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

946 lines
28KB

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