东风启辰小程序端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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