东风启辰小程序端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

851 lines
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: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: 0,
  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: 0,
  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. this.setData({
  607. lookIndex: (index || index == 0) ? this.data.recordList[index]:null,
  608. lookPrizeDetail: !this.data.lookPrizeDetail
  609. })
  610. // if (this.data.descFrameShow){
  611. // this.setData({
  612. // descFrameShow: !this.data.descFrameShow,
  613. // })
  614. // return;
  615. // }
  616. // if (this.data.recordList[e.currentTarget.dataset.value].awardState == 0){
  617. // this.setData({
  618. // mycenterTipWindow:this.data.isAddress?2:1,
  619. // lookDescId: e.currentTarget.dataset.value || e.currentTarget.dataset.value == 0 ? e.currentTarget.dataset.value : null
  620. // })
  621. // } else {
  622. // this.setData({
  623. // descFrameShow: !this.data.descFrameShow,
  624. // lookDescId: e.currentTarget.dataset.value || e.currentTarget.dataset.value == 0 ? e.currentTarget.dataset.value : null
  625. // })
  626. // }
  627. },
  628. lookRule: function (e) {//查看奖品详情
  629. this.setData({
  630. ruleShow: e.currentTarget.dataset.value
  631. })
  632. },
  633. getShareList: function () {//星探小分队
  634. this.setData({
  635. getFriendListState: true
  636. })
  637. wx.showLoading({
  638. title: '获取数据中'
  639. })
  640. app.wxRequest(app.globalData.urlRoot + "share/getFriendRegisterList", this.data.parames,res=>{
  641. wx.hideLoading();
  642. this.setData({
  643. getFriendListState: false
  644. })
  645. if(res.code==200){
  646. for(let i=0;i<res.data.length;i++){
  647. this.data.shareFriendList.push(res.data[i]);
  648. }
  649. this.setData({
  650. shareFriendList: this.data.shareFriendList
  651. })
  652. if (res.data.length<this.data.parames.count){
  653. this.setData({
  654. noData: true
  655. })
  656. }
  657. }
  658. },this);
  659. },
  660. getOrderInfo: function () {//查询是否已注册
  661. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  662. if (res.code == 200) {
  663. if (res.data) {
  664. this.setData({
  665. isRegister: true
  666. })
  667. app.globalData.isRegister = true;
  668. app.globalData.userMobile = res.data.mobile;
  669. } else {
  670. if (app.globalData.userMobile) {
  671. this.data.subscribeData.mobile = app.globalData.userMobile;
  672. this.setData({
  673. phoneInputShow: true,
  674. subscribeData: this.data.subscribeData
  675. })
  676. }
  677. }
  678. } else {
  679. console.log(res.msg)
  680. }
  681. }, this);
  682. },
  683. scrolltolower:function(){//星探小分队滚动条触底时执行
  684. if(!this.data.noData){
  685. this.data.parames.page+=1;
  686. this.getShareList();
  687. }
  688. },
  689. getMyAwardList: function () {//获取获奖记录
  690. this.setData({
  691. getState:true
  692. })
  693. wx.showLoading({
  694. title: '获取数据中'
  695. })
  696. app.wxRequest(app.globalData.urlRoot + "award/getMyAwardList", { awardSource: this.data.recordNow }, res => {
  697. wx.hideLoading();
  698. this.setData({
  699. getState: false
  700. })
  701. if(res.code == 200){
  702. // res.data = this.data.testData;
  703. this.setData({
  704. recordList:res.data
  705. })
  706. }
  707. },this)
  708. },
  709. getUserPhone: function (e) {//获取用户手机号
  710. this.setData({
  711. phoneInputShow: true
  712. })
  713. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  714. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  715. if (res.code == 200) {
  716. if (res.data && res.data.decodeData){
  717. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  718. this.setData({
  719. subscribeData: this.data.subscribeData
  720. })
  721. }
  722. } else {
  723. wx.showToast({
  724. title: res.msg,
  725. icon: "none"
  726. })
  727. }
  728. }, this);
  729. }
  730. },
  731. addressControl: function () {//跳转到地址管理
  732. if (app.globalData.userInfoData) {
  733. this.data.userData.avatarUrl = app.globalData.userInfoData.avatarUrl;
  734. this.data.userData.nickName = app.globalData.userInfoData.nickName;
  735. this.setData({
  736. userData: this.data.userData
  737. })
  738. }
  739. this.setData({
  740. addressShow:!this.data.addressShow
  741. })
  742. if (this.data.isAddress== false){
  743. this.getAddress();
  744. }
  745. },
  746. agreementState: function () {//协议
  747. this.setData({
  748. isAgreement: !this.data.isAgreement
  749. })
  750. },
  751. agreementControl: function () {
  752. this.setData({
  753. agreement: !this.data.agreement
  754. })
  755. },
  756. lookMore:function(){
  757. wx.navigateTo({
  758. url: '/pages/moreType/moreType',
  759. })
  760. },
  761. showSite: function () {//显示地址选择框
  762. if (!this.data.siteSelect) {
  763. if (!app.globalData.myCenterData) {
  764. this.getUserLocation();//获取用户当前位置
  765. }else{
  766. this.setData({
  767. siteSelect:true
  768. })
  769. }
  770. }
  771. },
  772. placingControl: function () {
  773. if (app.globalData.getBuyState.success != this.data.buyState) {
  774. this.setData({
  775. buyState: app.globalData.getBuyState.success,
  776. buyStateTime: app.globalData.getBuyState.cdate
  777. })
  778. }
  779. this.setData({
  780. placing: !this.data.placing
  781. })
  782. },
  783. scoutRuleControl:function(){
  784. this.setData({
  785. scoutRule: !this.data.scoutRule
  786. })
  787. },
  788. tipWindow:function(){
  789. this.setData({
  790. mycenterTipWindow:0
  791. })
  792. },
  793. lookAddress:function(){
  794. this.addressControl();
  795. },
  796. copyExchangeCode:function(){
  797. var text = this.data.recordList[this.data.lookDescId].couponCode || this.data.recordList[this.data.lookDescId].productCode || "";
  798. this.contentCopy(text);
  799. },
  800. contentCopy:function(text){//内容复制
  801. wx.setClipboardData({
  802. data: text
  803. })
  804. },
  805. getAddress: function () {//获取地址
  806. app.wxRequest(app.globalData.urlRoot + "address/getAddress", {}, res => {
  807. if (res.code == 200) {
  808. if (res.data) {
  809. this.data.isAddress = true;
  810. }
  811. } else {
  812. wx.showToast({
  813. title: res.msg,
  814. icon: "none"
  815. })
  816. }
  817. }, this);
  818. },
  819. starGo:function(){//去完成
  820. wx.reLaunch({
  821. url: '/pages/star/star',
  822. })
  823. },
  824. enterLucky:function(){
  825. wx.reLaunch({
  826. url: '/pages/luckyStar/luckyStar',
  827. })
  828. },
  829. enterEvery:function(){
  830. wx.navigateTo({
  831. url: '/pages/everyday/everyday',
  832. })
  833. },
  834. vipDetailControl:function(){
  835. this.setData({
  836. vipDetailShow:!this.data.vipDetailShow
  837. })
  838. }
  839. })