东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 line
5.2KB

  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. if (!app.globalData.certificationInfo) {
  69. app.globalData.certificationInfo = true;
  70. wx.setStorageSync("certificationInfo", true);
  71. }
  72. app.globalData.certificationState = res.data.certificationState;
  73. wx.navigateTo({
  74. url: '/pages/scout/scout'
  75. })
  76. } else if (res.code == -307){
  77. wx.navigateTo({
  78. url: '/pages/mobileVerification/mobileVerification'
  79. })
  80. } else if (res.code == -308) {
  81. wx.navigateTo({
  82. url: '/pages/scout/register/register'
  83. })
  84. }else{
  85. this.setData({isbtn: true})
  86. }
  87. }, this);
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad: function (options) {
  93. app.globalData.nowPage = 2;
  94. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/getCertificationNoCarList", {
  95. // adminState: 0, page:1,count:10
  96. // }, res => {
  97. // console.log(res)
  98. // }, this);
  99. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditRefuse", { id:4 }, res => {
  100. // console.log(res)
  101. // }, this,"POST");
  102. // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditPass", { id:4 }, res => {
  103. // console.log(res)
  104. // }, this,"POST");
  105. },
  106. /**
  107. * 生命周期函数--监听页面初次渲染完成
  108. */
  109. onReady: function () {
  110. this.setData({
  111. starNumber:4000
  112. })
  113. if (app.globalData.openid) {
  114. this.gettime();
  115. } else {
  116. app.globalData.openidSuccessFuc = this.gettime;
  117. }
  118. },
  119. gettime(){
  120. app.wxRequest(app.globalData.urlRoot + "certificationInfo/getCertificationNum", {}, res => {
  121. console.log(res)
  122. if (res.code == 200) {
  123. this.setData({
  124. stopNumber: res.data ? res.data.certificationNum : '0000'
  125. })
  126. if(this.data.stopNumber<10000){
  127. this.setData({
  128. numList: [4,0,0,0]
  129. })
  130. }else{
  131. this.setData({
  132. numList: [0,4,0,0,0]
  133. })
  134. }
  135. this.getNumber=setInterval(this.vCodeDownTime,20);
  136. }
  137. }, this);
  138. },
  139. vCodeDownTime(){
  140. var numb = this.data.starNumber;
  141. numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80);
  142. if(numb>=this.data.stopNumber){
  143. numb=this.data.stopNumber;
  144. clearInterval(this.getNumber);
  145. }
  146. this.setData({
  147. starNumber: numb,
  148. numList:numb.toString().split("")
  149. })
  150. },
  151. getPhone (e) {
  152. console.log(e.detail)
  153. if (e.detail.errMsg=='getPhoneNumber:ok'){
  154. if(this.data.isbtn){
  155. this.setData({isbtn: false})
  156. }else{
  157. return;
  158. }
  159. app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{
  160. if (res.code == 200) {
  161. if (res.data.result == 0) {
  162. this.phonebolb(res.data.decodeData.phoneNumber);
  163. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  164. } else {
  165. this.setData({ isbtn: true })
  166. wx.showToast({ title: '获取失败', icon: "none" })
  167. }
  168. } else {
  169. this.setData({ isbtn: true })
  170. wx.showToast({ title: res.msg, icon: "none" })
  171. }
  172. },this)
  173. }
  174. },
  175. /**
  176. * 生命周期函数--监听页面显示
  177. */
  178. onShow: function () {
  179. if(app.globalData.userMobile==null){
  180. this.setData({phonebol: true})
  181. }else{
  182. this.setData({phonebol: false})
  183. }
  184. this.setData({isbtn: true})
  185. },
  186. /**
  187. * 生命周期函数--监听页面隐藏
  188. */
  189. onHide: function () {
  190. },
  191. /**
  192. * 生命周期函数--监听页面卸载
  193. */
  194. onUnload: function () {
  195. },
  196. /**
  197. * 页面相关事件处理函数--监听用户下拉动作
  198. */
  199. onPullDownRefresh: function () {
  200. },
  201. /**
  202. * 页面上拉触底事件的处理函数
  203. */
  204. onReachBottom: function () {
  205. },
  206. /**
  207. * 用户点击右上角分享
  208. */
  209. onShareAppMessage: function () {
  210. return app.sharePack();
  211. }
  212. })