communitactiv.js 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. const app=getApp();
  2. const utils=require("../../../utils/http");
  3. import * as echarts from '../../ec-canvas/echarts';
  4. var dataList = [];
  5. var dataList0 = [];
  6. var dataList1 = [];
  7. var obj=[];
  8. var time = [];
  9. var Chart = null;
  10. var that
  11. var list = [];
  12. let pkpage=1,page=1;
  13. let trpage=1;//团队
  14. let mrpage=1;//员工
  15. Page({
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. loadflag:0,//0是进来的状态,1是加入团队,2是没有加入团队
  21. wburl:app.globalData.wburl,
  22. imgUrl:app.globalData.imgUrl,
  23. ec: {
  24. lazyLoad: true // 延迟加载
  25. },
  26. type:1,
  27. funshow:false,
  28. despointshow:false,
  29. signshow:false,
  30. chartflag:true,
  31. lunarr:['第一轮','第二轮','第三轮'],
  32. oppoflag:false,
  33. lunidx:0,
  34. footype:1,
  35. rtype:1,
  36. aid:'',
  37. addfunimgarr:[],
  38. funnum:0,
  39. editflag:false,
  40. nowimagearr:[],//当前上传oss图片的路径
  41. depositshow:false,
  42. addepositimgarr:[],
  43. depositnum:0,
  44. contractshow:false,
  45. addcontractimgarr:[],
  46. contractnum:0,
  47. wxindexobj:{},
  48. footfun:[],
  49. footdespoit:[],
  50. pkfootfun:[],
  51. pkfootdespoit:[],
  52. personobj: app.globalData.personMsg,
  53. numtype:'fans',
  54. recordlist:[],
  55. PKobj:{},
  56. datashow:false,
  57. ranktype:'fans',//fans deposit contract
  58. sort:'desc',
  59. teamobj:[],
  60. myteamobj:{},
  61. personranklist:[],
  62. mydataobj:{},
  63. pk_contract:[],
  64. teamlist:[],
  65. atitle:'',
  66. nowteamidx:0
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad: function (options) {
  72. this.setData({
  73. aid:options.aid,
  74. personobj: app.globalData.personMsg,
  75. wburl:app.globalData.wburl,
  76. imgUrl:app.globalData.imgUrl,
  77. atitle:options.name
  78. })
  79. wx.showLoading({
  80. title: '加载中...',
  81. })
  82. this.topindexdatafun();
  83. },
  84. bindteamChange(e){
  85. const that=this;
  86. this.setData({
  87. nowteamidx:e.detail.value
  88. })
  89. },
  90. topindexdatafun(){
  91. const that=this;
  92. utils.$get({
  93. url: app.globalData.webUrl + 'api/wechatActivity/empData',
  94. header: {
  95. 'Authorization':'bearer '+app.globalData.token
  96. },
  97. data:{
  98. activity_id:this.data.aid
  99. },
  100. success: function (res) {
  101. if(res.data.code=='0'){
  102. if(res.data.data.length==0){
  103. that.setData({
  104. loadflag:2
  105. })
  106. wx.setNavigationBarTitle({
  107. title: '队伍邀请',
  108. })
  109. that.teamlistfun();
  110. }else{
  111. if(res.data.data.my.lv.length!=0){
  112. let num1=res.data.data.my.lv.my_deposit_lv.my_deposit_num/res.data.data.my.lv.my_deposit_lv.deposit_Num
  113. res.data.data.my.lv.my_deposit_lv.finishlv=num1*100+'%';
  114. let num2=res.data.data.my.lv.my_fans_lv.my_fans_num/res.data.data.my.lv.my_fans_lv.fans_Num
  115. res.data.data.my.lv.my_fans_lv.finishlv=num1*100+'%';
  116. }
  117. that.setData({
  118. loadflag:1,
  119. wxindexobj:res.data.data,
  120. lunarr:res.data.data.bar?res.data.data.bar.x:[],
  121. footfun:res.data.data.bar?res.data.data.bar.y.my_fans:[],
  122. footdespoit:res.data.data.bar?res.data.data.bar.y.my_deposit:[],
  123. pkfootfun:res.data.data.bar&&res.data.data.bar.y.pk_fans?res.data.data.bar.y.pk_fans:[],
  124. pkfootdespoit:res.data.data.bar&&res.data.data.bar.y.pk_deposit?res.data.data.bar.y.pk_deposit:[],
  125. pk_contract:res.data.data.bar&&res.data.data.bar.y.pk_contract?res.data.data.bar.y.pk_contract:[],
  126. })
  127. that.echartsComponnet = that.selectComponent('#mychart-dom-bar');
  128. that.init_echarts();
  129. }
  130. }
  131. setTimeout(function(){
  132. wx.hideLoading()
  133. },1000)
  134. }
  135. })
  136. },
  137. teamlistfun(){
  138. const that=this;
  139. utils.$get({
  140. url: app.globalData.webUrl + "api/wechatActivity/team",
  141. header: {
  142. 'Authorization':'bearer '+app.globalData.token
  143. },
  144. data:{
  145. activity_id:that.data.aid
  146. },
  147. success: function (res) {
  148. if(res.data.code=='0'){
  149. that.setData({
  150. teamlist:res.data.data
  151. })
  152. }
  153. setTimeout(function(){
  154. wx.hideLoading()
  155. },1000)
  156. }
  157. })
  158. },
  159. jointeamtap(){
  160. const that=this;
  161. wx.showLoading({
  162. title: '队伍加入中...',
  163. })
  164. utils.$post({
  165. url: app.globalData.webUrl + "api/wechatActivity/join",
  166. header: {
  167. 'Authorization':'bearer '+app.globalData.token
  168. },
  169. data:{
  170. activity_id:that.data.aid,
  171. team_id:that.data.teamlist[that.data.nowteamidx].id
  172. },
  173. success: function (res) {
  174. if(res.data.code=='0'){
  175. wx.showToast({
  176. title: res.data.msg,
  177. icon:'none',
  178. duration: 2000
  179. })
  180. that.topindexdatafun();
  181. }else{
  182. setTimeout(function(){
  183. wx.hideLoading()
  184. },1000)
  185. }
  186. }
  187. })
  188. },
  189. inputfuntap(e){
  190. this.setData({
  191. funnum:e.detail.value
  192. })
  193. },
  194. editap(){
  195. this.setData({
  196. editflag:true
  197. })
  198. },
  199. upfunloadimg:function(){
  200. const that=this;
  201. wx.chooseMedia({
  202. count: 3,
  203. mediaType:['image'],
  204. sizeType: ['compressed'],
  205. sourceType: ['album', 'camera'],
  206. success (res) {
  207. let addfunimgarr=that.data.addfunimgarr;
  208. if(res.errMsg=="chooseMedia:ok"){
  209. console.log(res)
  210. let arr=res.tempFiles;
  211. for(let i=0;i<arr.length;i++){
  212. if(addfunimgarr.length<3){
  213. addfunimgarr.push(arr[i]);
  214. }else{
  215. addfunimgarr.shift();
  216. addfunimgarr.push(arr[i]);
  217. }
  218. }
  219. that.setData({
  220. addfunimgarr:addfunimgarr,
  221. funnum:addfunimgarr.length,
  222. })
  223. if(addfunimgarr.length>=3){
  224. wx.showToast({
  225. title: '最多上传三张图片!',
  226. icon:'none',
  227. duration: 2000
  228. })
  229. }
  230. }
  231. },
  232. fail(res){
  233. wx.showToast({
  234. title: '上传失败请重试!',
  235. icon: 'error',
  236. duration: 2000
  237. })
  238. }
  239. })
  240. },
  241. ossuploadimg:function(e){
  242. let that=this;
  243. let addfunimgarr=[];
  244. if(this.data.funshow){
  245. addfunimgarr=that.data.addfunimgarr;
  246. }else if(this.data.depositshow){
  247. addfunimgarr=that.data.addepositimgarr;
  248. }else if(this.data.contractshow){
  249. addfunimgarr=that.data.addcontractimgarr;
  250. }
  251. var arr = [];
  252. for (let i = 0; i < addfunimgarr.length; i++) {
  253. //获取文件后缀
  254. // 随机生成文件名称
  255. let rstr=addfunimgarr[i].tempFilePath.split('.');
  256. var fileRandName = Date.now() + "" + parseInt(Math.random() *10000)+i;
  257. var imgName = fileRandName + '.' + rstr[rstr.length-1];
  258. var date=new Date();
  259. var time=date.getFullYear()+''+(date.getMonth()*1+1)+''+date.getDate();
  260. var imgstr= 'communityActivism/'+time+'/'+imgName;
  261. var nowimagearr=that.data.nowimagearr;
  262. nowimagearr.push(imgstr);
  263. that.setData({
  264. nowimagearr:nowimagearr
  265. })
  266. // 上传有效时间 2040-01-01
  267. wx.uploadFile({
  268. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  269. filePath: addfunimgarr[i].tempFilePath,
  270. name: 'file',
  271. formData: {
  272. key: 'communityActivism/'+time+'/' + imgName,
  273. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  274. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  275. success_action_status: "200",
  276. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  277. },
  278. header: {
  279. "Content-Type": "multipart/form-data",
  280. 'accept': 'application/json',
  281. },
  282. success: function (rs) {
  283. if (rs.errMsg == 'uploadFile:ok' ) {
  284. arr.push('0');
  285. if(arr.length==addfunimgarr.length){
  286. that.addrecord();
  287. }
  288. }
  289. },
  290. fail(res){
  291. wx.hideLoading()
  292. }
  293. })
  294. }
  295. },
  296. addfuntap(){
  297. const that=this;
  298. if(!this.data.addfunimgarr.length){
  299. wx.showToast({
  300. title: '微信截图必须上传!',
  301. icon:'none',
  302. duration: 2000
  303. })
  304. return false
  305. }
  306. wx.showLoading({
  307. title: '数据上传中...',
  308. })
  309. this.ossuploadimg();
  310. },
  311. addrecord(){
  312. const that=this;
  313. let str="";
  314. if(this.data.funshow){
  315. str='api/wechatActivity/addFans';
  316. }else if(this.data.depositshow){
  317. str='api/wechatActivity/addDeposit';
  318. }else if(this.data.contractshow){
  319. str='api/wechatActivity/addContract';
  320. }
  321. utils.$post({
  322. url: app.globalData.webUrl + str,
  323. header: {
  324. 'Authorization':'bearer '+app.globalData.token
  325. },
  326. data:{
  327. activity_id:this.data.aid,
  328. num:this.data.funshow?this.data.funnum:this.data.depositshow?that.data.depositnum:that.data.contractnum,
  329. img_log:this.data.nowimagearr
  330. },
  331. success: function (res) {
  332. if(res.data.code=='0'){
  333. wx.showToast({
  334. title: '加粉上传成功!',
  335. icon: 'none',
  336. duration: 2000
  337. })
  338. that.closefuntap();
  339. that.closedeposittap();
  340. that.closecontractap();
  341. }
  342. setTimeout(function(){
  343. wx.hideLoading()
  344. },1000)
  345. }
  346. })
  347. },
  348. depositap(){
  349. this.setData({
  350. depositshow:true,
  351. chartflag:false
  352. })
  353. },
  354. closedeposittap(){
  355. this.setData({
  356. depositshow:false,
  357. chartflag:true,
  358. nowimagearr:[],
  359. addepositimgarr:[],
  360. editflag:false,
  361. })
  362. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  363. this.init_echarts();
  364. },
  365. updepositloadimg:function(){
  366. const that=this;
  367. wx.chooseMedia({
  368. count: 3,
  369. mediaType:['image'],
  370. sizeType: ['compressed'],
  371. sourceType: ['album', 'camera'],
  372. success (res) {
  373. let addepositimgarr=that.data.addepositimgarr;
  374. if(res.errMsg=="chooseMedia:ok"){
  375. console.log(res)
  376. let arr=res.tempFiles;
  377. for(let i=0;i<arr.length;i++){
  378. if(addepositimgarr.length<3){
  379. addepositimgarr.push(arr[i]);
  380. }else{
  381. addepositimgarr.shift();
  382. addepositimgarr.push(arr[i]);
  383. }
  384. }
  385. that.setData({
  386. addepositimgarr:addepositimgarr,
  387. depositnum:addepositimgarr.length
  388. })
  389. if(addepositimgarr.length>=3){
  390. wx.showToast({
  391. title: '最多上传三张图片!',
  392. icon:'none',
  393. duration: 2000
  394. })
  395. }
  396. }
  397. },
  398. fail(res){
  399. wx.showToast({
  400. title: '上传失败请重试!',
  401. icon: 'error',
  402. duration: 2000
  403. })
  404. }
  405. })
  406. },
  407. inputdepositap(e){
  408. this.setData({
  409. depositnum:e.detail.value
  410. })
  411. },
  412. addepositap(){
  413. const that=this;
  414. if(!this.data.addepositimgarr.length){
  415. wx.showToast({
  416. title: '微信截图必须上传!',
  417. icon:'none',
  418. duration: 2000
  419. })
  420. return false
  421. }
  422. wx.showLoading({
  423. title: '数据上传中...',
  424. })
  425. this.ossuploadimg();
  426. },
  427. contractap(){
  428. this.setData({
  429. contractshow:true,
  430. chartflag:false
  431. })
  432. },
  433. closecontractap(){
  434. this.setData({
  435. contractshow:false,
  436. chartflag:true,
  437. nowimagearr:[],
  438. addcontractimgarr:[],
  439. editflag:false,
  440. })
  441. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  442. this.init_echarts();
  443. },
  444. upcontractloadimg:function(){
  445. const that=this;
  446. wx.chooseMedia({
  447. count: 3,
  448. mediaType:['image'],
  449. sizeType: ['compressed'],
  450. sourceType: ['album', 'camera'],
  451. success (res) {
  452. let addcontractimgarr=that.data.addcontractimgarr;
  453. if(res.errMsg=="chooseMedia:ok"){
  454. console.log(res)
  455. let arr=res.tempFiles;
  456. for(let i=0;i<arr.length;i++){
  457. if(addcontractimgarr.length<3){
  458. addcontractimgarr.push(arr[i]);
  459. }else{
  460. addcontractimgarr.shift();
  461. addcontractimgarr.push(arr[i]);
  462. }
  463. }
  464. that.setData({
  465. addcontractimgarr:addcontractimgarr,
  466. contractnum:addcontractimgarr.length
  467. })
  468. if(addcontractimgarr.length>=3){
  469. wx.showToast({
  470. title: '最多上传三张图片!',
  471. icon:'none',
  472. duration: 2000
  473. })
  474. }
  475. }
  476. },
  477. fail(res){
  478. wx.showToast({
  479. title: '上传失败请重试!',
  480. icon: 'error',
  481. duration: 2000
  482. })
  483. }
  484. })
  485. },
  486. inputcontractap(e){
  487. this.setData({
  488. contractnum:e.detail.value
  489. })
  490. },
  491. addcontractap(){
  492. const that=this;
  493. if(!this.data.addcontractimgarr.length){
  494. wx.showToast({
  495. title: '微信截图必须上传!',
  496. icon:'none',
  497. duration: 2000
  498. })
  499. return false
  500. }
  501. wx.showLoading({
  502. title: '数据上传中...',
  503. })
  504. this.ossuploadimg();
  505. },
  506. setechartypetap(e){
  507. this.setData({
  508. type:e.currentTarget.dataset.type
  509. })
  510. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  511. this.init_echarts();
  512. },
  513. footsetypetap(e){
  514. this.setData({
  515. footype:e.currentTarget.dataset.type
  516. })
  517. if(this.data.footype==1){
  518. wx.setNavigationBarTitle({
  519. title: '社群活动'
  520. })
  521. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  522. this.init_echarts();
  523. }else if(this.data.footype==2){
  524. wx.setNavigationBarTitle({
  525. title: '操作记录'
  526. })
  527. this.setData({
  528. lunidx:0,
  529. })
  530. this.setrecord();
  531. }else if(this.data.footype==3){
  532. wx.setNavigationBarTitle({
  533. title: '团队管理'
  534. })
  535. this.setData({
  536. rtype:1,
  537. lunidx:0,
  538. })
  539. this.teamRankfun();
  540. }
  541. },
  542. openoppotap(){
  543. this.setData({
  544. oppoflag:true,
  545. chartflag:false,
  546. recordlist:[],
  547. PKobj:[],
  548. })
  549. this.setrecord();
  550. },
  551. closeoppotap(){
  552. this.setData({
  553. oppoflag:false,
  554. chartflag:true
  555. })
  556. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  557. this.init_echarts();
  558. },
  559. bindPickerChange: function(e) {
  560. this.setData({
  561. lunidx: e.detail.value
  562. })
  563. this.setrecord();
  564. },
  565. lookimgtap(e){
  566. var arr=[];
  567. for(var i=0;i<this.data.recordlist[e.currentTarget.dataset.idx].img_log.length;i++){
  568. arr.push(app.globalData.imgUrl+this.data.recordlist[e.currentTarget.dataset.idx].img_log[i]);
  569. }
  570. wx.previewImage({
  571. current: app.globalData.imgUrl+this.data.recordlist[e.currentTarget.dataset.idx].img_log[e.currentTarget.dataset.imgidx], // 当前显示图片的 http 链接
  572. urls:arr // 需要预览的图片 http 链接列表
  573. })
  574. },
  575. setypetap(e){
  576. this.setData({
  577. numtype:e.currentTarget.dataset.type
  578. })
  579. this.setrecord();
  580. },
  581. // 操作记录
  582. setrecord:function(){
  583. const that=this;
  584. let p=1;
  585. if(this.data.oppoflag){
  586. pkpage=1;
  587. }else{
  588. page=1;
  589. }
  590. // type:fans deposit contract, pk:1 对手数据, schedule第几轮
  591. utils.$post({
  592. url: app.globalData.webUrl + "api/wechatActivity/log",
  593. header: {
  594. 'Authorization':'bearer '+app.globalData.token
  595. },
  596. data:{
  597. activity_id:that.data.aid,
  598. type:that.data.numtype,
  599. page:p,
  600. limit:10,
  601. schedule:that.data.lunidx*1+1,
  602. pk:that.data.oppoflag?1:0
  603. },
  604. success: function (res) {
  605. that.setData({
  606. datashow:true
  607. })
  608. if(res.data.code=='0'){
  609. that.setData({
  610. recordlist:res.data.data.log,
  611. PKobj:res.data.data.pk?res.data.data.pk:{}
  612. })
  613. }else{
  614. console.log(113)
  615. that.closeoppotap();
  616. }
  617. setTimeout(function(){
  618. wx.hideLoading()
  619. },1000)
  620. }
  621. })
  622. },
  623. setrecordgun(){
  624. const that=this;
  625. let p=1;
  626. if(this.data.oppoflag){
  627. pkpage=pkpage*1+1;
  628. p=pkpage;
  629. }else{
  630. page=page*1+1;
  631. p=page;
  632. }
  633. utils.$post({
  634. url: app.globalData.webUrl + "api/wechatActivity/log",
  635. header: {
  636. 'Authorization':'bearer '+app.globalData.token
  637. },
  638. data:{
  639. activity_id:this.data.aid,
  640. type:that.data.numtype,
  641. page:p,
  642. limit:10,
  643. schedule:this.data.lunidx*1+1,
  644. pk:this.data.oppoflag?1:0
  645. },
  646. success: function (res) {
  647. let recordlist=that.data.recordlist;
  648. if(res.data.code=='0'){
  649. recordlist=recordlist.concat(res.data.data.log);
  650. that.setData({
  651. recordlist:recordlist
  652. })
  653. }
  654. setTimeout(function(){
  655. wx.hideLoading()
  656. },1000)
  657. }
  658. })
  659. },
  660. setranktypetap(e){
  661. this.setData({
  662. ranktype:e.currentTarget.dataset.type
  663. })
  664. if(this.data.rtype==1){
  665. this.teamRankfun();
  666. }else{
  667. this.personRankfun();
  668. }
  669. },
  670. seteamtap(){
  671. this.setData({
  672. rtype:1,
  673. })
  674. this.teamRankfun();
  675. },
  676. setsortap(){
  677. if(this.data.sort=='desc'){
  678. this.setData({
  679. sort:'asc'
  680. })
  681. }else{
  682. this.setData({
  683. sort:'desc'
  684. })
  685. }
  686. if(this.data.rtype==1){
  687. this.teamRankfun();
  688. }else{
  689. this.personRankfun();
  690. }
  691. },
  692. teamRankfun(){
  693. const that=this;
  694. trpage=1;
  695. utils.$post({
  696. url: app.globalData.webUrl + "api/wechatActivity/teamRank",
  697. header: {
  698. 'Authorization':'bearer '+app.globalData.token
  699. },
  700. data:{
  701. activity_id:this.data.aid,
  702. type:that.data.ranktype,
  703. page:trpage,
  704. limit:10,
  705. schedule:this.data.lunidx*1+1,
  706. sort:this.data.sort
  707. },
  708. success: function (res) {
  709. if(res.data.code=='0'){
  710. that.setData({
  711. teamobj:res.data.data.rank,
  712. myteamobj:res.data.data.my,
  713. })
  714. }
  715. setTimeout(function(){
  716. wx.hideLoading()
  717. },1000)
  718. }
  719. })
  720. },
  721. setmembertap(){
  722. this.setData({
  723. rtype:2,
  724. })
  725. this.personRankfun();
  726. },
  727. personRankfun(){
  728. const that=this;
  729. mrpage=1;
  730. utils.$post({
  731. url: app.globalData.webUrl + "api/wechatActivity/personRank",
  732. header: {
  733. 'Authorization':'bearer '+app.globalData.token
  734. },
  735. data:{
  736. activity_id:this.data.aid,
  737. type:that.data.ranktype,
  738. page:mrpage,
  739. limit:10,
  740. schedule:this.data.lunidx*1+1,
  741. sort:this.data.sort
  742. },
  743. success: function (res) {
  744. if(res.data.code=='0'){
  745. that.setData({
  746. personranklist:res.data.data.rank,
  747. mydataobj:res.data.data.my,
  748. })
  749. }
  750. setTimeout(function(){
  751. wx.hideLoading()
  752. },1000)
  753. }
  754. })
  755. },
  756. /**
  757. * 生命周期函数--监听页面初次渲染完成
  758. */
  759. onReady: function () {
  760. },
  761. funtap(){
  762. this.setData({
  763. funshow:true,
  764. chartflag:false
  765. })
  766. },
  767. closefuntap(){
  768. this.setData({
  769. funshow:false,
  770. chartflag:true,
  771. nowimagearr:[],
  772. addfunimgarr:[],
  773. editflag:false,
  774. })
  775. this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
  776. this.init_echarts();
  777. },
  778. dothis(){},
  779. managetap(){
  780. wx.navigateTo({
  781. url: '/index/pages/teamanage/teamanage?aid='+this.data.aid,
  782. })
  783. },
  784. /**
  785. * 生命周期函数--监听页面显示
  786. */
  787. onShow: function () {
  788. },
  789. recordtap(){
  790. },
  791. /**
  792. * 生命周期函数--监听页面隐藏
  793. */
  794. onHide: function () {
  795. },
  796. /**
  797. * 生命周期函数--监听页面卸载
  798. */
  799. onUnload: function () {
  800. },
  801. init_echarts: function () {
  802. this.echartsComponnet.init((canvas, width, height) => {
  803. // 初始化图表
  804. Chart = echarts.init(canvas, null, {
  805. width: width,
  806. height: height
  807. });
  808. Chart.setOption(this.getOption());
  809. return Chart;
  810. });
  811. },
  812. getOption: function () {
  813. // 指定图表的配置项和数据
  814. const that=this;
  815. var option = {
  816. grid: {
  817. top:'7%',
  818. left: '4%',
  819. right: '4%',
  820. bottom: '0%',
  821. z: 11,
  822. containLabel: true
  823. },
  824. tooltip: {
  825. trigger: 'axis',
  826. position: function (pos, params, dom, rect, size) {
  827. console.log(rect);
  828. console.log(size);
  829. var t,l;
  830. if (pos[0] > (size.viewSize[0]/2)){
  831. t = pos[0]-100;
  832. }else{
  833. t = pos[0];
  834. }
  835. if (pos[1] > size.viewSize[1] / 2){
  836. l = pos[1] - 100;
  837. }else{
  838. l = pos[1];
  839. }
  840. return [t,l];
  841. }
  842. },
  843. dataZoom: [{
  844. type: 'inside',
  845. show: true, //flase直接隐藏图形
  846. //xAxisIndex: [0],
  847. left: '9%', //滚动条靠左侧的百分比
  848. bottom: -5,
  849. start: 0,//滚动条的起始位置
  850. end: 80 //滚动条的截止位置(按比例分割你的柱状图x轴长度)
  851. }],
  852. color: ["#FF0035", "#0089FF"],
  853. xAxis: {
  854. type: 'category',
  855. axisLabel: {
  856. show: true,
  857. color:'#444',
  858. fontFamily:'PingFangSC-Regular',
  859. fontSize: 12,//字体大小
  860. },
  861. axisLine:{
  862. color:'#ccc',
  863. lineStyle: {
  864. type: 'solid',
  865. color: '#ccc',
  866. },
  867. },
  868. splitLine:{
  869. lineStyle:{
  870. type:'solid'
  871. }
  872. },
  873. boundaryGap: true,
  874. data: this.data.lunarr,//time
  875. z: 7,
  876. },
  877. yAxis: {
  878. type: 'value',
  879. position: 'right',
  880. axisTick:{
  881. show: false,
  882. },
  883. axisLabel: {
  884. show: true,
  885. color: '#444',
  886. inside: true,
  887. padding:[0,0,10,0]
  888. },
  889. axisLine: {
  890. color: 'transparent',
  891. lineStyle: {
  892. type: 'solid',
  893. color: 'transparent',
  894. },
  895. },
  896. splitLine: {
  897. lineStyle: {
  898. type: 'dashed'
  899. }
  900. },
  901. yAxisLabel: {
  902. show: true,
  903. color: '#444',
  904. fontFamily: 'PingFangSC-Regular',
  905. show: true,
  906. fontSize: 12,//字体大小
  907. }
  908. },
  909. series: [
  910. {
  911. animation: true,
  912. barWidth: 10,
  913. data: that.data.type==1?that.data.footfun:that.data.footdespoit,
  914. itemStyle:{
  915. normal: {color: "rgba(255,0,53,1)"}
  916. },
  917. name: that.data.type==1?"加粉":'定金',
  918. type: "bar"
  919. },
  920. {
  921. animation: true,
  922. barWidth: 10,
  923. data: that.data.type==1?that.data.pkfootfun:that.data.pkfootdespoit,
  924. itemStyle:{
  925. normal: {color: "rgba(0,137,255,0.8)"}
  926. },
  927. name: that.data.type==1?"加粉":'定金',
  928. type: "bar"
  929. }
  930. ]
  931. }
  932. return option;
  933. },
  934. /**
  935. * 页面相关事件处理函数--监听用户下拉动作
  936. */
  937. onPullDownRefresh: function () {
  938. if(this.data.type==1){
  939. this.topindexdatafun();
  940. this.setrecord();
  941. wx.stopPullDownRefresh();
  942. }else if(this.data.type==2){
  943. this.setrecord();
  944. wx.stopPullDownRefresh();
  945. }else if(this.data.type==3){
  946. if(this.data.rtype==1){
  947. this.teamRankfun();
  948. }else{
  949. this.personRankfun();
  950. }
  951. wx.stopPullDownRefresh();
  952. }
  953. },
  954. /**
  955. * 页面上拉触底事件的处理函数
  956. */
  957. onReachBottom: function () {
  958. if(this.data.type==2){
  959. this.setrecordgun();
  960. }else if(this.data.type==3){
  961. if(this.data.rtype==1){
  962. trpage=trpage*1+1;
  963. utils.$post({
  964. url: app.globalData.webUrl + "api/wechatActivity/teamRank",
  965. header: {
  966. 'Authorization':'bearer '+app.globalData.token
  967. },
  968. data:{
  969. activity_id:this.data.aid,
  970. type:that.data.ranktype,
  971. page:trpage,
  972. limit:10,
  973. schedule:this.data.lunidx*1+1,
  974. sort:this.data.sort
  975. },
  976. success: function (res) {
  977. let teamobj=that.data.teamobj;
  978. if(res.data.code=='0'){
  979. teamobj=teamobj.concat(res.data.data.rank);
  980. that.setData({
  981. teamobj:teamobj,
  982. myteamobj:res.data.data.my,
  983. })
  984. }
  985. setTimeout(function(){
  986. wx.hideLoading()
  987. },1000)
  988. }
  989. })
  990. }else{
  991. mrpage=mrpage*1+1;
  992. utils.$post({
  993. url: app.globalData.webUrl + "api/wechatActivity/personRank",
  994. header: {
  995. 'Authorization':'bearer '+app.globalData.token
  996. },
  997. data:{
  998. activity_id:this.data.aid,
  999. type:that.data.ranktype,
  1000. page:mrpage,
  1001. limit:10,
  1002. schedule:this.data.lunidx*1+1,
  1003. sort:this.data.sort
  1004. },
  1005. success: function (res) {
  1006. let personranklist=that.data.personranklist;
  1007. if(res.data.code=='0'){
  1008. personranklist=personranklist.concat(res.data.data.rank);
  1009. that.setData({
  1010. personranklist:personranklist,
  1011. mydataobj:res.data.data.my,
  1012. })
  1013. }
  1014. setTimeout(function(){
  1015. wx.hideLoading()
  1016. },1000)
  1017. }
  1018. })
  1019. }
  1020. }
  1021. },
  1022. })