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

1035 line
31KB

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