东风启辰小程序端
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.

myCenter.js 26KB

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