passport.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. active_tab:0,
  6. groupData:{},
  7. current:0,
  8. hidden:true,
  9. medals:[
  10. {oldSrc:'https://m.bbztx.com/img/medal/o1.png',newSrc:'https://m.bbztx.com/img/medal/n1.png',text:'宝贝勋章',days:3},
  11. {oldSrc:'https://m.bbztx.com/img/medal/o2.png',newSrc:'https://m.bbztx.com/img/medal/n2.png',text:'勇士勋章',days:6},
  12. {oldSrc:'https://m.bbztx.com/img/medal/o3.png',newSrc:'https://m.bbztx.com/img/medal/n3.png',text:'英雄勋章',days:9},
  13. {oldSrc:'https://m.bbztx.com/img/medal/o4.png',newSrc:'https://m.bbztx.com/img/medal/n4.png',text:'骑士勋章',days:15},
  14. {oldSrc:'https://m.bbztx.com/img/medal/o5.png',newSrc:'https://m.bbztx.com/img/medal/n5.png',text:'王者勋章',days:21},
  15. {oldSrc:'https://m.bbztx.com/img/medal/o6.png',newSrc:'https://m.bbztx.com/img/medal/n6.png',text:'彩虹勋章·赤',days:27},
  16. {oldSrc:'https://m.bbztx.com/img/medal/o7.png',newSrc:'https://m.bbztx.com/img/medal/n7.png',text:'彩虹勋章·橙',days:36},
  17. {oldSrc:'https://m.bbztx.com/img/medal/o8.png',newSrc:'https://m.bbztx.com/img/medal/n8.png',text:'彩虹勋章·黄',days:45},
  18. {oldSrc:'https://m.bbztx.com/img/medal/o9.png',newSrc:'https://m.bbztx.com/img/medal/n9.png',text:'彩虹勋章·绿',days:54},
  19. {oldSrc:'https://m.bbztx.com/img/medal/o10.png',newSrc:'https://m.bbztx.com/img/medal/n10.png',text:'彩虹勋章·青',days:66},
  20. {oldSrc:'https://m.bbztx.com/img/medal/o11.png',newSrc:'https://m.bbztx.com/img/medal/n11.png',text:'彩虹勋章·蓝',days:78},
  21. {oldSrc:'https://m.bbztx.com/img/medal/o12.png',newSrc:'https://m.bbztx.com/img/medal/n12.png',text:'彩虹勋章·紫',days:90},
  22. {oldSrc:'https://m.bbztx.com/img/medal/o13.png',newSrc:'https://m.bbztx.com/img/medal/n13.png',text:'白虎勋章',days:105},
  23. {oldSrc:'https://m.bbztx.com/img/medal/o14.png',newSrc:'https://m.bbztx.com/img/medal/n14.png',text:'朱雀勋章',days:120},
  24. {oldSrc:'https://m.bbztx.com/img/medal/o15.png',newSrc:'https://m.bbztx.com/img/medal/n15.png',text:'青龙勋章',days:135},
  25. {oldSrc:'https://m.bbztx.com/img/medal/o16.png',newSrc:'https://m.bbztx.com/img/medal/n16.png',text:'玄武勋章',days:153},
  26. {oldSrc:'https://m.bbztx.com/img/medal/o17.png',newSrc:'https://m.bbztx.com/img/medal/n17.png',text:'终极勋章',days:171},
  27. ],
  28. share:false,//是否是分享
  29. currentPages:0,
  30. user:[],
  31. cardNo:'',
  32. cardType:'',
  33. avatar:'',
  34. name:'',
  35. },
  36. onShow:function(){
  37. let that = this;
  38. if(this.data.hidden){
  39. if(getCurrentPages().length == 1){
  40. // var getLocation = util.promise();
  41. // getLocation.then(function(value) {
  42. that.getUser();
  43. that.setData({currentPages:getCurrentPages().length})
  44. // }, function(error) {
  45. // });
  46. }else{
  47. that.getUser();
  48. }
  49. }
  50. },
  51. getUser:function(){
  52. let that = this;
  53. util.ajax({
  54. func:"user/childs",
  55. },function(res){
  56. if(res.code == 0){
  57. let user = [],current = 0;
  58. user = res.data;
  59. if (user.length > 0) {
  60. that.setData({ user});
  61. that.userData(current);
  62. }else{
  63. that.setData({ hidden :false });
  64. }
  65. }
  66. })
  67. },
  68. userData:function(current){
  69. let that = this,user = this.data.user;
  70. util.ajax({
  71. func:"user/medal_child",
  72. data: { "cardNo": user[current].cardNo, "cardType": user[current].cardType},
  73. load:false
  74. },function(res){
  75. let datas = res.data || {},medals = that.data.medals;
  76. for(let i in medals){
  77. medals[i].show = false
  78. }
  79. if(datas && datas.medal && datas.medal.length>0){
  80. for(let i in datas.medal){
  81. let l = datas.medal[i].match(/img\/x(\S*).png/)[1];
  82. medals[l-1].show = true;
  83. }
  84. }
  85. if(datas && datas.goldSeal && datas.goldSeal.length > 0){
  86. for(let i in datas.goldSeal){
  87. datas.goldSeal[i] = util.config.imgUrl + datas.goldSeal[i]
  88. }
  89. }
  90. that.setData({medals,groupData:datas,hidden:false});
  91. })
  92. },
  93. choose(e) {
  94. this.userData(e.detail)
  95. this.setData({current:e.detail})
  96. },
  97. imgdetails:function(e){
  98. let index = e.currentTarget.dataset.index,seals = this.data.groupData.seals;
  99. wx.previewImage({
  100. current: seals[index], // 当前显示图片的http链接
  101. urls: seals // 需要预览的图片http链接列表
  102. })
  103. },
  104. imgGold:function(e){
  105. let index = e.currentTarget.dataset.index,seals = this.data.groupData.goldSeal;
  106. wx.previewImage({
  107. current: seals[index], // 当前显示图片的http链接
  108. urls: seals // 需要预览的图片http链接列表
  109. })
  110. },
  111. bingImg:function(e){
  112. let index = e.currentTarget.dataset.index,medals = this.data.medals,urls=[];
  113. for(let i in medals){
  114. urls.push(medals[i].src)
  115. }
  116. wx.previewImage({
  117. current: urls[index], // 当前显示图片的http链接
  118. urls: urls // 需要预览的图片http链接列表
  119. })
  120. },
  121. // tab栏切换
  122. changeTab(e){
  123. console.log(e)
  124. let val = e.currentTarget.dataset.value;
  125. this.setData({active_tab:val})
  126. },
  127. // 点击图片跳转
  128. jumpToBuy(){
  129. wx.navigateTo({
  130. url: '/pages/product/goods/detail?aid=7cb01701-98d9-4f17-a24e-53568fa095fd',
  131. })
  132. },
  133. onShareAppMessage: function () {
  134. return {
  135. title: '儿童参加活动的印章勋章记录',
  136. path: '/pages/account/passport/passport'
  137. }
  138. },
  139. })