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

myCenter.js 28KB

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