东风启辰小程序端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

myCenter.js 27KB

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