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

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