东风启辰小程序端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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