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

829 line
26KB

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