东风启辰小程序端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

895 lines
27KB

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