东风启辰小程序端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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