东风启辰小程序端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

242 líneas
5.7KB

  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:0,//开始人数
  14. stopNumber:0,//结束人数
  15. numList:[],
  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:0
  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.data.starNumber = res.data.total-1000<0?0:res.data.total-1000;
  133. this.setData({
  134. stopNumber: res.data.total ? res.data.total : '0'
  135. })
  136. } else {
  137. this.setData({
  138. stopNumber: '0'
  139. })
  140. }
  141. // if (this.data.stopNumber < 10000) {
  142. // this.setData({
  143. // numList: [4, 0, 0, 0]
  144. // })
  145. // } else {
  146. // this.setData({
  147. // numList: [0, 4, 0, 0, 0]
  148. // })
  149. // }
  150. this.getNumber = setInterval(this.vCodeDownTime, 20);
  151. }
  152. }, this);
  153. },
  154. vCodeDownTime(){
  155. var numb = this.data.starNumber;
  156. // numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80);
  157. numb=Math.floor(this.data.starNumber+this.data.stopNumber/80);
  158. if(numb>=this.data.stopNumber){
  159. numb=this.data.stopNumber;
  160. clearInterval(this.getNumber);
  161. }
  162. this.setData({
  163. starNumber: numb,
  164. numList:numb.toString().split("")
  165. })
  166. },
  167. getPhone (e) {
  168. console.log(e.detail)
  169. if (e.detail.errMsg=='getPhoneNumber:ok'){
  170. if(this.data.isbtn){
  171. this.setData({isbtn: false})
  172. }else{
  173. return;
  174. }
  175. app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{
  176. if (res.code == 200) {
  177. if (res.data.result == 0) {
  178. this.phonebolb(res.data.decodeData.phoneNumber);
  179. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  180. } else {
  181. this.setData({ isbtn: true })
  182. wx.showToast({ title: '获取失败', icon: "none" })
  183. }
  184. } else {
  185. this.setData({ isbtn: true })
  186. wx.showToast({ title: res.msg, icon: "none" })
  187. }
  188. },this)
  189. }
  190. },
  191. /**
  192. * 生命周期函数--监听页面显示
  193. */
  194. onShow: function () {
  195. if(app.globalData.userMobile==null){
  196. this.setData({phonebol: true})
  197. }else{
  198. this.setData({phonebol: false})
  199. }
  200. this.setData({isbtn: true})
  201. },
  202. /**
  203. * 生命周期函数--监听页面隐藏
  204. */
  205. onHide: function () {
  206. },
  207. /**
  208. * 生命周期函数--监听页面卸载
  209. */
  210. onUnload: function () {
  211. },
  212. /**
  213. * 页面相关事件处理函数--监听用户下拉动作
  214. */
  215. onPullDownRefresh: function () {
  216. },
  217. /**
  218. * 页面上拉触底事件的处理函数
  219. */
  220. onReachBottom: function () {
  221. },
  222. /**
  223. * 用户点击右上角分享
  224. */
  225. onShareAppMessage: function () {
  226. return app.sharePack();
  227. }
  228. })