东风启辰小程序端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

296 lines
7.6KB

  1. // pages/star/star.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. maskShow: false,
  10. phonebol: false,//是否有手机号
  11. getNumber: null,//数字跳跃
  12. starNumber: 0,//开始人数
  13. stopNumber: 0,//结束人数
  14. numList: [],
  15. isbtn: true,//防重复点击
  16. selectGroup:[false,false,false],
  17. addressShow:false,
  18. isAddress:false,//是否有地址
  19. starInfo:null,//星探状态
  20. },
  21. /**
  22. * 显示规则页
  23. */
  24. showRule: function () {
  25. if (app.globalData.entered) {
  26. this.everyDay();
  27. } else {
  28. wx.navigateTo({
  29. url: '/pages/fragmentRule/fragmentRule'
  30. })
  31. }
  32. },
  33. showMask:function(){
  34. this.setData({
  35. maskShow: true
  36. })
  37. },
  38. hiddenMask: function () {
  39. this.setData({
  40. maskShow: false
  41. })
  42. },
  43. /**
  44. * 每日任务
  45. */
  46. everyDay: function () {
  47. if (this.data.isbtn) {
  48. this.setData({ isbtn: false })
  49. } else {
  50. return;
  51. }
  52. wx.navigateTo({ url: '../everyday/everyday' })
  53. },
  54. /**
  55. * 星探任务
  56. */
  57. scout: function () {
  58. if(this.data.starInfo==200 || app.globalData.isStar){
  59. wx.navigateTo({
  60. url: '/pages/scout/scout'
  61. })
  62. }else if(this.data.starInfo==-307){
  63. wx.navigateTo({
  64. url: '/pages/mobileVerification/mobileVerification'
  65. })
  66. }else if(this.data.starInfo==-308){
  67. wx.navigateTo({
  68. url: '/pages/scout/register/register'
  69. })
  70. }
  71. },
  72. phonebolb: function (_phone) {
  73. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfoV2", {}, res => {
  74. this.data.starInfo = res.code;
  75. if (res.code == 200) {
  76. app.globalData.isStar = res.data;
  77. wx.setStorageSync('isStar', res.data);
  78. app.globalData.authenticationStatus = res.data;
  79. if (!app.globalData.certificationInfo) {
  80. app.globalData.certificationInfo = true;
  81. wx.setStorageSync("certificationInfo", true);
  82. }
  83. app.globalData.certificationState = res.data.certificationState;
  84. // wx.navigateTo({
  85. // url: '/pages/scout/scout'
  86. // })
  87. } else if (res.code == -307) {
  88. // wx.navigateTo({
  89. // url: '/pages/mobileVerification/mobileVerification'
  90. // })
  91. } else if (res.code == -308) {
  92. // wx.navigateTo({
  93. // url: '/pages/scout/register/register'
  94. // })
  95. } else {
  96. this.setData({ isbtn: true })
  97. }
  98. }, this);
  99. },
  100. /**
  101. * 生命周期函数--监听页面加载
  102. */
  103. onLoad: function (options) {
  104. app.globalData.nowPage = 2;
  105. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/getCertificationNoCarList", {
  106. // adminState: 0, page:1,count:10
  107. // }, res => {
  108. // console.log(res)
  109. // }, this);
  110. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditRefuse", { id:4 }, res => {
  111. // console.log(res)
  112. // }, this,"POST");
  113. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditPass", { id:4 }, res => {
  114. // console.log(res)
  115. // }, this,"POST");
  116. },
  117. addressControl: function () {//跳转到地址管理
  118. this.setData({
  119. addressShow: !this.data.addressShow
  120. })
  121. if (this.data.addressShow) {
  122. app.globalData.skipType = 'mycenter';
  123. }
  124. },
  125. getAddress: function () {//获取地址
  126. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  127. if (res.code == 200) {
  128. if (res.data) {
  129. this.setData({
  130. isAddress:true
  131. })
  132. }
  133. }
  134. }, this)
  135. },
  136. /**
  137. * 生命周期函数--监听页面初次渲染完成
  138. */
  139. onReady: function () {
  140. this.setData({
  141. starNumber: 0
  142. })
  143. if (app.globalData.openid) {
  144. this.loadFun();
  145. } else {
  146. app.globalData.openidSuccessFuc = this.loadFun;
  147. }
  148. },
  149. loadFun() {
  150. if (!app.globalData.addPageEnterState.star) {
  151. app.addPageEnter("61D8FFCBF9D58A1DFB3F660294CE006A");
  152. app.globalData.addPageEnterState.star = true;
  153. }
  154. if(!app.globalData.isStar){
  155. this.phonebolb();
  156. }else{
  157. this.getAddress();
  158. this.getFriendStoreAward();
  159. app.globalData.authenticationStatus = app.globalData.isStar;
  160. if (!app.globalData.certificationInfo) {
  161. app.globalData.certificationInfo = true;
  162. wx.setStorageSync("certificationInfo", true);
  163. }
  164. app.globalData.certificationState = app.globalData.isStar.certificationState;
  165. }
  166. this.gettime();
  167. },
  168. getFriendStoreAward(){//是否需要显示弹窗
  169. app.wxRequest(app.globalData.urlRoot + "userInfo/getFriendStoreAward", {}, res => {
  170. if (res.code == 200 && res.data && res.data.showState==1) {
  171. this.showMask();
  172. }
  173. }, this);
  174. },
  175. gettime() {
  176. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationCount", {}, res => {
  177. if (res.code == 200) {
  178. if (res.data) {
  179. this.data.starNumber = res.data.total - 1000 < 0 ? 0 : res.data.total - 1000;
  180. this.setData({
  181. stopNumber: res.data.total ? res.data.total : '0'
  182. })
  183. } else {
  184. this.setData({
  185. stopNumber: '0'
  186. })
  187. }
  188. // if (this.data.stopNumber < 10000) {
  189. // this.setData({
  190. // numList: [4, 0, 0, 0]
  191. // })
  192. // } else {
  193. // this.setData({
  194. // numList: [0, 4, 0, 0, 0]
  195. // })
  196. // }
  197. this.getNumber = setInterval(this.vCodeDownTime, 20);
  198. }
  199. }, this);
  200. },
  201. vCodeDownTime() {
  202. var numb = this.data.starNumber;
  203. // numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80);
  204. numb = Math.floor(this.data.starNumber + this.data.stopNumber / 80);
  205. if (numb >= this.data.stopNumber) {
  206. numb = this.data.stopNumber;
  207. clearInterval(this.getNumber);
  208. }
  209. this.setData({
  210. starNumber: numb,
  211. numList: numb.toString().split("")
  212. })
  213. },
  214. getPhone(e) {
  215. console.log(e.detail)
  216. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  217. if (this.data.isbtn) {
  218. this.setData({ isbtn: false })
  219. } else {
  220. return;
  221. }
  222. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  223. if (res.code == 200) {
  224. if (res.data.result == 0) {
  225. // this.phonebolb(res.data.decodeData.phoneNumber);
  226. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  227. } else {
  228. this.setData({ isbtn: true })
  229. wx.showToast({ title: '获取失败', icon: "none" })
  230. }
  231. } else {
  232. this.setData({ isbtn: true })
  233. wx.showToast({ title: res.msg, icon: "none" })
  234. }
  235. }, this)
  236. }
  237. },
  238. /**
  239. * 生命周期函数--监听页面显示
  240. */
  241. onShow: function () {
  242. if (app.globalData.userMobile == null) {
  243. this.setData({ phonebol: true })
  244. } else {
  245. this.setData({ phonebol: false })
  246. }
  247. this.setData({ isbtn: true })
  248. },
  249. /**
  250. * 生命周期函数--监听页面隐藏
  251. */
  252. onHide: function () {
  253. },
  254. /**
  255. * 生命周期函数--监听页面卸载
  256. */
  257. onUnload: function () {
  258. },
  259. /**
  260. * 页面相关事件处理函数--监听用户下拉动作
  261. */
  262. onPullDownRefresh: function () {
  263. },
  264. /**
  265. * 页面上拉触底事件的处理函数
  266. */
  267. onReachBottom: function () {
  268. },
  269. /**
  270. * 用户点击右上角分享
  271. */
  272. onShareAppMessage: function () {
  273. return app.sharePack();
  274. },
  275. cutSelect:function(e){
  276. var index = e.currentTarget.dataset.type;
  277. this.data.selectGroup[index] = !this.data.selectGroup[index];
  278. this.setData({
  279. selectGroup:this.data.selectGroup
  280. })
  281. }
  282. })