东风启辰小程序端
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.

346 lines
9.0KB

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