东风启辰小程序端
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. console.log(app.globalData.userInfoData);
  283. if (app.globalData.userInfoData) {
  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. onReady: function () {
  297. },
  298. /**
  299. * 生命周期函数--监听页面显示
  300. */
  301. onShow: function () {
  302. if (app.globalData.getBuyState) {
  303. this.getBuyStates();
  304. } else {
  305. app.globalData.buyStateSuccessFuc = this.getBuyStates;
  306. }
  307. this.data.subscribeData.parentOpenid = app.globalData.parentOpenid;
  308. },
  309. getBuyStates: function () {
  310. this.setData({
  311. buyState: app.globalData.getBuyState.success,
  312. buyStateTime: app.globalData.getBuyState.cdate,
  313. buyStateCouponCode: app.globalData.getBuyState.coupon_code
  314. })
  315. },
  316. /**
  317. * 生命周期函数--监听页面隐藏
  318. */
  319. onHide: function () {
  320. },
  321. /**
  322. * 生命周期函数--监听页面卸载
  323. */
  324. onUnload: function () {
  325. },
  326. /**
  327. * 页面相关事件处理函数--监听用户下拉动作
  328. */
  329. onPullDownRefresh: function () {
  330. },
  331. /**
  332. * 页面上拉触底事件的处理函数
  333. */
  334. onReachBottom: function () {
  335. },
  336. /**
  337. * 用户点击右上角分享
  338. */
  339. onShareAppMessage: function () {
  340. return app.sharePack();
  341. },
  342. selectChange:function(e){
  343. this.setData({
  344. selectNow: e.currentTarget.dataset.value
  345. })
  346. if (e.currentTarget.dataset.value == 1) {
  347. this.getFriendBuCarNum();
  348. } else if (e.currentTarget.dataset.value == 2) {
  349. this.data.parames2.page = 1;
  350. this.data.noData2 = false;
  351. this.setData({
  352. recordList:[]
  353. })
  354. this.getMyAwardList();
  355. } else if (e.currentTarget.dataset.value == 3){
  356. this.data.parames.page = 1;
  357. this.data.noData = false;
  358. this.setData({
  359. parames: this.data.parames,
  360. shareFriendList:[]
  361. })
  362. this.getShareList();
  363. }
  364. },
  365. selectTask: function (e) {
  366. this.setData({
  367. taskNow: e.currentTarget.dataset.type
  368. })
  369. if (this.data.taskNow==2){
  370. this.getFriendBuCarNum();
  371. }
  372. },
  373. getFriendBuCarNum:function(){
  374. app.wxRequest(app.globalData.urlRoot +"/share/getFriendBuCarNum",{},res=>{
  375. if(res.code==200){
  376. this.setData({
  377. barNums: res.data.total
  378. })
  379. }
  380. },this);
  381. },
  382. selectRecord: function (e) {
  383. if (this.data.recordNow == e.currentTarget.dataset.type) {
  384. return;
  385. }
  386. this.setData({
  387. recordList:[],
  388. recordNow: e.currentTarget.dataset.type
  389. })
  390. this.data.parames2.page = 1;
  391. this.data.noData2 = false;
  392. this.getMyAwardList();
  393. },
  394. getUserLocation: function (e) {
  395. wx.getLocation({
  396. type: 'gcj02', //wgs84
  397. success: (res) => {
  398. this.getDistributorList(res.longitude, res.latitude);
  399. },
  400. fail: (res) => {
  401. this.getDistributorList("", "");
  402. },
  403. complete: (res) => {
  404. this.setData({
  405. siteSelect: true,
  406. })
  407. }
  408. })
  409. },
  410. getDistributorList: function (longitude, latitude) {//获取经销商列表
  411. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  412. if (res.code == 200) {
  413. app.globalData.myCenterData = {};
  414. this.setData({
  415. provinceArr: res.data.list,
  416. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  417. provinceValue: res.data.nearData.provinceIndex,
  418. storeValue: res.data.nearData.cityIndex
  419. })
  420. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  421. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  422. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  423. app.globalData.myCenterData.provinceArr = res.data.list;
  424. app.globalData.myCenterData.storeArr = res.data.list[res.data.nearData.provinceIndex].children;
  425. app.globalData.myCenterData.provinceValue = res.data.nearData.provinceIndex;
  426. app.globalData.myCenterData.storeValue = res.data.nearData.cityIndex;
  427. } else {
  428. wx.showToast({
  429. title: res.msg,
  430. icon: "none"
  431. })
  432. }
  433. }, this);
  434. },
  435. provinceChane: function (e) {//选中省
  436. this.setData({
  437. provinceValue: e.detail.value,
  438. storeArr: this.data.provinceArr[e.detail.value].children,
  439. storeValue: 0
  440. })
  441. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  442. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  443. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  444. },
  445. storeChane: function (e) {//选中店铺
  446. this.setData({
  447. storeValue: e.detail.value,
  448. })
  449. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  450. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  451. },
  452. getCode: function (e) {//获取验证码
  453. if (!app.mobileVerify(this.data.subscribeData.mobile)) {
  454. if (this.data.subscribeData.mobile) {
  455. wx.showToast({
  456. title: '请输入正确的电话',
  457. icon: 'none'
  458. })
  459. } else {
  460. wx.showToast({
  461. title: '请输入电话',
  462. icon: 'none'
  463. })
  464. }
  465. return;
  466. }
  467. if (!this.data.sendCode) {
  468. return;
  469. }
  470. this.data.sendCode = false;
  471. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.subscribeData.mobile }, res => {
  472. if (res.code == 200) {
  473. this.countDown();
  474. wx.showToast({
  475. title: '验证码获取成功',
  476. icon: "none"
  477. })
  478. this.setData({
  479. verificationCode: 60
  480. })
  481. } else {
  482. this.data.sendCode = true;
  483. wx.showToast({
  484. title: res.msg,
  485. icon: "none"
  486. })
  487. }
  488. }, this)
  489. },
  490. countDown: function () {//倒计时
  491. setTimeout(() => {
  492. this.setData({
  493. verificationCode: this.data.verificationCode - 1
  494. })
  495. if (this.data.verificationCode > 0) {
  496. this.countDown();
  497. } else {
  498. this.setData({
  499. verificationCode: "获取验证码"
  500. })
  501. this.data.sendCode = true;
  502. }
  503. }, 1000);
  504. },
  505. getRealname: function (e) {//获取用户输入的姓名
  506. this.data.subscribeData.realname = e.detail.value;
  507. },
  508. getMobile: function (e) {//获取用户输入的电话
  509. this.data.subscribeData.mobile = e.detail.value;
  510. },
  511. getCaptcha: function (e) {//获取用户输入的验证码
  512. this.data.subscribeData.captcha = e.detail.value;
  513. },
  514. subscribeFun: function (e) {//预约鉴赏
  515. if(!this.data.subscribeData.realname){
  516. wx.showToast({
  517. title: '请输入姓名',
  518. icon:"none"
  519. })
  520. return;
  521. }
  522. if (!this.data.subscribeData.mobile) {
  523. wx.showToast({
  524. title: '请输入电话',
  525. icon: "none"
  526. })
  527. return;
  528. }
  529. if (!this.data.subscribeData.captcha) {
  530. wx.showToast({
  531. title: '请输入验证码',
  532. icon: "none"
  533. })
  534. return;
  535. }
  536. if (!this.data.isAgreement) {
  537. wx.showToast({
  538. title: '请同意协议',
  539. icon: 'none'
  540. })
  541. return;
  542. }
  543. if (!this.data.appointment) {
  544. return;
  545. }
  546. this.data.appointment = false;
  547. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  548. this.data.appointment = true;
  549. if (res.code == 200) {
  550. wx.showToast({
  551. title: '预约成功'
  552. })
  553. this.data.subscribeData.realname = "";
  554. this.data.subscribeData.captcha = "";
  555. this.setData({
  556. subscribeData: this.data.subscribeData,
  557. verificationCode: '获取验证码',
  558. })
  559. this.setData({
  560. siteSelect: false
  561. })
  562. // this.setData({
  563. // isRegister: true
  564. // })
  565. // app.globalData.isRegister = true;
  566. app.globalData.userMobile = this.data.subscribeData.mobile;
  567. } else {
  568. wx.showToast({
  569. title: res.msg,
  570. icon: "none"
  571. })
  572. }
  573. }, this, "POST")
  574. },
  575. getUserWxMsg:function(e){//通过微信获取用户信息
  576. if (e.detail.errMsg == "getUserInfo:ok") {
  577. this.data.userData.avatarUrl = e.detail.userInfo.avatarUrl;
  578. this.data.userData.nickName = e.detail.userInfo.nickName;
  579. this.setData({
  580. userData: this.data.userData,
  581. isLogin: true
  582. })
  583. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  584. }
  585. },
  586. getUserInfo:function(e){//获取个人信息
  587. app.wxRequest(app.globalData.urlRoot + 'userInfo/getUserInfo', {}, res => {
  588. if (res.code == 200) {
  589. if (res.data && res.data.avatarUrl) {
  590. if (!app.globalData.userInfoData) {
  591. this.data.userData.avatarUrl = res.data.avatarUrl;
  592. this.data.userData.nickName = res.data.nickName;
  593. this.data.userData.userLevel = res.data.userLevel;
  594. app.globalData.userInfoData = {};
  595. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  596. app.globalData.userInfoData.nickName = res.data.nickName;
  597. app.globalData.userInfoData.userLevel = res.data.userLevel;
  598. wx.setStorageSync('userInfoData', {
  599. avatarUrl: res.data.avatarUrl,
  600. nickName: res.data.nickName,
  601. userLevel: res.data.userLevel,
  602. })
  603. } else if (app.globalData.userInfoData){
  604. if (app.globalData.userInfoData.userLevel != res.data.userLevel) {
  605. this.data.userData.userLevel = res.data.userLevel;
  606. app.globalData.userInfoData.userLevel = res.data.userLevel;
  607. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  608. }
  609. if (app.globalData.userInfoData.avatarUrl != res.data.avatarUrl) {
  610. this.data.userData.avatarUrl = res.data.avatarUrl;
  611. app.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  612. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  613. }
  614. if (app.globalData.userInfoData.nickName != res.data.nickName) {
  615. this.data.userData.nickName = res.data.nickName;
  616. app.globalData.userInfoData.nickName = res.data.nickName;
  617. wx.setStorageSync('userInfoData', app.globalData.userInfoData);
  618. }
  619. }
  620. this.setData({
  621. userData: this.data.userData
  622. })
  623. if (!app.globalData.userInfoData){
  624. this.setData({
  625. isLogin: true
  626. })
  627. }
  628. }
  629. }
  630. },this)
  631. },
  632. getTaskProgress: function () {//获取任务完成度 1每日任务
  633. app.wxRequest(app.globalData.urlRoot + "task/getTaskProgress", { taskType: this.data.taskNow},res=>{
  634. if(res.code==200){
  635. if(res.data){
  636. for (let i = 0; i < res.data.taskData.length; i++) {
  637. res.data.taskData[i]['unlockNum'] = 0;
  638. for (let j = 0; j < res.data.taskData[i].childIdArr.length; j++) {
  639. if (res.data.taskData[i].childIdArr[j]) {
  640. res.data.taskData[i]['unlockNum'] += 1;
  641. }
  642. }
  643. }
  644. this.setData({
  645. taskList: res.data.taskData
  646. })
  647. }
  648. }
  649. },this)
  650. },
  651. lookDesc:function(e){//查看奖品详情
  652. var index = e.currentTarget.dataset.index;
  653. if (this.data.lookPrizeDetail) {
  654. this.setData({
  655. lookPrizeDetail: !this.data.lookPrizeDetail
  656. })
  657. return;
  658. }
  659. if (this.data.recordList[index].awardState == 0 && !this.data.isAddress){
  660. this.setData({
  661. mycenterTipWindow:1,
  662. })
  663. } else if(this.data.recordList[index].awardState == 0 && this.data.isAddress){
  664. wx.showToast({
  665. title:"购车成功后可用",
  666. icon:"none"
  667. })
  668. }else {
  669. this.setData({
  670. lookIndex: (index || index == 0) ? this.data.recordList[index] : null,
  671. lookPrizeDetail: !this.data.lookPrizeDetail
  672. })
  673. }
  674. },
  675. lookRule: function (e) {//查看奖品详情
  676. this.setData({
  677. ruleShow: e.currentTarget.dataset.value
  678. })
  679. },
  680. getShareList: function () {//星探小分队
  681. this.setData({
  682. getFriendListState: true
  683. })
  684. wx.showLoading({
  685. title: '获取数据中'
  686. })
  687. app.wxRequest(app.globalData.urlRoot + "share/getFriendRegisterList", this.data.parames,res=>{
  688. wx.hideLoading();
  689. if(res.code==200){
  690. for(let i=0;i<res.data.length;i++){
  691. this.data.shareFriendList.push(res.data[i]);
  692. }
  693. this.setData({
  694. shareFriendList: this.data.shareFriendList
  695. })
  696. if (res.data.length<this.data.parames.count){
  697. this.setData({
  698. noData: true
  699. })
  700. }
  701. }
  702. this.setData({
  703. getFriendListState: false
  704. })
  705. },this);
  706. },
  707. getOrderInfo: function () {//查询是否已注册
  708. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  709. if (res.code == 200) {
  710. if (res.data) {
  711. this.setData({
  712. isRegister: true
  713. })
  714. app.globalData.isRegister = true;
  715. app.globalData.userMobile = res.data.mobile;
  716. } else {
  717. if (app.globalData.userMobile) {
  718. this.data.subscribeData.mobile = app.globalData.userMobile;
  719. this.setData({
  720. phoneInputShow: true,
  721. subscribeData: this.data.subscribeData
  722. })
  723. }
  724. }
  725. } else {
  726. console.log(res.msg)
  727. }
  728. }, this);
  729. },
  730. scrolltolower:function(){//星探小分队滚动条触底时执行
  731. if(!this.data.noData){
  732. this.data.parames.page+=1;
  733. this.getShareList();
  734. }
  735. },
  736. scrolltolower2:function(){
  737. console.log(this.data.noData2);
  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.userInfoData) {
  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/getAddress", {}, 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. })