东风启辰小程序端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1135 行
33KB

  1. // pages/myCenter/myCenter.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. isAddress:false,
  10. placing:false,
  11. buyState:false,
  12. buyStateTime:"",
  13. isAgreement: true,//是否同意协议
  14. phoneInputShow: false,//是否显示电话输入框
  15. siteSelect: false,//是否显示位置选择框
  16. isLogin:false,//登录状态
  17. selectNow:0,//现在的选项
  18. taskNow:2,//现在的任务类型
  19. recordNow: 2,//现在的记录类型
  20. taskList: [],//任务列表
  21. shareFriendList:[],//星探小分队列表
  22. couponList:[],//卡券列表
  23. recordList:[],//获奖记录列表
  24. provinceArr: [],//省
  25. provinceValue: 0,//选中的省下标
  26. storeArr: [],//店铺
  27. storeValue: 0,//选中的店铺下标
  28. verificationCode: '获取验证码',//验证码文案
  29. sendCode: true,
  30. appointment: true,
  31. getFriendListState:false,
  32. couponListState:false,
  33. couponListCode:"",
  34. tipWindow2:false,
  35. subscribeData: {
  36. realname: "",//姓名
  37. mobile: "",//手机号
  38. captcha: "",//验证码
  39. province: "",//省份
  40. agent_code: "",//经销商编码
  41. agentDetail: "",//经销商详细信息
  42. parentOpenid: app.globalData.parentOpenid,//好友openid
  43. },
  44. userData:{
  45. avatarUrl: null,
  46. nickName: null,
  47. userLevel: 1
  48. },
  49. descFrameShow:false,//是否显示奖品详情
  50. ruleShow: false,//是否显示星探等级规则
  51. // isRegister: false,//查询是否已注册
  52. parames:{
  53. page:1,
  54. count:20
  55. },
  56. parames2:{
  57. page:1,
  58. count:20
  59. },
  60. parames3:{
  61. page:1,
  62. count:20
  63. },
  64. noData:false,
  65. noData2:false,
  66. noData3:false,
  67. optionsData:null,
  68. lookDescId: null,
  69. agreement: false,//是否显示协议
  70. addressShow:false,
  71. mycenterTipWindow:0,
  72. barNums:0,
  73. getState:true,
  74. scoutRule:false,
  75. vipDetailShow:false,
  76. machineShow:false,
  77. upgradeShow:false,
  78. starMoveShow:false,
  79. cash1Show:false,
  80. cash2Show:false,
  81. lookPrizeDetail:false,
  82. lookIndex:null,
  83. buyStateCouponCode:"",
  84. starInfo:null,//星探状态
  85. testData:[
  86. {
  87. awardDetailPicContentHeight:0,
  88. awardName: "头等舱机票", //奖品名称
  89. awardPicurl:"https://xingb.venucia.com/award/10_1.png",//奖品小图
  90. couponCode: "我是卡号",//卡号
  91. couponSecret:"",//卡密
  92. dead_date:"",//有效期
  93. awardState: 1,
  94. cdate: "2020-03-23",
  95. awardId:1
  96. },
  97. {
  98. awardDetailPicContentHeight: 0,
  99. awardName: "小米扫地机器人", //奖品名称
  100. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  101. couponCode: "我是卡号",//卡号
  102. couponSecret:"我是卡密",//卡密
  103. dead_date:"我是有效期",//有效期
  104. awardState: 1,
  105. cdate: "2020-03-23",
  106. awardId: 2
  107. },
  108. {
  109. awardDetailPicContentHeight: 0,
  110. awardName: "索尼无线蓝牙耳机", //奖品名称
  111. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  112. couponCode: "我是卡号",//卡号
  113. couponSecret:"我是卡密",//卡密
  114. dead_date:"我是有效期",//有效期
  115. awardState: 1,
  116. cdate: "2020-03-23",
  117. awardId: 3
  118. },
  119. {
  120. awardDetailPicContentHeight: 0,
  121. awardName: "美的烤箱", //奖品名称
  122. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  123. couponCode: "我是卡号",//卡号
  124. couponSecret:"我是卡密",//卡密
  125. dead_date:"我是有效期",//有效期
  126. awardState: 1,
  127. cdate: "2020-03-23",
  128. awardId: 4
  129. },
  130. {
  131. awardDetailPicContentHeight: 0,
  132. awardName: "200元油卡", //奖品名称
  133. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  134. couponCode: "我是卡号",//卡号
  135. couponSecret:"我是卡密",//卡密
  136. dead_date:"我是有效期",//有效期
  137. awardState: 1,
  138. cdate: "2020-03-23",
  139. awardId: 5
  140. },
  141. {
  142. awardDetailPicContentHeight: 0,
  143. awardName: "100元京东E卡", //奖品名称
  144. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  145. couponCode: "我是卡号",//卡号
  146. couponSecret:"我是卡密",//卡密
  147. dead_date:"我是有效期",//有效期
  148. awardState: 1,
  149. cdate: "2020-03-23",
  150. awardId: 6,
  151. productId:2501
  152. },
  153. {
  154. awardDetailPicContentHeight: 0,
  155. awardName: "50元京东E卡", //奖品名称
  156. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  157. couponCode: "我是卡号",//卡号
  158. couponSecret:"",//卡密
  159. dead_date:"",//有效期
  160. awardState: 1,
  161. cdate: "2020-03-23",
  162. awardId: 7
  163. },
  164. {
  165. awardDetailPicContentHeight: 0,
  166. awardName: "网易云音乐vip月卡", //奖品名称
  167. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  168. couponCode: "我是卡号",//卡号
  169. couponSecret:"我是卡密",//卡密
  170. dead_date:"我是有效期",//有效期
  171. awardState: 1,
  172. cdate: "2020-03-23",
  173. awardId: 8
  174. },
  175. {
  176. awardDetailPicContentHeight: 0,
  177. awardName: "爱奇艺vip月卡", //奖品名称
  178. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  179. couponCode: "我是卡号",//卡号
  180. couponSecret:"我是卡密",//卡密
  181. dead_date:"我是有效期",//有效期
  182. awardState: 1,
  183. cdate: "2020-03-23",
  184. awardId: 9
  185. },
  186. {
  187. awardDetailPicContentHeight: 0,
  188. awardName: "腾讯会员vip月卡", //奖品名称
  189. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  190. couponCode: "我是卡号",//卡号
  191. couponSecret:"我是卡密",//卡密
  192. dead_date:"我是有效期",//有效期
  193. awardState: 1,
  194. cdate: "2020-03-23",
  195. awardId: 11
  196. },
  197. {
  198. awardDetailPicContentHeight: 0,
  199. awardName: "100元购车红包", //奖品名称
  200. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  201. couponCode: "我是卡号",//卡号
  202. couponSecret:"我是卡密",//卡密
  203. dead_date:"我是有效期",//有效期
  204. awardState: 1,
  205. cdate: "2020-03-23",
  206. awardId: 13
  207. },
  208. {
  209. awardDetailPicContentHeight: 0,
  210. awardName: "100元机油升级券", //奖品名称
  211. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  212. couponCode: "我是卡号",//卡号
  213. couponSecret:"我是卡密",//卡密
  214. dead_date:"我是有效期",//有效期
  215. awardState: 1,
  216. cdate: "2020-03-23",
  217. awardId: 14
  218. },
  219. {
  220. awardDetailPicContentHeight: 0,
  221. awardName: "500元现金", //奖品名称
  222. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  223. couponCode: "我是卡号",//卡号
  224. couponSecret:"我是卡密",//卡密
  225. dead_date:"我是有效期",//有效期
  226. awardState: 1,
  227. cdate: "2020-03-23",
  228. awardId: 16
  229. },
  230. {
  231. awardDetailPicContentHeight: 0,
  232. awardName: "1000元现金", //奖品名称
  233. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  234. couponCode: "我是卡号",//卡号
  235. couponSecret:"我是卡密",//卡密
  236. dead_date:"我是有效期",//有效期
  237. awardState: 1,
  238. cdate: "2020-03-23",
  239. awardId: 17
  240. },
  241. {
  242. awardDetailPicContentHeight: 0,
  243. awardName: "10元京东E卡", //奖品名称
  244. awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  245. couponCode: "我是卡号",//卡号
  246. couponSecret:"我是卡密",//卡密
  247. dead_date:"我是有效期",//有效期
  248. awardState: 1,
  249. cdate: "2020-03-23",
  250. awardId: 18
  251. },
  252. ]
  253. },
  254. /**
  255. * 生命周期函数--监听页面加载
  256. */
  257. onLoad: function (options) {
  258. app.globalData.nowPage = 4;
  259. if (options.sourcePage){
  260. this.data.optionsData = options.sourcePage;
  261. }
  262. if (app.globalData.openid) {
  263. this.loadFun();
  264. } else {
  265. app.globalData.openidSuccessFuc = this.loadFun;
  266. }
  267. },
  268. loadFun: function () {
  269. if (!app.globalData.addPageEnterState.myCenter) {
  270. app.addPageEnter("BDAB6E93ECCD815EE83371E16EE42886");
  271. app.globalData.addPageEnterState.myCenter = true;
  272. }
  273. this.getUserInfo();
  274. this.getAddress();
  275. if (app.globalData.userMobile) {
  276. this.data.subscribeData.mobile = app.globalData.userMobile;
  277. this.setData({
  278. phoneInputShow: true,
  279. subscribeData: this.data.subscribeData
  280. })
  281. }
  282. if (app.globalData.myCenterData) {
  283. this.setData({
  284. provinceArr: app.globalData.myCenterData.provinceArr,
  285. storeArr: app.globalData.myCenterData.storeArr,
  286. provinceValue: app.globalData.myCenterData.provinceValue,
  287. storeValue: app.globalData.myCenterData.storeValue,
  288. // isRegister: app.globalData.isRegister
  289. })
  290. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  291. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  292. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  293. }
  294. // if (!app.globalData.isRegister) {
  295. // this.getOrderInfo();
  296. // }
  297. if (app.globalData.userInfoData) {
  298. if (app.globalData.userInfoData.avatarUrl){
  299. this.data.userData.avatarUrl = app.globalData.userInfoData.avatarUrl;
  300. this.data.userData.nickName = app.globalData.userInfoData.nickName;
  301. this.data.userData.userLevel = app.globalData.userInfoData.userLevel;
  302. this.setData({
  303. isLogin: true,
  304. userData: this.data.userData
  305. })
  306. }
  307. }
  308. if(!app.globalData.isStar){
  309. this.phonebolb();
  310. }else{
  311. app.globalData.authenticationStatus = app.globalData.isStar;
  312. if (!app.globalData.certificationInfo) {
  313. app.globalData.certificationInfo = true;
  314. wx.setStorageSync("certificationInfo", true);
  315. }
  316. app.globalData.certificationState = app.globalData.isStar.certificationState;
  317. }
  318. },
  319. /**
  320. * 生命周期函数--监听页面初次渲染完成
  321. */
  322. onReady: function () {
  323. },
  324. /**
  325. * 生命周期函数--监听页面显示
  326. */
  327. onShow: function () {
  328. if (app.globalData.getBuyState) {
  329. this.getBuyStates();
  330. } else {
  331. app.globalData.buyStateSuccessFuc = this.getBuyStates;
  332. }
  333. this.data.subscribeData.parentOpenid = app.globalData.parentOpenid;
  334. },
  335. getBuyStates: function () {
  336. this.setData({
  337. buyState: app.globalData.getBuyState.success,
  338. buyStateTime: app.globalData.getBuyState.cdate
  339. })
  340. },
  341. /**
  342. * 生命周期函数--监听页面隐藏
  343. */
  344. onHide: function () {
  345. },
  346. /**
  347. * 生命周期函数--监听页面卸载
  348. */
  349. onUnload: function () {
  350. },
  351. /**
  352. * 页面相关事件处理函数--监听用户下拉动作
  353. */
  354. onPullDownRefresh: function () {
  355. },
  356. /**
  357. * 页面上拉触底事件的处理函数
  358. */
  359. onReachBottom: function () {
  360. },
  361. /**
  362. * 用户点击右上角分享
  363. */
  364. onShareAppMessage: function () {
  365. return app.sharePack();
  366. },
  367. selectChange:function(e){
  368. this.setData({
  369. selectNow: e.currentTarget.dataset.value
  370. })
  371. if (e.currentTarget.dataset.value == 1) {
  372. this.getFriendBuCarNum();
  373. } else if (e.currentTarget.dataset.value == 2) {
  374. this.data.parames2.page = 1;
  375. this.data.noData2 = false;
  376. this.setData({
  377. recordList:[]
  378. })
  379. this.getMyAwardList();
  380. } else if (e.currentTarget.dataset.value == 3){
  381. this.data.parames.page = 1;
  382. this.data.noData = false;
  383. this.setData({
  384. parames: this.data.parames,
  385. shareFriendList:[]
  386. })
  387. this.getShareList();
  388. }else if(e.currentTarget.dataset.value == 4){
  389. this.data.parames3.page = 1;
  390. this.data.noData3 = false;
  391. this.setData({
  392. couponList:[]
  393. })
  394. this.getMyCouponList();
  395. }
  396. },
  397. getMyCouponList:function(){//获取我的卡包
  398. this.setData({
  399. couponListState: true
  400. })
  401. wx.showLoading({
  402. title: '获取数据中'
  403. })
  404. app.wxRequest(app.globalData.urlRoot +"/bag/getMyCouponList",this.data.parames3,res=>{
  405. wx.hideLoading();
  406. if(res.code==200){
  407. if(res.data){
  408. for(let i=0;i<res.data.list.length;i++){
  409. this.data.couponList.push(res.data.list[i]);
  410. }
  411. this.setData({
  412. couponList: this.data.couponList
  413. })
  414. if (res.data.list.length<this.data.parames3.count){
  415. this.setData({
  416. noData3: true
  417. })
  418. }
  419. }
  420. }
  421. this.setData({
  422. couponListState: false
  423. })
  424. },this);
  425. },
  426. selectTask: function (e) {
  427. this.setData({
  428. taskNow: e.currentTarget.dataset.type
  429. })
  430. if (this.data.taskNow==2){
  431. this.getFriendBuCarNum();
  432. }
  433. },
  434. getFriendBuCarNum:function(){
  435. app.wxRequest(app.globalData.urlRoot +"/share/getFriendBuCarNum",{},res=>{
  436. if(res.code==200){
  437. this.setData({
  438. barNums: res.data.total
  439. })
  440. }
  441. },this);
  442. },
  443. selectRecord: function (e) {
  444. if (this.data.recordNow == e.currentTarget.dataset.type) {
  445. return;
  446. }
  447. this.setData({
  448. recordList:[],
  449. recordNow: e.currentTarget.dataset.type
  450. })
  451. this.data.parames2.page = 1;
  452. this.data.noData2 = false;
  453. this.getMyAwardList();
  454. },
  455. getUserLocation: function (e) {
  456. wx.getLocation({
  457. type: 'gcj02', //wgs84
  458. success: (res) => {
  459. this.getDistributorList(res.longitude, res.latitude);
  460. },
  461. fail: (res) => {
  462. this.getDistributorList("", "");
  463. },
  464. complete: (res) => {
  465. this.setData({
  466. siteSelect: true,
  467. })
  468. }
  469. })
  470. },
  471. getDistributorList: function (longitude, latitude) {//获取经销商列表
  472. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  473. if (res.code == 200) {
  474. app.globalData.myCenterData = {};
  475. this.setData({
  476. provinceArr: res.data.list,
  477. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  478. provinceValue: res.data.nearData.provinceIndex,
  479. storeValue: res.data.nearData.cityIndex
  480. })
  481. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  482. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  483. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  484. app.globalData.myCenterData.provinceArr = res.data.list;
  485. app.globalData.myCenterData.storeArr = res.data.list[res.data.nearData.provinceIndex].children;
  486. app.globalData.myCenterData.provinceValue = res.data.nearData.provinceIndex;
  487. app.globalData.myCenterData.storeValue = res.data.nearData.cityIndex;
  488. } else {
  489. wx.showToast({
  490. title: res.msg,
  491. icon: "none"
  492. })
  493. }
  494. }, this);
  495. },
  496. provinceChane: function (e) {//选中省
  497. this.setData({
  498. provinceValue: e.detail.value,
  499. storeArr: this.data.provinceArr[e.detail.value].children,
  500. storeValue: 0
  501. })
  502. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  503. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  504. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  505. },
  506. storeChane: function (e) {//选中店铺
  507. this.setData({
  508. storeValue: e.detail.value,
  509. })
  510. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  511. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  512. },
  513. getCode: function (e) {//获取验证码
  514. if (!app.mobileVerify(this.data.subscribeData.mobile)) {
  515. if (this.data.subscribeData.mobile) {
  516. wx.showToast({
  517. title: '请输入正确的电话',
  518. icon: 'none'
  519. })
  520. } else {
  521. wx.showToast({
  522. title: '请输入电话',
  523. icon: 'none'
  524. })
  525. }
  526. return;
  527. }
  528. if (!this.data.sendCode) {
  529. return;
  530. }
  531. this.data.sendCode = false;
  532. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.subscribeData.mobile }, res => {
  533. if (res.code == 200) {
  534. this.countDown();
  535. wx.showToast({
  536. title: '验证码获取成功',
  537. icon: "none"
  538. })
  539. this.setData({
  540. verificationCode: 60
  541. })
  542. } else {
  543. this.data.sendCode = true;
  544. wx.showToast({
  545. title: res.msg,
  546. icon: "none"
  547. })
  548. }
  549. }, this)
  550. },
  551. countDown: function () {//倒计时
  552. setTimeout(() => {
  553. this.setData({
  554. verificationCode: this.data.verificationCode - 1
  555. })
  556. if (this.data.verificationCode > 0) {
  557. this.countDown();
  558. } else {
  559. this.setData({
  560. verificationCode: "获取验证码"
  561. })
  562. this.data.sendCode = true;
  563. }
  564. }, 1000);
  565. },
  566. getRealname: function (e) {//获取用户输入的姓名
  567. this.data.subscribeData.realname = e.detail.value;
  568. },
  569. getMobile: function (e) {//获取用户输入的电话
  570. this.data.subscribeData.mobile = e.detail.value;
  571. },
  572. getCaptcha: function (e) {//获取用户输入的验证码
  573. this.data.subscribeData.captcha = e.detail.value;
  574. },
  575. subscribeFun: function (e) {//预约鉴赏
  576. if(!this.data.subscribeData.realname){
  577. wx.showToast({
  578. title: '请输入姓名',
  579. icon:"none"
  580. })
  581. return;
  582. }
  583. if (!this.data.subscribeData.mobile) {
  584. wx.showToast({
  585. title: '请输入电话',
  586. icon: "none"
  587. })
  588. return;
  589. }
  590. if (!this.data.subscribeData.captcha) {
  591. wx.showToast({
  592. title: '请输入验证码',
  593. icon: "none"
  594. })
  595. return;
  596. }
  597. if (!this.data.isAgreement) {
  598. wx.showToast({
  599. title: '请同意协议',
  600. icon: 'none'
  601. })
  602. return;
  603. }
  604. if (!this.data.appointment) {
  605. return;
  606. }
  607. this.data.appointment = false;
  608. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  609. this.data.appointment = true;
  610. if (res.code == 200) {
  611. wx.showToast({
  612. title: '预约成功'
  613. })
  614. this.data.subscribeData.realname = "";
  615. this.data.subscribeData.captcha = "";
  616. this.setData({
  617. subscribeData: this.data.subscribeData,
  618. verificationCode: '获取验证码',
  619. })
  620. this.setData({
  621. siteSelect: false
  622. })
  623. // this.setData({
  624. // isRegister: true
  625. // })
  626. // app.globalData.isRegister = true;
  627. app.globalData.userMobile = this.data.subscribeData.mobile;
  628. } else {
  629. wx.showToast({
  630. title: res.msg,
  631. icon: "none"
  632. })
  633. }
  634. }, this, "POST")
  635. },
  636. getUserWxMsg:function(e){//通过微信获取用户信息
  637. if (e.detail.errMsg == "getUserInfo:ok") {
  638. this.data.userData.avatarUrl = e.detail.userInfo.avatarUrl;
  639. this.data.userData.nickName = e.detail.userInfo.nickName;
  640. this.setData({
  641. userData: this.data.userData,
  642. isLogin: true
  643. })
  644. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  645. }
  646. },
  647. getUserInfo:function(e){//获取个人信息
  648. app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => {
  649. if (res.code == 200) {
  650. if (res.data && res.data.avatarUrl) {
  651. if (!app.globalData.userInfoData.nickName) {
  652. this.data.userData.avatarUrl = res.data.avatarUrl;
  653. this.data.userData.nickName = res.data.nickName;
  654. this.data.userData.userLevel = res.data.userLevel;
  655. app.globalData.userInfoData = {};
  656. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  657. app.globalData.userInfoData.nickName = res.data.nickName;
  658. app.globalData.userInfoData.userLevel = res.data.userLevel;
  659. wx.setStorageSync('userInfoData', {
  660. avatarUrl: res.data.avatarUrl,
  661. nickName: res.data.nickName,
  662. userLevel: res.data.userLevel,
  663. })
  664. } else if (app.globalData.userInfoData.nickName){
  665. if (app.globalData.userInfoData.userLevel != res.data.userLevel) {
  666. this.data.userData.userLevel = res.data.userLevel;
  667. app.globalData.userInfoData.userLevel = res.data.userLevel;
  668. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  669. }
  670. if (app.globalData.userInfoData.avatarUrl != res.data.avatarUrl) {
  671. this.data.userData.avatarUrl = res.data.avatarUrl;
  672. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  673. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  674. }
  675. if (app.globalData.userInfoData.nickName != res.data.nickName) {
  676. this.data.userData.nickName = res.data.nickName;
  677. app.globalData.userInfoData.nickName = res.data.nickName;
  678. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  679. }
  680. }
  681. this.setData({
  682. userData: this.data.userData
  683. })
  684. if (app.globalData.userInfoData.nickName){
  685. this.setData({
  686. isLogin: true
  687. })
  688. }
  689. }
  690. }
  691. },this)
  692. },
  693. getTaskProgress: function () {//获取任务完成度 1每日任务
  694. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: this.data.taskNow},res=>{
  695. if(res.code==200){
  696. if(res.data){
  697. for (let i = 0; i < res.data.taskData.length; i++) {
  698. res.data.taskData[i]['unlockNum'] = 0;
  699. for (let j = 0; j < res.data.taskData[i].childIdArr.length; j++) {
  700. if (res.data.taskData[i].childIdArr[j]) {
  701. res.data.taskData[i]['unlockNum'] += 1;
  702. }
  703. }
  704. }
  705. this.setData({
  706. taskList: res.data.taskData
  707. })
  708. }
  709. }
  710. },this)
  711. },
  712. lookDesc:function(e){//查看奖品详情
  713. var index = e.currentTarget.dataset.index;
  714. if (this.data.lookPrizeDetail) {
  715. this.setData({
  716. lookPrizeDetail: !this.data.lookPrizeDetail
  717. })
  718. return;
  719. }
  720. if (this.data.recordList[index].awardState == 0 && !this.data.isAddress){
  721. this.setData({
  722. mycenterTipWindow:1,
  723. })
  724. } else if(this.data.recordList[index].awardState == 0 && this.data.isAddress){
  725. wx.showToast({
  726. title:"购车成功后可用",
  727. icon:"none"
  728. })
  729. }else {
  730. this.setData({
  731. lookIndex: (index || index == 0) ? this.data.recordList[index] : null,
  732. lookPrizeDetail: !this.data.lookPrizeDetail
  733. })
  734. }
  735. },
  736. lookRule: function (e) {//查看奖品详情
  737. this.setData({
  738. ruleShow: e.currentTarget.dataset.value
  739. })
  740. },
  741. getShareList: function () {//星探小分队
  742. this.setData({
  743. getFriendListState: true
  744. })
  745. wx.showLoading({
  746. title: '获取数据中'
  747. })
  748. app.wxRequest(app.globalData.urlRoot + "share/getFriendRegisterList", this.data.parames,res=>{
  749. wx.hideLoading();
  750. if(res.code==200){
  751. for(let i=0;i<res.data.length;i++){
  752. this.data.shareFriendList.push(res.data[i]);
  753. }
  754. this.setData({
  755. shareFriendList: this.data.shareFriendList
  756. })
  757. if (res.data.length<this.data.parames.count){
  758. this.setData({
  759. noData: true
  760. })
  761. }
  762. }
  763. this.setData({
  764. getFriendListState: false
  765. })
  766. },this);
  767. },
  768. getOrderInfo: function () {//查询是否已注册
  769. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  770. if (res.code == 200) {
  771. if (res.data) {
  772. this.setData({
  773. isRegister: true
  774. })
  775. app.globalData.isRegister = true;
  776. app.globalData.userMobile = res.data.mobile;
  777. } else {
  778. if (app.globalData.userMobile) {
  779. this.data.subscribeData.mobile = app.globalData.userMobile;
  780. this.setData({
  781. phoneInputShow: true,
  782. subscribeData: this.data.subscribeData
  783. })
  784. }
  785. }
  786. } else {
  787. console.log(res.msg)
  788. }
  789. }, this);
  790. },
  791. scrolltolower:function(){//星探小分队滚动条触底时执行
  792. if(!this.data.noData){
  793. this.data.parames.page+=1;
  794. this.getShareList();
  795. }
  796. },
  797. scrolltolower2:function(){
  798. if(!this.data.noData2){
  799. this.data.parames2.page+=1;
  800. this.getMyAwardList();
  801. }
  802. },
  803. scrolltolower3:function(){
  804. if(!this.data.noData3){
  805. this.data.parames3.page+=1;
  806. this.getMyCouponList();
  807. }
  808. },
  809. getMyAwardList: function () {//获取获奖记录
  810. this.setData({
  811. getState:true
  812. })
  813. wx.showLoading({
  814. title: '获取数据中'
  815. })
  816. this.data.parames2.awardSource = this.data.recordNow;
  817. app.wxRequest(app.globalData.urlRoot + "award/getMyAwardList", this.data.parames2, res => {
  818. wx.hideLoading();
  819. if(res.code == 200){
  820. // res.data[0].awardState = 0;
  821. // res.data = this.data.testData;
  822. // res.data = [{
  823. // awardDetailPicContentHeight: 0,
  824. // awardName: "500元现金", //奖品名称
  825. // awardPicurl: "https://xingb.venucia.com/award/10_1.png",//奖品小图
  826. // couponCode: "我是卡号",//卡号
  827. // couponSecret:"我是卡密",//卡密
  828. // dead_date:"我是有效期",//有效期
  829. // awardState: 1,
  830. // cdate: "2020-03-23",
  831. // awardId: 16
  832. // }]
  833. // if(this.data.parames2.page<3){
  834. // for(let i=0;i<20;i++){
  835. // res.data.push(res.data[0])
  836. // }
  837. // }
  838. for(let i=0;i<res.data.length;i++){
  839. this.data.recordList.push(res.data[i]);
  840. }
  841. this.setData({
  842. recordList: this.data.recordList
  843. })
  844. if (res.data.length<this.data.parames2.count){
  845. this.setData({
  846. noData2: true
  847. })
  848. }
  849. }
  850. this.setData({
  851. getState: false
  852. })
  853. },this)
  854. },
  855. getUserPhone: function (e) {//获取用户手机号
  856. this.setData({
  857. phoneInputShow: true
  858. })
  859. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  860. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  861. if (res.code == 200) {
  862. if (res.data && res.data.decodeData){
  863. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  864. this.setData({
  865. subscribeData: this.data.subscribeData
  866. })
  867. }
  868. } else {
  869. wx.showToast({
  870. title: res.msg,
  871. icon: "none"
  872. })
  873. }
  874. }, this);
  875. }
  876. },
  877. addressControl: function () {//跳转到地址管理
  878. if (app.globalData.userInfoData.nickName) {
  879. this.data.userData.avatarUrl = app.globalData.userInfoData.avatarUrl;
  880. this.data.userData.nickName = app.globalData.userInfoData.nickName;
  881. this.setData({
  882. userData: this.data.userData
  883. })
  884. }
  885. this.setData({
  886. addressShow:!this.data.addressShow,
  887. mycenterTipWindow:0
  888. })
  889. if (!this.data.isAddress){
  890. this.getAddress();
  891. }
  892. if(this.data.selectNow==2 && this.data.recordNow == 1 && !this.data.addressShow){
  893. this.data.parames2.page = 1;
  894. this.data.noData2 = false;
  895. this.setData({
  896. recordList:[]
  897. })
  898. this.getMyAwardList();
  899. }
  900. if(this.data.selectNow==4 && this.data.couponList.length && !this.data.addressShow){
  901. this.data.parames3.page = 1;
  902. this.data.noData3 = false;
  903. this.setData({
  904. couponList:[]
  905. })
  906. this.getMyCouponList();
  907. }
  908. },
  909. agreementState: function () {//协议
  910. this.setData({
  911. isAgreement: !this.data.isAgreement
  912. })
  913. },
  914. agreementControl: function () {
  915. this.setData({
  916. agreement: !this.data.agreement
  917. })
  918. },
  919. lookMore:function(){
  920. wx.navigateTo({
  921. url: '/pages/moreType/moreType',
  922. })
  923. },
  924. showSite: function () {//显示地址选择框
  925. if (!this.data.siteSelect) {
  926. if (!app.globalData.myCenterData) {
  927. this.getUserLocation();//获取用户当前位置
  928. }else{
  929. this.setData({
  930. siteSelect:true
  931. })
  932. }
  933. }
  934. },
  935. placingControl: function () {
  936. if (app.globalData.getBuyState.success != this.data.buyState) {
  937. this.setData({
  938. buyState: app.globalData.getBuyState.success,
  939. buyStateTime: app.globalData.getBuyState.cdate
  940. })
  941. }
  942. if(this.data.tipWindow2){
  943. this.setData({
  944. tipWindow2:false
  945. })
  946. }
  947. this.setData({
  948. placing: !this.data.placing
  949. })
  950. },
  951. scoutRuleControl:function(){
  952. this.setData({
  953. scoutRule: !this.data.scoutRule
  954. })
  955. },
  956. tipWindow:function(){
  957. this.setData({
  958. mycenterTipWindow:0
  959. })
  960. },
  961. lookAddress:function(){
  962. this.addressControl();
  963. },
  964. copyExchangeCode:function(){
  965. var text = this.data.recordList[this.data.lookDescId].couponCode || this.data.recordList[this.data.lookDescId].productCode || "";
  966. this.contentCopy(text);
  967. },
  968. contentCopy:function(text){//内容复制
  969. wx.setClipboardData({
  970. data: text
  971. })
  972. },
  973. getAddress: function () {//获取地址
  974. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  975. if (res.code == 200) {
  976. if (res.data) {
  977. this.data.isAddress = true;
  978. this.setData({
  979. mycenterTipWindow:0
  980. })
  981. }
  982. } else {
  983. wx.showToast({
  984. title: res.msg,
  985. icon: "none"
  986. })
  987. }
  988. }, this);
  989. },
  990. starGo:function(){//去完成
  991. wx.reLaunch({
  992. url: '/pages/star/star',
  993. })
  994. },
  995. enterLucky:function(){
  996. wx.reLaunch({
  997. url: '/pages/luckyStar/luckyStar',
  998. })
  999. },
  1000. enterEvery:function(){
  1001. wx.navigateTo({
  1002. url: '/pages/everyday/everyday',
  1003. })
  1004. },
  1005. vipDetailControl:function(e){
  1006. var index = e.currentTarget.dataset.index;
  1007. if (!this.data.couponList[index].addressState){
  1008. this.setData({
  1009. mycenterTipWindow:1,
  1010. })
  1011. return;
  1012. }
  1013. this.setData({
  1014. couponListCode:this.data.couponList[index].couponCode?this.data.couponList[index].couponCode:""
  1015. })
  1016. if(this.data.couponList[index].couponId=="175978"){
  1017. this.vipDetailHide();
  1018. }else if(this.data.couponList[index].couponId=="171748"){
  1019. this.machineHide();
  1020. }else if(this.data.couponList[index].couponId=="177275"){
  1021. this.upgradeHide();
  1022. }else if(this.data.couponList[index].couponId=="179478"){
  1023. this.starMoveHide();
  1024. }else if(this.data.couponList[index].couponId=="185379"){
  1025. this.cashHide1();
  1026. }else if(this.data.couponList[index].couponId=="185382"){
  1027. this.cashHide2();
  1028. }
  1029. },
  1030. vipDetailHide:function(){
  1031. this.setData({
  1032. vipDetailShow:!this.data.vipDetailShow
  1033. })
  1034. },
  1035. machineHide:function(){
  1036. this.setData({
  1037. machineShow:!this.data.machineShow
  1038. })
  1039. },
  1040. upgradeHide:function(){
  1041. this.setData({
  1042. upgradeShow:!this.data.upgradeShow
  1043. })
  1044. },
  1045. starMoveHide:function(){
  1046. this.setData({
  1047. starMoveShow:!this.data.starMoveShow
  1048. })
  1049. },
  1050. cashHide1:function(){
  1051. this.setData({
  1052. cash1Show:!this.data.cash1Show
  1053. })
  1054. },
  1055. cashHide2:function(){
  1056. this.setData({
  1057. cash2Show:!this.data.cash2Show
  1058. })
  1059. },
  1060. cardCodeCopy:function(){
  1061. this.contentCopy(this.data.couponListCode);
  1062. },
  1063. lookOrder:function(){//跳转到智趣启辰小程序的订单页面
  1064. // if(this.data.buyState){
  1065. console.log("小程序跳转");
  1066. wx.navigateToMiniProgram({
  1067. appId:'wx1d585c8c2fffe589',
  1068. path:"/activity_module/pages/carorder_info/carorder_info",
  1069. // appId:"wxf712bf8ad7e95b46",
  1070. // path:"/pages/myindex/index",
  1071. success(res) {
  1072. // 打开成功
  1073. },
  1074. complete(res){
  1075. console.log(res);
  1076. }
  1077. })
  1078. // }else{
  1079. // this.tipWindowControl();
  1080. // }
  1081. },
  1082. tipWindowControl:function(){
  1083. this.setData({
  1084. tipWindow2:!this.data.tipWindow2
  1085. })
  1086. },
  1087. enterPoster(){//荐车晋级
  1088. if(this.data.starInfo==200 || app.globalData.isStar){
  1089. if(app.globalData.isStar && app.globalData.isStar.agentDetail){
  1090. wx.navigateTo({
  1091. url: '/pages/poster/poster'
  1092. })
  1093. }else{
  1094. wx.navigateTo({
  1095. url: '/pages/supplement/supplement'
  1096. })
  1097. }
  1098. }else if(this.data.starInfo==-307){
  1099. wx.navigateTo({
  1100. url: '/pages/mobileVerification/mobileVerification'
  1101. })
  1102. }else if(this.data.starInfo==-308){
  1103. wx.navigateTo({
  1104. url: '/pages/scout/register/register'
  1105. })
  1106. }
  1107. },
  1108. phonebolb: function (_phone) {
  1109. app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfoV2", {}, res => {
  1110. this.data.starInfo = res.code;
  1111. if (res.code == 200) {
  1112. app.globalData.isStar = res.data;
  1113. wx.setStorageSync('isStar', res.data);
  1114. app.globalData.authenticationStatus = res.data;
  1115. if (!app.globalData.certificationInfo) {
  1116. app.globalData.certificationInfo = true;
  1117. wx.setStorageSync("certificationInfo", true);
  1118. }
  1119. app.globalData.certificationState = res.data.certificationState;
  1120. }
  1121. }, this);
  1122. }
  1123. })