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

347 line
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. this.hiddenMask();
  127. // if (this.data.addressShow) {
  128. // app.globalData.skipType = 'mycenter';
  129. // }
  130. },
  131. getAddress: function () {//获取地址
  132. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  133. if (res.code == 200) {
  134. if (res.data) {
  135. this.setData({
  136. isAddress:true
  137. })
  138. }
  139. }
  140. }, this)
  141. },
  142. /**
  143. * 生命周期函数--监听页面初次渲染完成
  144. */
  145. onReady: function () {
  146. this.setData({
  147. starNumber: 0
  148. })
  149. if (app.globalData.openid) {
  150. this.loadFun();
  151. } else {
  152. app.globalData.openidSuccessFuc = this.loadFun;
  153. }
  154. },
  155. loadFun() {
  156. if (!app.globalData.addPageEnterState.star) {
  157. app.addPageEnter("61D8FFCBF9D58A1DFB3F660294CE006A");
  158. app.globalData.addPageEnterState.star = true;
  159. }
  160. if(!app.globalData.isStar){
  161. this.phonebolb();
  162. }else{
  163. this.setData({
  164. btnType:2
  165. })
  166. this.getAddress();
  167. this.getFriendStoreAward();
  168. app.globalData.authenticationStatus = app.globalData.isStar;
  169. if (!app.globalData.certificationInfo) {
  170. app.globalData.certificationInfo = true;
  171. wx.setStorageSync("certificationInfo", true);
  172. }
  173. app.globalData.certificationState = app.globalData.isStar.certificationState;
  174. var enterScout = wx.getStorageSync('enterScout');
  175. if(app.globalData.isStar.agentDetail && enterScout){
  176. if(!app.globalData.userInfoData || !app.globalData.userInfoData.avatarUrl){
  177. this.setData({
  178. getUserInfoBtn:true
  179. })
  180. }
  181. }
  182. }
  183. this.gettime();
  184. },
  185. getFriendStoreAward(){//是否需要显示弹窗
  186. app.wxRequest(app.globalData.urlRoot + "userInfo/getFriendStoreAward", {}, res => {
  187. if (res.code == 200 && res.data && res.data.showState==1) {
  188. this.showMask();
  189. }
  190. }, this);
  191. },
  192. gettime() {
  193. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationCount", {}, res => {
  194. if (res.code == 200) {
  195. if (res.data) {
  196. this.data.starNumber = res.data.total - 1000 < 0 ? 0 : res.data.total - 1000;
  197. this.setData({
  198. stopNumber: res.data.total ? res.data.total : '0'
  199. })
  200. } else {
  201. this.setData({
  202. stopNumber: '0'
  203. })
  204. }
  205. // if (this.data.stopNumber < 10000) {
  206. // this.setData({
  207. // numList: [4, 0, 0, 0]
  208. // })
  209. // } else {
  210. // this.setData({
  211. // numList: [0, 4, 0, 0, 0]
  212. // })
  213. // }
  214. this.getNumber = setInterval(this.vCodeDownTime, 20);
  215. }
  216. }, this);
  217. },
  218. vCodeDownTime() {
  219. var numb = this.data.starNumber;
  220. // numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80);
  221. numb = Math.floor(this.data.starNumber + this.data.stopNumber / 80);
  222. if (numb >= this.data.stopNumber) {
  223. numb = this.data.stopNumber;
  224. clearInterval(this.getNumber);
  225. }
  226. this.setData({
  227. starNumber: numb,
  228. numList: numb.toString().split("")
  229. })
  230. },
  231. getPhone(e) {
  232. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  233. if (this.data.isbtn) {
  234. this.setData({ isbtn: false })
  235. } else {
  236. return;
  237. }
  238. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  239. if (res.code == 200) {
  240. if (res.data.result == 0) {
  241. // this.phonebolb(res.data.decodeData.phoneNumber);
  242. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  243. } else {
  244. this.setData({ isbtn: true })
  245. wx.showToast({ title: '获取失败', icon: "none" })
  246. }
  247. } else {
  248. this.setData({ isbtn: true })
  249. wx.showToast({ title: res.msg, icon: "none" })
  250. }
  251. }, this)
  252. }
  253. },
  254. /**
  255. * 生命周期函数--监听页面显示
  256. */
  257. onShow: function () {
  258. if (app.globalData.userMobile == null) {
  259. this.setData({ phonebol: true })
  260. } else {
  261. this.setData({ phonebol: false })
  262. }
  263. this.setData({ isbtn: true })
  264. if(app.globalData.isStar){
  265. this.setData({
  266. btnType:2
  267. })
  268. }
  269. },
  270. /**
  271. * 生命周期函数--监听页面隐藏
  272. */
  273. onHide: function () {
  274. },
  275. /**
  276. * 生命周期函数--监听页面卸载
  277. */
  278. onUnload: function () {
  279. },
  280. /**
  281. * 页面相关事件处理函数--监听用户下拉动作
  282. */
  283. onPullDownRefresh: function () {
  284. },
  285. /**
  286. * 页面上拉触底事件的处理函数
  287. */
  288. onReachBottom: function () {
  289. },
  290. /**
  291. * 用户点击右上角分享
  292. */
  293. onShareAppMessage: function () {
  294. return app.sharePack();
  295. },
  296. cutSelect:function(e){
  297. var index = e.currentTarget.dataset.type;
  298. this.data.selectGroup[index] = !this.data.selectGroup[index];
  299. this.setData({
  300. selectGroup:this.data.selectGroup
  301. })
  302. },
  303. skipPoster(){
  304. var enterScout = wx.getStorageSync('enterScout');
  305. if(app.globalData.isStar && app.globalData.isStar.agentDetail && enterScout){
  306. if(app.globalData.userInfoData && app.globalData.userInfoData.avatarUrl){
  307. wx.navigateTo({
  308. url:'../poster/poster'
  309. })
  310. }
  311. }else{
  312. wx.navigateTo({
  313. url:'../scout/scout'
  314. })
  315. }
  316. },
  317. getUserWxMsg:function(e){//通过微信获取用户信息
  318. if (e.detail.errMsg == "getUserInfo:ok") {
  319. if(app.globalData.userInfoData){
  320. app.globalData.userInfoData.avatarUrl = e.detail.userInfo.avatarUrl;
  321. app.globalData.userInfoData.nickName = e.detail.userInfo.nickName;
  322. }
  323. this.setData({
  324. getUserInfoBtn:false
  325. })
  326. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  327. wx.navigateTo({
  328. url:'../poster/poster'
  329. })
  330. }
  331. }
  332. })