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

343 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. app.globalData.userInfoData = {avatarUrl:"",nickName:""};
  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. console.log(e.detail)
  233. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  234. if (this.data.isbtn) {
  235. this.setData({ isbtn: false })
  236. } else {
  237. return;
  238. }
  239. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  240. if (res.code == 200) {
  241. if (res.data.result == 0) {
  242. // this.phonebolb(res.data.decodeData.phoneNumber);
  243. app.globalData.userMobile = res.data.decodeData.phoneNumber;
  244. } else {
  245. this.setData({ isbtn: true })
  246. wx.showToast({ title: '获取失败', icon: "none" })
  247. }
  248. } else {
  249. this.setData({ isbtn: true })
  250. wx.showToast({ title: res.msg, icon: "none" })
  251. }
  252. }, this)
  253. }
  254. },
  255. /**
  256. * 生命周期函数--监听页面显示
  257. */
  258. onShow: function () {
  259. if (app.globalData.userMobile == null) {
  260. this.setData({ phonebol: true })
  261. } else {
  262. this.setData({ phonebol: false })
  263. }
  264. this.setData({ isbtn: true })
  265. },
  266. /**
  267. * 生命周期函数--监听页面隐藏
  268. */
  269. onHide: function () {
  270. },
  271. /**
  272. * 生命周期函数--监听页面卸载
  273. */
  274. onUnload: function () {
  275. },
  276. /**
  277. * 页面相关事件处理函数--监听用户下拉动作
  278. */
  279. onPullDownRefresh: function () {
  280. },
  281. /**
  282. * 页面上拉触底事件的处理函数
  283. */
  284. onReachBottom: function () {
  285. },
  286. /**
  287. * 用户点击右上角分享
  288. */
  289. onShareAppMessage: function () {
  290. return app.sharePack();
  291. },
  292. cutSelect:function(e){
  293. var index = e.currentTarget.dataset.type;
  294. this.data.selectGroup[index] = !this.data.selectGroup[index];
  295. this.setData({
  296. selectGroup:this.data.selectGroup
  297. })
  298. },
  299. skipPoster(){
  300. var enterScout = wx.getStorageSync('enterScout');
  301. if(app.globalData.isStar && app.globalData.isStar.agentDetail && enterScout){
  302. if(app.globalData.userInfoData && app.globalData.userInfoData.avatarUrl){
  303. wx.navigateTo({
  304. url:'../poster/poster'
  305. })
  306. }
  307. }else{
  308. wx.navigateTo({
  309. url:'../scout/scout'
  310. })
  311. }
  312. },
  313. getUserWxMsg:function(e){//通过微信获取用户信息
  314. if (e.detail.errMsg == "getUserInfo:ok") {
  315. if(app.globalData.userInfoData){
  316. app.globalData.userInfoData.avatarUrl = e.detail.userInfo.avatarUrl;
  317. app.globalData.userInfoData.nickName = e.detail.userInfo.nickName;
  318. }
  319. this.setData({
  320. getUserInfoBtn:false
  321. })
  322. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  323. wx.navigateTo({
  324. url:'../poster/poster'
  325. })
  326. }
  327. }
  328. })