东风启辰小程序端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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