大数据平台的小程序版本

index.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. // pages/userDrtail/index.js
  2. import * as echarts from '../../../components/ec-canvas/echarts';
  3. const app = getApp()
  4. Page({
  5. data: {
  6. ec: {
  7. lazyLoad: true
  8. },
  9. trendObj: {
  10. province_list: [],
  11. city_list: []
  12. },
  13. pageMove: 1,
  14. tab: 1,
  15. user_id: '',
  16. range: 1,
  17. timeObj:{id:1,name:'昨日'},
  18. addTimeObj: {id:7,name:'近7天'},
  19. moveObj: {},
  20. sexTrend: true,
  21. ageTrend: true,
  22. deviceTrend: true,
  23. pageLive: 1,
  24. safeAreaTop:50+app.data.safeAreaTop,
  25. followObj:{},
  26. timeList:[
  27. {id:1,name:'昨日'},
  28. {id:7,name:'近7天'},
  29. {id:30,name:'近30天'},
  30. ],
  31. isReset:false,
  32. isOneFalg:true,
  33. timeRangeList:[
  34. {id:7,name:'近7天'},
  35. {id:30,name:'近30天'},
  36. ],
  37. addDataObj:{},
  38. fanTrendTimeFlag:false,
  39. type: 1,
  40. pagesize:20,
  41. total:0,
  42. page:1,
  43. search_key_word:'',
  44. if_extlink:'',
  45. is_like_count_min:'',
  46. video_sort_type:{id:'createtime',name:'按最新'},
  47. video_list:[],
  48. video_sort_type_list:[
  49. {id:'createtime',name:'按最新'},
  50. {id:'like_count',name:'按点赞'},
  51. {id:'forward_count',name:'按转发'},
  52. {id:'comment_count',name:'按评论'},
  53. ],
  54. video_sort_type_flag:false,
  55. scrollTop:0,
  56. videoLoading:false,
  57. isHaveMoreData:true,
  58. liveDataObj:{},
  59. detailObj: {
  60. cookie_status:1
  61. },
  62. userExtAppListData:[{}],
  63. authorizeFlag:false,
  64. claimFlag:false,
  65. cookie_status:1
  66. },
  67. onLoad: function (options) {
  68. this.setData({
  69. user_id: options.user_id
  70. })
  71. },
  72. onShow() {
  73. this.getDetail();
  74. this.init()
  75. this.isClaim()
  76. },
  77. init(){
  78. if(this.data.type==1){
  79. if(this.data.tab==1) {
  80. this.getFollowData();
  81. this.getAddData();
  82. }else {
  83. this.getFansData();
  84. }
  85. }
  86. if(this.data.type ==2){
  87. this.setData({
  88. moveList: [],
  89. pageMove: 1,
  90. pagesMove: 1
  91. })
  92. this.getMoveData()
  93. this.getMoveList();
  94. }
  95. if(this.data.type==3){
  96. this.setData({
  97. liveList: [],
  98. pageLive: 1,
  99. pagesLive: 1
  100. })
  101. this.getLiveData()
  102. this.getLiveList()
  103. }
  104. },
  105. getFollowData(){//视频号--关注者数据
  106. wx.showLoading({
  107. title: '加载中',
  108. })
  109. app.func.req('/api/sphClaimInfo/followRangeIndex', 'get', {
  110. 'user_id': this.data.user_id,
  111. "range": this.data.range
  112. }, (res) => {
  113. wx.hideLoading()
  114. wx.stopPullDownRefresh();
  115. if(res && res.errno == 0){
  116. //成功
  117. this.setData({
  118. followObj: res.rst
  119. })
  120. }else if(res.errno!=4003){
  121. wx.showToast({
  122. title: res.err,
  123. icon: 'none',
  124. duration: 2000
  125. })
  126. }
  127. },(err)=>{
  128. wx.hideLoading()
  129. wx.stopPullDownRefresh();
  130. })
  131. },
  132. toDetail(e) {
  133. // return;
  134. wx.navigateTo({
  135. url: '/pages/moveDetail/moveDetail?user_id='+this.data.user_id+'&video_id='+e.currentTarget.dataset.item.video_id,
  136. })
  137. },
  138. goUserDetail(e){
  139. wx.navigateTo({
  140. url: '/pages/userDrtail/index?user_id='+e.currentTarget.dataset.user_id,
  141. })
  142. },
  143. goVideoDetail(e){
  144. wx.navigateTo({
  145. url: '/pages/videoDetail/videoDetail?video_id='+e.currentTarget.dataset.item.video_id+'&user_id='+e.currentTarget.dataset.item.user_id,
  146. })
  147. },
  148. checkTab(e) {
  149. this.setData({
  150. tab: e.currentTarget.dataset.type
  151. })
  152. this.init();
  153. },
  154. getFansData(){//粉丝画像
  155. wx.showLoading({
  156. title: '加载中',
  157. })
  158. app.func.req('/api/sphClaimUser/fansPortrait', 'get', {
  159. 'uid': this.data.user_id
  160. }, (res) => {
  161. wx.hideLoading()
  162. wx.stopPullDownRefresh();
  163. if(res && res.errno == 0){
  164. //成功
  165. var sexList = [],deviceList = [],ageObj = {nameList:[],valueList:[]};
  166. if(res.rst&&Object.keys(res.rst).length>0&&res.rst.sex_list) {
  167. res.rst.sex_list.forEach(item => {
  168. sexList.push({
  169. value: item.scale,
  170. name: item.dim
  171. })
  172. })
  173. }else {
  174. this.setData({
  175. trendObj: res.rst&&!Array.isArray(res.rst)&&Object.keys(res.rst)?res.rst:{
  176. province_list: [],
  177. city_list: []
  178. },
  179. sexList: sexList,
  180. deviceList: deviceList,
  181. ageObj: ageObj,
  182. sexTrend: sexList.length>0,
  183. deviceTrend: deviceList.length>0,
  184. ageTrend: ageObj.nameList.length>0,
  185. })
  186. console.log(this.data.trendObj)
  187. return;
  188. }
  189. Object.keys(res.rst).length>0&&res.rst.device_list&&res.rst.device_list.forEach(item => {
  190. deviceList.push({
  191. value: item.scale,
  192. name: item.dim
  193. })
  194. })
  195. Object.keys(res.rst).length>0&&res.rst.age_list&&res.rst.age_list.forEach(item => {
  196. ageObj.nameList.push(item.dim)
  197. ageObj.valueList.push(item.value)
  198. })
  199. this.setData({
  200. trendObj: res.rst,
  201. sexList: sexList,
  202. deviceList: deviceList,
  203. ageObj: ageObj,
  204. sexTrend: sexList.length>0,
  205. deviceTrend: deviceList.length>0,
  206. ageTrend: ageObj.nameList.length>0,
  207. })
  208. this.data.sexList.length>0&&this.sexTrend();
  209. this.data.deviceList.length>0&&this.deviceTrend();
  210. this.data.ageObj.nameList.length>0&&this.ageTrend();
  211. }else if(res.errno!=4003){
  212. wx.showToast({
  213. title: res.err,
  214. icon: 'none',
  215. duration: 2000
  216. })
  217. }
  218. },(err)=>{
  219. wx.hideLoading()
  220. wx.stopPullDownRefresh();
  221. })
  222. },
  223. //增长趋势数据
  224. getAddData(){
  225. app.func.req('/api/sphClaimInfo/followRangeChart', 'get', {
  226. "user_id": this.data.user_id,
  227. "begin_date": app.func.getDay(-Number(this.data.addTimeObj.id-1),false),
  228. "end_date": app.func.getDay(0,false)
  229. }, (res) => {
  230. if(res && res.errno == 0){
  231. wx.hideLoading()
  232. //成功
  233. this.setData({
  234. addDataObj: res.rst
  235. })
  236. this.addTrend()
  237. }else if(res.errno!=4003){
  238. wx.showToast({
  239. title: res.err,
  240. icon: 'none',
  241. duration: 2000
  242. })
  243. }
  244. })
  245. },
  246. addTrend(){//增长趋势
  247. var echartsComponnet = this.selectComponent('#addEcharts')
  248. var _this = this;
  249. echartsComponnet.init((canvas, width, height, dpr) => {
  250. // 初始化图表
  251. const Chart = echarts.init(canvas, null, {
  252. width: width,
  253. height: height,
  254. devicePixelRatio: dpr
  255. });
  256. var option = {
  257. tooltip : {
  258. trigger: 'axis',
  259. show: true,
  260. formatter:function(params) {
  261. var result = params[0].name + "\n";
  262. params.forEach((item, index) => {
  263. result +=
  264. item.seriesName +
  265. ":" + app.func.NumberHandle(item.value) +
  266. "\n";
  267. });
  268. return result;
  269. }
  270. },
  271. grid: {
  272. left: "7%",
  273. right: "0%",
  274. top: "3%",
  275. containLabel: true
  276. },
  277. legend: {
  278. show: true,
  279. bottom: '0%',
  280. textStyle: {
  281. color:'#000',
  282. fontSize: 10
  283. }
  284. },
  285. xAxis: [
  286. {
  287. type: "category",
  288. data: _this.data.addDataObj.date,
  289. axisLine: {
  290. lineStyle:{
  291. color:'#89899C'
  292. }
  293. },
  294. axisTick: {
  295. show: false
  296. },
  297. splitLine: {
  298. show: false
  299. },
  300. axisLabel:{
  301. color:'#89899C',
  302. fontSize:10,
  303. rotate:30,
  304. },
  305. }
  306. ],
  307. yAxis: [
  308. {
  309. type: "value",
  310. // name: "预估增量",
  311. axisLine: {
  312. show:false
  313. },
  314. axisTick: {
  315. show: false
  316. },
  317. splitLine: {
  318. lineStyle: {
  319. color: "#89899C",
  320. type: "dashed"
  321. }
  322. },
  323. axisLine: {
  324. lineStyle:{
  325. color:'#89899C'
  326. }
  327. },
  328. nameTextStyle: {
  329. color: "#89899C",
  330. fontSize:12,
  331. padding: [0, -30, 0, 0]
  332. },
  333. axisLabel: {
  334. color:'#89899C',
  335. fontSize:12,
  336. formatter: function(params) {
  337. var result = params;
  338. return app.func.NumberHandle(result);
  339. }
  340. }
  341. }
  342. ],
  343. series: [
  344. {
  345. smooth: true,
  346. type: "line",
  347. name:"新增关注",
  348. barWidth: (100 / _this.data.addDataObj.date.length) > 10 ? 10 : (100 / _this.data.addDataObj.date.length),
  349. data: _this.data.addDataObj.add,
  350. itemStyle: {
  351. opacity: 0,
  352. color: "#FF835E",
  353. barBorderRadius: [4, 4, 4, 4],
  354. borderType: "dotted"
  355. }
  356. },
  357. {
  358. smooth: true,
  359. type: "line",
  360. name:"净增关注",
  361. barWidth: (100 / _this.data.addDataObj.date.length) > 10 ? 10 : (100 / _this.data.addDataObj.date.length),
  362. data: _this.data.addDataObj.net_add,
  363. itemStyle: {
  364. opacity: 0,
  365. color: "#2662FF",
  366. barBorderRadius: [4, 4, 4, 4],
  367. borderType: "dotted"
  368. }
  369. },
  370. {
  371. smooth: true,
  372. type: "line",
  373. name:"取消关注",
  374. barWidth: (100 / _this.data.addDataObj.date.length) > 10 ? 10 : (100 / _this.data.addDataObj.date.length),
  375. data: _this.data.addDataObj.reduce,
  376. itemStyle: {
  377. opacity: 0,
  378. color: "#2EDD99",
  379. barBorderRadius: [4, 4, 4, 4],
  380. borderType: "dotted"
  381. }
  382. },
  383. {
  384. smooth: true,
  385. type: "line",
  386. name:"关注者数",
  387. barWidth: (100 / _this.data.addDataObj.date.length) > 10 ? 10 : (100 / _this.data.addDataObj.date.length),
  388. data: _this.data.addDataObj.total,
  389. itemStyle: {
  390. opacity: 0,
  391. color: "#8C5EFF",
  392. barBorderRadius: [4, 4, 4, 4],
  393. borderType: "dotted"
  394. }
  395. }]
  396. };
  397. Chart.setOption(option);
  398. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  399. return Chart;
  400. });
  401. },
  402. //性别
  403. sexTrend(){
  404. var echartsComponnet = this.selectComponent('#sexEcharts')
  405. var _this = this;
  406. echartsComponnet.init((canvas, width, height, dpr) => {
  407. // 初始化图表
  408. const Chart = echarts.init(canvas, null, {
  409. width: width,
  410. height: height,
  411. devicePixelRatio: dpr
  412. });
  413. var option = {
  414. color: ['#6ECFFE','#6E71F2','#FEA33F'],
  415. tooltip: {
  416. trigger: 'item',
  417. formatter(data) {
  418. return data.data.name+':'+data.value+'%'
  419. }
  420. },
  421. grid: {
  422. left: "3%",
  423. right: "10%",
  424. top: "2%",
  425. bottom: '2%',
  426. containLabel: true
  427. },
  428. legend: {
  429. show: true,
  430. bottom: '0%',
  431. textStyle: {
  432. color:'#000',
  433. fontSize: 10
  434. }
  435. },
  436. series: [{
  437. type: 'pie',
  438. radius: ['40%', '60%'],
  439. avoidLabelOverlap: false,
  440. avoidLabelOverlap:true,//是否启用防止标签重叠策略
  441. minShowLabelAngle: 2,
  442. minAngle: 22,//最小的扇区角度(0 ~ 360),用于防止某个值过小导致扇区太小影响交互
  443. label: {
  444. normal: {
  445. formatter: '{a|{b}}{abg|}\n{hr|}\n {per|{d}%}',
  446. rich: {
  447. a: {
  448. color: '#666666',
  449. fontSize: 11,
  450. lineHeight: 20,
  451. align: 'center'
  452. },
  453. hr: {
  454. width: '100%',
  455. height: 0,
  456. alien:'center'
  457. },
  458. per: {
  459. color: '#000000',
  460. align: 'center',
  461. fontSize: 13,
  462. }
  463. }
  464. }
  465. },
  466. labelLine: {
  467. normal: {
  468. show: true
  469. }
  470. },
  471. data: _this.data.sexList
  472. }]
  473. };
  474. Chart.setOption(option);
  475. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  476. return Chart;
  477. });
  478. },
  479. //设备
  480. deviceTrend(){
  481. var echartsComponnet = this.selectComponent('#deviceEcharts')
  482. var _this = this;
  483. echartsComponnet.init((canvas, width, height, dpr) => {
  484. // 初始化图表
  485. const Chart = echarts.init(canvas, null, {
  486. width: width,
  487. height: height,
  488. devicePixelRatio: dpr
  489. });
  490. var option = {
  491. color: ['#6ECFFE','#6E71F2','#FEA33F','#FEED6E','#FE6E6E','#6EFEAA'],
  492. tooltip: {
  493. trigger: 'item',
  494. formatter(data) {
  495. return data.data.name+':'+data.value+'%'
  496. }
  497. },
  498. grid: {
  499. left: "3%",
  500. right: "10%",
  501. top: "2%",
  502. bottom: '2%',
  503. containLabel: true
  504. },
  505. legend: {
  506. show: true,
  507. bottom: '0%',
  508. textStyle: {
  509. color:'#000',
  510. fontSize: 10
  511. }
  512. },
  513. series: [{
  514. type: 'pie',
  515. radius: ['40%', '60%'],
  516. avoidLabelOverlap: false,
  517. avoidLabelOverlap:true,//是否启用防止标签重叠策略
  518. minShowLabelAngle: 2,
  519. minAngle: 22,//最小的扇区角度(0 ~ 360),用于防止某个值过小导致扇区太小影响交互
  520. label: {
  521. normal: {
  522. formatter: '{a|{b}}{abg|}\n{hr|}\n {per|{d}%}',
  523. rich: {
  524. a: {
  525. color: '#666666',
  526. fontSize: 11,
  527. lineHeight: 20,
  528. align: 'center'
  529. },
  530. hr: {
  531. width: '100%',
  532. height: 0,
  533. alien:'center'
  534. },
  535. per: {
  536. color: '#000000',
  537. align: 'center',
  538. fontSize: 13,
  539. }
  540. }
  541. }
  542. },
  543. labelLine: {
  544. normal: {
  545. show: true
  546. }
  547. },
  548. data: _this.data.deviceList
  549. }]
  550. };
  551. Chart.setOption(option);
  552. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  553. return Chart;
  554. });
  555. },
  556. ageTrend(){//年龄分布
  557. var echartsComponnet = this.selectComponent('#ageEcharts')
  558. var _this = this;
  559. echartsComponnet.init((canvas, width, height, dpr) => {
  560. // 初始化图表
  561. const Chart = echarts.init(canvas, null, {
  562. width: width,
  563. height: height,
  564. devicePixelRatio: dpr
  565. });
  566. var option = {
  567. tooltip : {
  568. trigger: 'axis',
  569. show: true,
  570. formatter:function(params) {
  571. params = params[0];
  572. var result = "";
  573. result = params.name + ':' + (params.value?(params.value):'-')
  574. return result;
  575. }
  576. },
  577. grid: {
  578. left: "0%",
  579. right: "0%",
  580. bottom: '0%',
  581. top: '4%',
  582. containLabel: true
  583. },
  584. legend: {
  585. show: true,
  586. bottom: '0%',
  587. textStyle: {
  588. color:'#000',
  589. fontSize: 10
  590. }
  591. },
  592. xAxis: [
  593. {
  594. type: "category",
  595. data: _this.data.ageObj.nameList,
  596. axisLine: {
  597. lineStyle:{
  598. color:'#89899C'
  599. }
  600. },
  601. axisTick: {
  602. show: false
  603. },
  604. splitLine: {
  605. show: false
  606. },
  607. axisLabel:{
  608. color:'#89899C',
  609. fontSize:10,
  610. rotate:30,
  611. },
  612. }
  613. ],
  614. yAxis: [
  615. {
  616. type: "value",
  617. axisLine: {
  618. lineStyle:{
  619. color:'#ECEDF2'
  620. }
  621. },
  622. min: function (value) {
  623. return value.min <= 0 ? value.min : 0;
  624. },
  625. axisTick: {
  626. show: false
  627. },
  628. splitLine: {
  629. lineStyle: {
  630. color: "#89899C",
  631. type: "dashed"
  632. }
  633. },
  634. axisLine: {
  635. lineStyle:{
  636. color:'#89899C'
  637. }
  638. },
  639. nameTextStyle: {
  640. color: "#999999",
  641. fontSize:14,
  642. padding: [0, -20, 0, 0]
  643. },
  644. axisLabel: {
  645. color:'#999999',
  646. fontSize:13,
  647. }
  648. }
  649. ],
  650. series: [
  651. {
  652. smooth: true,
  653. type: "bar",
  654. // name:"新增关注",
  655. barWidth: (100 / _this.data.ageObj.nameList.length) > 10 ? 10 : (100 / _this.data.ageObj.nameList.length),
  656. data: _this.data.ageObj.valueList,
  657. itemStyle: {
  658. color: "#4B76FB",
  659. barBorderRadius: [4, 4, 4, 4],
  660. borderType: "dotted"
  661. }
  662. }]
  663. };
  664. Chart.setOption(option);
  665. // 注意这里一定要返回 chart 实例,否则会影响事件处理等
  666. return Chart;
  667. });
  668. },
  669. showTime(e) {
  670. switch (e.currentTarget.dataset.type) {
  671. case '1':
  672. this.setData({
  673. showTimeCheck: !this.data.showTimeCheck
  674. })
  675. break;
  676. case '2':
  677. this.setData({
  678. showFollowTime: !this.data.showFollowTime
  679. })
  680. break;
  681. default:
  682. break;
  683. }
  684. },
  685. closeDiv() {
  686. this.setData({
  687. showTimeCheck: false,
  688. showFollowTime: false
  689. })
  690. },
  691. checkTime(e) {
  692. // 关注者数据的周期指标
  693. if(e.currentTarget.dataset.type==1) {
  694. this.setData({
  695. timeObj: e.currentTarget.dataset.item,
  696. showTimeCheck: false,
  697. range: e.currentTarget.dataset.item.id
  698. })
  699. if(this.data.type==1) {
  700. this.getFollowData();
  701. }else if(this.data.type==2) {
  702. this.getMoveData();
  703. }else {
  704. this.getLiveData();
  705. }
  706. }else if(e.currentTarget.dataset.type==2) {
  707. wx.showLoading({
  708. title: '加载中',
  709. })
  710. this.setData({
  711. addTimeObj: e.currentTarget.dataset.item,
  712. showFollowTime: false
  713. })
  714. this.getAddData();
  715. }
  716. },
  717. // 重新激活
  718. againActivationEvent(e){
  719. var user_id = e.currentTarget.dataset.user_id
  720. this.setData({isReset:true,user_id:user_id})
  721. this.getToken()
  722. },
  723. cancelTask(){
  724. this.setData({claimTaskFlag:false,authorizeFlag:false})
  725. },
  726. getToken(){
  727. wx.showLoading({
  728. title: '获取授权码',
  729. })
  730. this.setData({claimTaskFlag:false})
  731. app.func.req('/api/sphClaim/getToken', 'get', {
  732. }, (res) => {
  733. wx.hideLoading()
  734. wx.stopPullDownRefresh()
  735. if(res && res.errno == 0){
  736. //成功
  737. this.setData({
  738. authorizeFlag:true,
  739. imgCode:'https://sph.wenxingshuju.com/wx_sph/api/sphClaim/getQRcode?token='+res.rst.token,
  740. token:res.rst.token
  741. })
  742. }else{
  743. wx.showToast({
  744. title: res.err,
  745. icon: 'none',
  746. duration: 2000
  747. })
  748. }
  749. },()=>{
  750. wx.stopPullDownRefresh()
  751. wx.hideLoading()
  752. })
  753. },
  754. typeEvent(e){
  755. var data = e.currentTarget.dataset;
  756. if(data.type == this.data.type){
  757. return
  758. }
  759. this.setData({
  760. timeObj:{id:1,name:'昨日'},
  761. addTimeObj: {id:7,name:'近7天'},
  762. type:data.type
  763. })
  764. this.init()
  765. },
  766. closeToast(){
  767. this.setData({
  768. fanTrendTimeFlag:false,
  769. zzcFlag:false,
  770. video_sort_type_flag:false
  771. })
  772. },
  773. getMoveData(){//动态数据
  774. app.func.req('/api/sphClaimInfo/dynamicRangeIndex', 'get', {
  775. "user_id": this.data.user_id,
  776. "range": this.data.range
  777. }, (res) => {
  778. if(res && res.errno == 0){
  779. //成功
  780. this.setData({
  781. moveObj: res.rst
  782. })
  783. }else if(res.errno!=4003){
  784. wx.showToast({
  785. title: res.err,
  786. icon: 'none',
  787. duration: 2000
  788. })
  789. }
  790. },(err)=>{
  791. this.setData({
  792. videoLoading:false
  793. })
  794. wx.hideLoading()
  795. })
  796. },
  797. getMoveList(){//动态列表
  798. wx.showLoading({
  799. title: '加载中',
  800. })
  801. app.func.req('/api/sphClaimUser/videoIndex', 'get', {
  802. "uid": this.data.user_id,
  803. "page": this.data.pageMove?this.data.pageMove:1,
  804. "page_size": 2,
  805. }, (res) => {
  806. wx.hideLoading()
  807. this.setData({
  808. videoLoading:false
  809. })
  810. if(res && res.errno == 0){
  811. //成功
  812. var moveList = []
  813. if(this.data.pageMove==1) {
  814. moveList = res.rst.data
  815. }else {
  816. moveList = this.data.moveList.concat(res.rst.data);
  817. }
  818. this.setData({
  819. moveList: moveList,
  820. pagesMove: res.rst.pageInfo.pages,
  821. moveLength: moveList.length>0?moveList.length:-1
  822. })
  823. }else if(res.errno!=4003){
  824. wx.showToast({
  825. title: res.err,
  826. icon: 'none',
  827. duration: 2000
  828. })
  829. }
  830. },(err)=>{
  831. this.setData({
  832. videoLoading:false
  833. })
  834. wx.hideLoading()
  835. })
  836. },
  837. video_sort_type_click(){
  838. this.setData({
  839. zzcFlag:!this.data.video_sort_type_flag,
  840. video_sort_type_flag:!this.data.video_sort_type_flag,
  841. })
  842. },
  843. videoSeachInputChange(e){
  844. this.setData({
  845. search_key_word: e.detail.value
  846. })
  847. },
  848. goVideoDetail(e){
  849. wx.navigateTo({
  850. url: '/pages/videoDetail/videoDetail?video_id='+e.currentTarget.dataset.item.video_id+'&user_id='+this.data.user_id,
  851. })
  852. },
  853. onPageScroll: function(res) {//获取滑动的距离
  854. this.setData({
  855. scrollTop:res.scrollTop
  856. })
  857. },
  858. goScrolltop:function(e){//返回顶部
  859. if (wx.pageScrollTo) {
  860. wx.pageScrollTo({
  861. scrollTop: 0
  862. })
  863. } else {
  864. wx.showModal({
  865. title: '提示',
  866. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  867. })
  868. }
  869. },
  870. /**
  871. * 页面上拉触底事件的处理函数
  872. */
  873. onReachBottom: function () {
  874. if(this.data.type==2&&this.data.pageMove<this.data.pagesMove) {
  875. this.setData({
  876. pageMove: this.data.pageMove+1
  877. })
  878. this.getMoveList();
  879. }else if(this.data.type==3&&this.data.pageLive<this.data.pagesLive) {
  880. this.setData({
  881. pageLive: this.data.pageLive+1
  882. })
  883. this.getLiveList();
  884. }
  885. },
  886. checkBoxEvent(e){
  887. var data = e.currentTarget.dataset;
  888. this.setData({
  889. [data.type] : this.data[data.type]==1?0:1
  890. })
  891. this.getMoveData()
  892. },
  893. getLiveData(){//挂链分析
  894. wx.showLoading({
  895. title: '加载中',
  896. })
  897. app.func.req('/api/sphClaimInfo/liveRangeIndex', 'get', {
  898. user_id:this.data.user_id,
  899. range: this.data.range
  900. }, (res) => {
  901. wx.hideLoading()
  902. if(res && res.errno == 0){
  903. this.setData({
  904. liveDataObj:res.rst
  905. })
  906. }else{
  907. wx.showToast({
  908. title: res.err,
  909. icon: 'none',
  910. duration: 2000
  911. })
  912. }
  913. },()=>{
  914. wx.hideLoading()
  915. })
  916. },
  917. getDetail(){
  918. app.func.req('/api/sphClaimInfo/list', 'get', {
  919. user_id:this.data.user_id
  920. }, (res) => {
  921. if(res && res.errno == 0){
  922. this.setData({
  923. detailObj:res.rst.length>0?res.rst[0]:{}
  924. })
  925. }else{
  926. wx.showToast({
  927. title: res.err,
  928. icon: 'none',
  929. duration: 2000
  930. })
  931. }
  932. },()=>{
  933. })
  934. },
  935. getLiveList(){
  936. app.func.req('/api/sphClaimUser/liveIndex', 'get', {
  937. uid:this.data.user_id,
  938. page: this.data.pageLive?this.data.pageLive:1,
  939. page_size: 20,
  940. sort: 'createTime'
  941. }, (res) => {
  942. if(res && res.errno == 0){
  943. var liveList = [];
  944. if(this.data.pageLive==1) {
  945. liveList = res.rst.data
  946. }else {
  947. liveList = this.data.liveList.concat(res.rst.data);
  948. }
  949. this.setData({
  950. liveList: liveList,
  951. pagesLive: res.rst.pageInfo.pages,
  952. liveLength: liveList.length>0?liveList.length:-1
  953. })
  954. }else{
  955. wx.showToast({
  956. title: res.err,
  957. icon: 'none',
  958. duration: 2000
  959. })
  960. }
  961. },()=>{
  962. })
  963. },
  964. claimInit(){
  965. this.setData({authorizeFlag:false})
  966. this.isClaim()
  967. },
  968. goClaim(){
  969. if(!this.data.claimFlag||this.data.cookie_status!=1){//去认领
  970. this.setData({authorizeFlag:true})
  971. }else{
  972. // wx.navigateTo({
  973. // url: '/pages/claim/index/index',
  974. // })
  975. }
  976. },
  977. isClaim(){//判断是否认领
  978. app.func.req('/api/sphClaim/isClaim', 'get', {
  979. uid: this.data.user_id
  980. }, (res) => {
  981. this.setData({claimFlag : res.rst})
  982. if(this.data.claimFlag){
  983. app.func.req('/api/sphClaimInfo/list', 'get', {
  984. user_id:this.data.user_id
  985. }, (res) => {
  986. if(res && res.errno == 0){
  987. if(res.rst.length!=0){
  988. this.setData({
  989. cookie_status:res.rst[0].cookie_status,
  990. })
  991. }
  992. }else{
  993. wx.showToast({
  994. title: res.err,
  995. icon: 'none',
  996. duration: 2000
  997. })
  998. }
  999. },()=>{
  1000. })
  1001. }
  1002. },(err)=>{
  1003. })
  1004. },
  1005. onPullDownRefresh: function () {
  1006. this.getFollowData()
  1007. this.init()
  1008. },
  1009. onShareAppMessage: function (res) {
  1010. return {
  1011. title:'问星数据【视频号版】最新的视频号分析工具',
  1012. }
  1013. }
  1014. })