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

840 lines
25KB

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