东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1120 lines
33KB

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