东风启辰小程序端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1033 lines
30KB

  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. })
  324. },
  325. /**
  326. * 生命周期函数--监听页面隐藏
  327. */
  328. onHide: function () {
  329. },
  330. /**
  331. * 生命周期函数--监听页面卸载
  332. */
  333. onUnload: function () {
  334. },
  335. /**
  336. * 页面相关事件处理函数--监听用户下拉动作
  337. */
  338. onPullDownRefresh: function () {
  339. },
  340. /**
  341. * 页面上拉触底事件的处理函数
  342. */
  343. onReachBottom: function () {
  344. },
  345. /**
  346. * 用户点击右上角分享
  347. */
  348. onShareAppMessage: function () {
  349. return app.sharePack();
  350. },
  351. selectChange:function(e){
  352. this.setData({
  353. selectNow: e.currentTarget.dataset.value
  354. })
  355. if (e.currentTarget.dataset.value == 1) {
  356. this.getFriendBuCarNum();
  357. } else if (e.currentTarget.dataset.value == 2) {
  358. this.data.parames2.page = 1;
  359. this.data.noData2 = false;
  360. this.setData({
  361. recordList:[]
  362. })
  363. this.getMyAwardList();
  364. } else if (e.currentTarget.dataset.value == 3){
  365. this.data.parames.page = 1;
  366. this.data.noData = false;
  367. this.setData({
  368. parames: this.data.parames,
  369. shareFriendList:[]
  370. })
  371. this.getShareList();
  372. }else if(e.currentTarget.dataset.value == 4){
  373. this.data.parames3.page = 1;
  374. this.data.noData3 = false;
  375. this.setData({
  376. couponList:[]
  377. })
  378. this.getMyCouponList();
  379. }
  380. },
  381. getMyCouponList:function(){//获取我的卡包
  382. this.setData({
  383. couponListState: true
  384. })
  385. wx.showLoading({
  386. title: '获取数据中'
  387. })
  388. app.wxRequest(app.globalData.urlRoot +"/bag/getMyCouponList",this.data.parames3,res=>{
  389. wx.hideLoading();
  390. if(res.code==200){
  391. if(res.data){
  392. for(let i=0;i<res.data.list.length;i++){
  393. this.data.couponList.push(res.data.list[i]);
  394. }
  395. this.setData({
  396. couponList: this.data.couponList
  397. })
  398. if (res.data.list.length<this.data.parames3.count){
  399. this.setData({
  400. noData3: true
  401. })
  402. }
  403. }
  404. }
  405. this.setData({
  406. couponListState: false
  407. })
  408. },this);
  409. },
  410. selectTask: function (e) {
  411. this.setData({
  412. taskNow: e.currentTarget.dataset.type
  413. })
  414. if (this.data.taskNow==2){
  415. this.getFriendBuCarNum();
  416. }
  417. },
  418. getFriendBuCarNum:function(){
  419. app.wxRequest(app.globalData.urlRoot +"/share/getFriendBuCarNum",{},res=>{
  420. if(res.code==200){
  421. this.setData({
  422. barNums: res.data.total
  423. })
  424. }
  425. },this);
  426. },
  427. selectRecord: function (e) {
  428. if (this.data.recordNow == e.currentTarget.dataset.type) {
  429. return;
  430. }
  431. this.setData({
  432. recordList:[],
  433. recordNow: e.currentTarget.dataset.type
  434. })
  435. this.data.parames2.page = 1;
  436. this.data.noData2 = false;
  437. this.getMyAwardList();
  438. },
  439. getUserLocation: function (e) {
  440. wx.getLocation({
  441. type: 'gcj02', //wgs84
  442. success: (res) => {
  443. this.getDistributorList(res.longitude, res.latitude);
  444. },
  445. fail: (res) => {
  446. this.getDistributorList("", "");
  447. },
  448. complete: (res) => {
  449. this.setData({
  450. siteSelect: true,
  451. })
  452. }
  453. })
  454. },
  455. getDistributorList: function (longitude, latitude) {//获取经销商列表
  456. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  457. if (res.code == 200) {
  458. app.globalData.myCenterData = {};
  459. this.setData({
  460. provinceArr: res.data.list,
  461. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  462. provinceValue: res.data.nearData.provinceIndex,
  463. storeValue: res.data.nearData.cityIndex
  464. })
  465. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  466. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  467. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  468. app.globalData.myCenterData.provinceArr = res.data.list;
  469. app.globalData.myCenterData.storeArr = res.data.list[res.data.nearData.provinceIndex].children;
  470. app.globalData.myCenterData.provinceValue = res.data.nearData.provinceIndex;
  471. app.globalData.myCenterData.storeValue = res.data.nearData.cityIndex;
  472. } else {
  473. wx.showToast({
  474. title: res.msg,
  475. icon: "none"
  476. })
  477. }
  478. }, this);
  479. },
  480. provinceChane: function (e) {//选中省
  481. this.setData({
  482. provinceValue: e.detail.value,
  483. storeArr: this.data.provinceArr[e.detail.value].children,
  484. storeValue: 0
  485. })
  486. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  487. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  488. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  489. },
  490. storeChane: function (e) {//选中店铺
  491. this.setData({
  492. storeValue: e.detail.value,
  493. })
  494. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  495. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  496. },
  497. getCode: function (e) {//获取验证码
  498. if (!app.mobileVerify(this.data.subscribeData.mobile)) {
  499. if (this.data.subscribeData.mobile) {
  500. wx.showToast({
  501. title: '请输入正确的电话',
  502. icon: 'none'
  503. })
  504. } else {
  505. wx.showToast({
  506. title: '请输入电话',
  507. icon: 'none'
  508. })
  509. }
  510. return;
  511. }
  512. if (!this.data.sendCode) {
  513. return;
  514. }
  515. this.data.sendCode = false;
  516. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.subscribeData.mobile }, res => {
  517. if (res.code == 200) {
  518. this.countDown();
  519. wx.showToast({
  520. title: '验证码获取成功',
  521. icon: "none"
  522. })
  523. this.setData({
  524. verificationCode: 60
  525. })
  526. } else {
  527. this.data.sendCode = true;
  528. wx.showToast({
  529. title: res.msg,
  530. icon: "none"
  531. })
  532. }
  533. }, this)
  534. },
  535. countDown: function () {//倒计时
  536. setTimeout(() => {
  537. this.setData({
  538. verificationCode: this.data.verificationCode - 1
  539. })
  540. if (this.data.verificationCode > 0) {
  541. this.countDown();
  542. } else {
  543. this.setData({
  544. verificationCode: "获取验证码"
  545. })
  546. this.data.sendCode = true;
  547. }
  548. }, 1000);
  549. },
  550. getRealname: function (e) {//获取用户输入的姓名
  551. this.data.subscribeData.realname = e.detail.value;
  552. },
  553. getMobile: function (e) {//获取用户输入的电话
  554. this.data.subscribeData.mobile = e.detail.value;
  555. },
  556. getCaptcha: function (e) {//获取用户输入的验证码
  557. this.data.subscribeData.captcha = e.detail.value;
  558. },
  559. subscribeFun: function (e) {//预约鉴赏
  560. if(!this.data.subscribeData.realname){
  561. wx.showToast({
  562. title: '请输入姓名',
  563. icon:"none"
  564. })
  565. return;
  566. }
  567. if (!this.data.subscribeData.mobile) {
  568. wx.showToast({
  569. title: '请输入电话',
  570. icon: "none"
  571. })
  572. return;
  573. }
  574. if (!this.data.subscribeData.captcha) {
  575. wx.showToast({
  576. title: '请输入验证码',
  577. icon: "none"
  578. })
  579. return;
  580. }
  581. if (!this.data.isAgreement) {
  582. wx.showToast({
  583. title: '请同意协议',
  584. icon: 'none'
  585. })
  586. return;
  587. }
  588. if (!this.data.appointment) {
  589. return;
  590. }
  591. this.data.appointment = false;
  592. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  593. this.data.appointment = true;
  594. if (res.code == 200) {
  595. wx.showToast({
  596. title: '预约成功'
  597. })
  598. this.data.subscribeData.realname = "";
  599. this.data.subscribeData.captcha = "";
  600. this.setData({
  601. subscribeData: this.data.subscribeData,
  602. verificationCode: '获取验证码',
  603. })
  604. this.setData({
  605. siteSelect: false
  606. })
  607. // this.setData({
  608. // isRegister: true
  609. // })
  610. // app.globalData.isRegister = true;
  611. app.globalData.userMobile = this.data.subscribeData.mobile;
  612. } else {
  613. wx.showToast({
  614. title: res.msg,
  615. icon: "none"
  616. })
  617. }
  618. }, this, "POST")
  619. },
  620. getUserWxMsg:function(e){//通过微信获取用户信息
  621. if (e.detail.errMsg == "getUserInfo:ok") {
  622. this.data.userData.avatarUrl = e.detail.userInfo.avatarUrl;
  623. this.data.userData.nickName = e.detail.userInfo.nickName;
  624. this.setData({
  625. userData: this.data.userData,
  626. isLogin: true
  627. })
  628. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  629. }
  630. },
  631. getUserInfo:function(e){//获取个人信息
  632. app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => {
  633. if (res.code == 200) {
  634. if (res.data && res.data.avatarUrl) {
  635. if (!app.globalData.userInfoData.nickName) {
  636. this.data.userData.avatarUrl = res.data.avatarUrl;
  637. this.data.userData.nickName = res.data.nickName;
  638. this.data.userData.userLevel = res.data.userLevel;
  639. app.globalData.userInfoData = {};
  640. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  641. app.globalData.userInfoData.nickName = res.data.nickName;
  642. app.globalData.userInfoData.userLevel = res.data.userLevel;
  643. wx.setStorageSync('userInfoData', {
  644. avatarUrl: res.data.avatarUrl,
  645. nickName: res.data.nickName,
  646. userLevel: res.data.userLevel,
  647. })
  648. } else if (app.globalData.userInfoData.nickName){
  649. if (app.globalData.userInfoData.userLevel != res.data.userLevel) {
  650. this.data.userData.userLevel = res.data.userLevel;
  651. app.globalData.userInfoData.userLevel = res.data.userLevel;
  652. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  653. }
  654. if (app.globalData.userInfoData.avatarUrl != res.data.avatarUrl) {
  655. this.data.userData.avatarUrl = res.data.avatarUrl;
  656. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  657. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  658. }
  659. if (app.globalData.userInfoData.nickName != res.data.nickName) {
  660. this.data.userData.nickName = res.data.nickName;
  661. app.globalData.userInfoData.nickName = res.data.nickName;
  662. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  663. }
  664. }
  665. this.setData({
  666. userData: this.data.userData
  667. })
  668. if (app.globalData.userInfoData.nickName){
  669. this.setData({
  670. isLogin: true
  671. })
  672. }
  673. }
  674. }
  675. },this)
  676. },
  677. getTaskProgress: function () {//获取任务完成度 1每日任务
  678. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: this.data.taskNow},res=>{
  679. if(res.code==200){
  680. if(res.data){
  681. for (let i = 0; i < res.data.taskData.length; i++) {
  682. res.data.taskData[i]['unlockNum'] = 0;
  683. for (let j = 0; j < res.data.taskData[i].childIdArr.length; j++) {
  684. if (res.data.taskData[i].childIdArr[j]) {
  685. res.data.taskData[i]['unlockNum'] += 1;
  686. }
  687. }
  688. }
  689. this.setData({
  690. taskList: res.data.taskData
  691. })
  692. }
  693. }
  694. },this)
  695. },
  696. lookDesc:function(e){//查看奖品详情
  697. var index = e.currentTarget.dataset.index;
  698. if (this.data.lookPrizeDetail) {
  699. this.setData({
  700. lookPrizeDetail: !this.data.lookPrizeDetail
  701. })
  702. return;
  703. }
  704. if (this.data.recordList[index].awardState == 0 && !this.data.isAddress){
  705. this.setData({
  706. mycenterTipWindow:1,
  707. })
  708. } else if(this.data.recordList[index].awardState == 0 && this.data.isAddress){
  709. wx.showToast({
  710. title:"购车成功后可用",
  711. icon:"none"
  712. })
  713. }else {
  714. this.setData({
  715. lookIndex: (index || index == 0) ? this.data.recordList[index] : null,
  716. lookPrizeDetail: !this.data.lookPrizeDetail
  717. })
  718. }
  719. },
  720. lookRule: function (e) {//查看奖品详情
  721. this.setData({
  722. ruleShow: e.currentTarget.dataset.value
  723. })
  724. },
  725. getShareList: function () {//星探小分队
  726. this.setData({
  727. getFriendListState: true
  728. })
  729. wx.showLoading({
  730. title: '获取数据中'
  731. })
  732. app.wxRequest(app.globalData.urlRoot + "share/getFriendRegisterList", this.data.parames,res=>{
  733. wx.hideLoading();
  734. if(res.code==200){
  735. for(let i=0;i<res.data.length;i++){
  736. this.data.shareFriendList.push(res.data[i]);
  737. }
  738. this.setData({
  739. shareFriendList: this.data.shareFriendList
  740. })
  741. if (res.data.length<this.data.parames.count){
  742. this.setData({
  743. noData: true
  744. })
  745. }
  746. }
  747. this.setData({
  748. getFriendListState: false
  749. })
  750. },this);
  751. },
  752. getOrderInfo: function () {//查询是否已注册
  753. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  754. if (res.code == 200) {
  755. if (res.data) {
  756. this.setData({
  757. isRegister: true
  758. })
  759. app.globalData.isRegister = true;
  760. app.globalData.userMobile = res.data.mobile;
  761. } else {
  762. if (app.globalData.userMobile) {
  763. this.data.subscribeData.mobile = app.globalData.userMobile;
  764. this.setData({
  765. phoneInputShow: true,
  766. subscribeData: this.data.subscribeData
  767. })
  768. }
  769. }
  770. } else {
  771. console.log(res.msg)
  772. }
  773. }, this);
  774. },
  775. scrolltolower:function(){//星探小分队滚动条触底时执行
  776. if(!this.data.noData){
  777. this.data.parames.page+=1;
  778. this.getShareList();
  779. }
  780. },
  781. scrolltolower2:function(){
  782. if(!this.data.noData2){
  783. this.data.parames2.page+=1;
  784. this.getMyAwardList();
  785. }
  786. },
  787. scrolltolower3:function(){
  788. if(!this.data.noData3){
  789. this.data.parames3.page+=1;
  790. this.getMyCouponList();
  791. }
  792. },
  793. getMyAwardList: function () {//获取获奖记录
  794. this.setData({
  795. getState:true
  796. })
  797. wx.showLoading({
  798. title: '获取数据中'
  799. })
  800. this.data.parames2.awardSource = this.data.recordNow;
  801. app.wxRequest(app.globalData.urlRoot + "award/getMyAwardList", this.data.parames2, res => {
  802. wx.hideLoading();
  803. if(res.code == 200){
  804. // res.data[0].awardState = 0;
  805. // res.data = this.data.testData;
  806. // res.data = [{
  807. // awardDetailPicurl:"https://xingb.venucia.com/award/14_2.png",
  808. // awardId:14,
  809. // awardName:"100元机油升级券",
  810. // awardPicurl:"https://xingb.venucia.com/award/14_1.png",
  811. // awardState:1,
  812. // awardType:2,
  813. // cdate:"2020-04-01",
  814. // couponCode:"450610985",
  815. // productId:0
  816. // }]
  817. // if(this.data.parames2.page<3){
  818. // for(let i=0;i<20;i++){
  819. // res.data.push(res.data[0])
  820. // }
  821. // }
  822. for(let i=0;i<res.data.length;i++){
  823. this.data.recordList.push(res.data[i]);
  824. }
  825. this.setData({
  826. recordList: this.data.recordList
  827. })
  828. if (res.data.length<this.data.parames2.count){
  829. this.setData({
  830. noData2: true
  831. })
  832. }
  833. }
  834. this.setData({
  835. getState: false
  836. })
  837. },this)
  838. },
  839. getUserPhone: function (e) {//获取用户手机号
  840. this.setData({
  841. phoneInputShow: true
  842. })
  843. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  844. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  845. if (res.code == 200) {
  846. if (res.data && res.data.decodeData){
  847. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  848. this.setData({
  849. subscribeData: this.data.subscribeData
  850. })
  851. }
  852. } else {
  853. wx.showToast({
  854. title: res.msg,
  855. icon: "none"
  856. })
  857. }
  858. }, this);
  859. }
  860. },
  861. addressControl: function () {//跳转到地址管理
  862. if (app.globalData.userInfoData.nickName) {
  863. this.data.userData.avatarUrl = app.globalData.userInfoData.avatarUrl;
  864. this.data.userData.nickName = app.globalData.userInfoData.nickName;
  865. this.setData({
  866. userData: this.data.userData
  867. })
  868. }
  869. this.setData({
  870. addressShow:!this.data.addressShow,
  871. mycenterTipWindow:0
  872. })
  873. if (!this.data.isAddress){
  874. this.getAddress();
  875. }
  876. if(this.data.selectNow==2 && this.data.recordNow == 1 && !this.data.addressShow){
  877. this.data.parames2.page = 1;
  878. this.data.noData2 = false;
  879. this.setData({
  880. recordList:[]
  881. })
  882. this.getMyAwardList();
  883. }
  884. if(this.data.selectNow==4 && this.data.couponList.length && !this.data.addressShow){
  885. this.data.parames3.page = 1;
  886. this.data.noData3 = false;
  887. this.setData({
  888. couponList:[]
  889. })
  890. this.getMyCouponList();
  891. }
  892. },
  893. agreementState: function () {//协议
  894. this.setData({
  895. isAgreement: !this.data.isAgreement
  896. })
  897. },
  898. agreementControl: function () {
  899. this.setData({
  900. agreement: !this.data.agreement
  901. })
  902. },
  903. lookMore:function(){
  904. wx.navigateTo({
  905. url: '/pages/moreType/moreType',
  906. })
  907. },
  908. showSite: function () {//显示地址选择框
  909. if (!this.data.siteSelect) {
  910. if (!app.globalData.myCenterData) {
  911. this.getUserLocation();//获取用户当前位置
  912. }else{
  913. this.setData({
  914. siteSelect:true
  915. })
  916. }
  917. }
  918. },
  919. placingControl: function () {
  920. if (app.globalData.getBuyState.success != this.data.buyState) {
  921. this.setData({
  922. buyState: app.globalData.getBuyState.success,
  923. buyStateTime: app.globalData.getBuyState.cdate
  924. })
  925. }
  926. this.setData({
  927. placing: !this.data.placing
  928. })
  929. },
  930. scoutRuleControl:function(){
  931. this.setData({
  932. scoutRule: !this.data.scoutRule
  933. })
  934. },
  935. tipWindow:function(){
  936. this.setData({
  937. mycenterTipWindow:0
  938. })
  939. },
  940. lookAddress:function(){
  941. this.addressControl();
  942. },
  943. copyExchangeCode:function(){
  944. var text = this.data.recordList[this.data.lookDescId].couponCode || this.data.recordList[this.data.lookDescId].productCode || "";
  945. this.contentCopy(text);
  946. },
  947. contentCopy:function(text){//内容复制
  948. wx.setClipboardData({
  949. data: text
  950. })
  951. },
  952. getAddress: function () {//获取地址
  953. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  954. if (res.code == 200) {
  955. if (res.data) {
  956. this.data.isAddress = true;
  957. this.setData({
  958. mycenterTipWindow:0
  959. })
  960. }
  961. } else {
  962. wx.showToast({
  963. title: res.msg,
  964. icon: "none"
  965. })
  966. }
  967. }, this);
  968. },
  969. starGo:function(){//去完成
  970. wx.reLaunch({
  971. url: '/pages/star/star',
  972. })
  973. },
  974. enterLucky:function(){
  975. wx.reLaunch({
  976. url: '/pages/luckyStar/luckyStar',
  977. })
  978. },
  979. enterEvery:function(){
  980. wx.navigateTo({
  981. url: '/pages/everyday/everyday',
  982. })
  983. },
  984. vipDetailControl:function(e){
  985. var index = e.currentTarget.dataset.index;
  986. if (!this.data.couponList[index].addressState){
  987. this.setData({
  988. mycenterTipWindow:1,
  989. })
  990. return;
  991. }
  992. this.setData({
  993. couponListCode:this.data.couponList[index].couponCode?this.data.couponList[index].couponCode:""
  994. })
  995. if(this.data.couponList[index].couponId=="175978"){
  996. this.vipDetailHide();
  997. }else if(this.data.couponList[index].couponId=="171748"){
  998. this.machineHide();
  999. }else if(this.data.couponList[index].couponId=="177275"){
  1000. this.upgradeHide();
  1001. }
  1002. },
  1003. vipDetailHide:function(){
  1004. this.setData({
  1005. vipDetailShow:!this.data.vipDetailShow
  1006. })
  1007. },
  1008. machineHide:function(){
  1009. this.setData({
  1010. machineShow:!this.data.machineShow
  1011. })
  1012. },
  1013. upgradeHide:function(){
  1014. this.setData({
  1015. upgradeShow:!this.data.upgradeShow
  1016. })
  1017. },
  1018. cardCodeCopy:function(){
  1019. this.contentCopy(this.data.buyStateCouponCode);
  1020. }
  1021. })