东风启辰小程序端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

240 lines
5.5KB

  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. ruleShow:false,
  11. phonebol:false,//是否有手机号
  12. getNumber:null,//数字跳跃
  13. starNumber:4000,//开始人数
  14. stopNumber:0,//结束人数
  15. numList:[4,0,0,0],
  16. isbtn:true,//防重复点击
  17. },
  18. /**
  19. * 显示规则页
  20. */
  21. showRule:function(){
  22. // this.setData({
  23. // maskShow:true,
  24. // ruleShow:true
  25. // })
  26. if (app.globalData.entered) {
  27. this.everyDay();
  28. }else{
  29. wx.navigateTo({
  30. url: '/pages/fragmentRule/fragmentRule'
  31. })
  32. }
  33. },
  34. /**
  35. * 关闭规则页
  36. */
  37. hiddenRule:function(){
  38. this.setData({
  39. maskShow: false,
  40. ruleShow: 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.isbtn){
  59. this.setData({isbtn: false})
  60. }else{
  61. return;
  62. }
  63. this.phonebolb();
  64. },
  65. phonebolb:function(_phone){
  66. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfo", {}, res => {
  67. if (res.code == 200) {
  68. app.globalData.authenticationStatus = res.data;
  69. if (!app.globalData.certificationInfo) {
  70. app.globalData.certificationInfo = true;
  71. wx.setStorageSync("certificationInfo", true);
  72. }
  73. app.globalData.certificationState = res.data.certificationState;
  74. wx.navigateTo({
  75. url: '/pages/scout/scout'
  76. })
  77. } else if (res.code == -307){
  78. wx.navigateTo({
  79. url: '/pages/mobileVerification/mobileVerification'
  80. })
  81. } else if (res.code == -308) {
  82. wx.navigateTo({
  83. url: '/pages/scout/register/register'
  84. })
  85. }else{
  86. this.setData({isbtn: true})
  87. }
  88. }, this);
  89. },
  90. /**
  91. * 生命周期函数--监听页面加载
  92. */
  93. onLoad: function (options) {
  94. app.globalData.nowPage = 2;
  95. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/getCertificationNoCarList", {
  96. // adminState: 0, page:1,count:10
  97. // }, res => {
  98. // console.log(res)
  99. // }, this);
  100. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditRefuse", { id:4 }, res => {
  101. // console.log(res)
  102. // }, this,"POST");
  103. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditPass", { id:4 }, res => {
  104. // console.log(res)
  105. // }, this,"POST");
  106. },
  107. /**
  108. * 生命周期函数--监听页面初次渲染完成
  109. */
  110. onReady: function () {
  111. this.setData({
  112. starNumber:4000
  113. })
  114. if (app.globalData.openid) {
  115. this.loadFun();
  116. } else {
  117. app.globalData.openidSuccessFuc = this.loadFun;
  118. }
  119. },
  120. loadFun(){
  121. if (!app.globalData.addPageEnterState.star) {
  122. app.addPageEnter("61D8FFCBF9D58A1DFB3F660294CE006A");
  123. app.globalData.addPageEnterState.star = true;
  124. }
  125. this.gettime();
  126. },
  127. gettime(){
  128. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationCount", {}, res => {
  129. console.log(res)
  130. if (res.code == 200) {
  131. if (res.data){
  132. this.setData({
  133. stopNumber: res.data.total ? res.data.total : '0000'
  134. })
  135. } else {
  136. this.setData({
  137. stopNumber: '0000'
  138. })
  139. }
  140. if (this.data.stopNumber < 10000) {
  141. this.setData({
  142. numList: [4, 0, 0, 0]
  143. })
  144. } else {
  145. this.setData({
  146. numList: [0, 4, 0, 0, 0]
  147. })
  148. }
  149. this.getNumber = setInterval(this.vCodeDownTime, 20);
  150. }
  151. }, this);
  152. },
  153. vCodeDownTime(){
  154. var numb = this.data.starNumber;
  155. numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80);
  156. if(numb>=this.data.stopNumber){
  157. numb=this.data.stopNumber;
  158. clearInterval(this.getNumber);
  159. }
  160. this.setData({
  161. starNumber: numb,
  162. numList:numb.toString().split("")
  163. })
  164. },
  165. getPhone (e) {
  166. console.log(e.detail)
  167. if (e.detail.errMsg=='getPhoneNumber:ok'){
  168. if(this.data.isbtn){
  169. this.setData({isbtn: false})
  170. }else{
  171. return;
  172. }
  173. app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{
  174. if (res.code == 200) {
  175. if (res.data.result == 0) {
  176. this.phonebolb(res.data.decodeData.phoneNumber);
  177. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  178. } else {
  179. this.setData({ isbtn: true })
  180. wx.showToast({ title: '获取失败', icon: "none" })
  181. }
  182. } else {
  183. this.setData({ isbtn: true })
  184. wx.showToast({ title: res.msg, icon: "none" })
  185. }
  186. },this)
  187. }
  188. },
  189. /**
  190. * 生命周期函数--监听页面显示
  191. */
  192. onShow: function () {
  193. if(app.globalData.userMobile==null){
  194. this.setData({phonebol: true})
  195. }else{
  196. this.setData({phonebol: false})
  197. }
  198. this.setData({isbtn: true})
  199. },
  200. /**
  201. * 生命周期函数--监听页面隐藏
  202. */
  203. onHide: function () {
  204. },
  205. /**
  206. * 生命周期函数--监听页面卸载
  207. */
  208. onUnload: function () {
  209. },
  210. /**
  211. * 页面相关事件处理函数--监听用户下拉动作
  212. */
  213. onPullDownRefresh: function () {
  214. },
  215. /**
  216. * 页面上拉触底事件的处理函数
  217. */
  218. onReachBottom: function () {
  219. },
  220. /**
  221. * 用户点击右上角分享
  222. */
  223. onShareAppMessage: function () {
  224. return app.sharePack();
  225. }
  226. })