C端小程序
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.

920 regels
23 KiB

  1. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  2. let ifStoreApp = extConfig.attr.ifStoreApp;
  3. const navigationBarHeight = (getApp().statusBarHeight + 44)+"px"
  4. const Http = require("../utils/HttpBasics");
  5. const imgurl = require("../utils/imgurl");
  6. const config = require("../config/config");
  7. const QR = require("../utils/memberqrcode.js");
  8. const util = require("../utils/util");
  9. const bgColor = require("../utils/bgColor.js")
  10. let app = getApp();
  11. Page({
  12. data: {
  13. typeLsit:{},
  14. showLocationIf: true,
  15. ifStoreApp: ifStoreApp,
  16. navigationBarTitle: '首页',
  17. navigationBarHeight,
  18. chengzhangBox: bgColor.colorFirst.main.chengzhangBox,
  19. activeColor: bgColor.colorFirst.main.activeColor,
  20. qg: bgColor.colorFirst.main.qg,
  21. newUrl: "",
  22. cover: "",
  23. kanjia: imgurl.kanjia.url,
  24. pintuan: imgurl.pintuan.url,
  25. xiaofeika: imgurl.xiaofeika.url,
  26. xingyun: imgurl.xingyun.url,
  27. jfshangcheng: imgurl.jfshangcheng.url,
  28. toutiao: imgurl.toutiao.url,
  29. more: imgurl.more.url,
  30. giftHr: imgurl.giftHr.url,
  31. giftHr: imgurl.giftHr.url,
  32. next: imgurl.next.url,
  33. usergift: imgurl.usergift.url,
  34. guanbi1: imgurl.guanbi1.url,
  35. icon0001: imgurl.icon0001.url,
  36. icon0002: imgurl.icon0002.url,
  37. icon0003: imgurl.icon0003.url,
  38. icon0004: imgurl.icon0004.url,
  39. icon0005: imgurl.icon0005.url,
  40. icon0006: imgurl.icon0006.url,
  41. icon0007: imgurl.icon0007.url,
  42. icon0008: imgurl.icon0008.url,
  43. barcode: imgurl.barcode.url,
  44. leftarrows: imgurl.leftarrows.url,
  45. newcard: imgurl.newcard.url,
  46. newseckill: imgurl.newseckill.url,
  47. newbargain: imgurl.newbargain.url,
  48. newgroup: imgurl.newgroup.url,
  49. product: imgurl.product.url,
  50. barginicon: imgurl.barginicon.url,
  51. pintuan: imgurl.pintuan.url,
  52. live: imgurl.live.url,
  53. duihuan: imgurl.duihuan.url,
  54. market: app.globalData.market,
  55. list: [],
  56. xslist: [],
  57. loading: true,
  58. fistLogin: null,
  59. alphaData: null,
  60. alphaData1: null,
  61. swiperCurrent: 0,
  62. title: null,
  63. weappShareTitle: '', //分享标题
  64. weappShareCoverImg: '', //分享图片
  65. desc: null,
  66. scrollTop: 0,
  67. showGame: false,
  68. showTopic: false,
  69. showQg: false,
  70. gamedata: {},
  71. couponId: '', //游戏返回时传回的字段
  72. played: false, //从游戏页面跳回首页返回true
  73. havePlayEd: app.globalData.havePlayEd,
  74. havePlayEd1: app.globalData.havePlayEd1,
  75. staticGamedata: {},
  76. showIf: false,
  77. showPages: false,
  78. display: 'none',
  79. display1: 'none',
  80. optionsData: null,
  81. page: 1, // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载
  82. openId: '',
  83. showGg: false,
  84. ggdata: {},
  85. liveFlag: 0, //直播按钮显隐标志位
  86. squareName: "", //当前广场
  87. isShowSqare: false,
  88. },
  89. //获取当前广场名
  90. //跳转到每日签到
  91. goSign(){
  92. wx.navigateTo({
  93. url: '/pages/activityCalendar/activityCalendar',
  94. })
  95. },
  96. //活动日历
  97. goCalendar(){
  98. wx.navigateTo({
  99. url: '/pages/dateLsit/dateLsit',
  100. })
  101. },
  102. //跳转到其他广场列表
  103. goSquareList() {
  104. wx.navigateTo({
  105. url: '/pages/location/location',
  106. })
  107. },
  108. goLive() {
  109. wx.navigateTo({
  110. url: '/pages2/live/livelist/index',
  111. })
  112. },
  113. alphaClick1: function(even) {
  114. var animation = wx.createAnimation({})
  115. animation.opacity(0).step({
  116. duration: 2000
  117. })
  118. this.setData({
  119. alphaData: animation.export()
  120. })
  121. },
  122. alphaClick: function(even) {
  123. var animation = wx.createAnimation({})
  124. animation.opacity(0).step({
  125. duration: 2000
  126. })
  127. this.setData({
  128. alphaData1: animation.export()
  129. })
  130. },
  131. // 我的卡包
  132. mycard: function() {
  133. wx.navigateTo({
  134. url: '/pages/cardorder/index/index',
  135. })
  136. },
  137. //我的券包
  138. mycoupon: function() {
  139. wx.navigateTo({
  140. url: '/pages/couponorder/index/index',
  141. })
  142. },
  143. gotoSpellGroup: function() {
  144. wx.navigateTo({
  145. url: '/pages/spellGroup/spellGroup',
  146. })
  147. },
  148. qrcode: function() {
  149. var that = this;
  150. let memberId = that.data.memberId;
  151. if (memberId) {
  152. wx.navigateTo({
  153. url: '/pages/specialcourtesy/specialcourtesy'
  154. })
  155. }
  156. },
  157. //跳往限时秒杀
  158. gotoRushBuy: function() {
  159. wx.navigateTo({
  160. url: '/pages/rushToBuy/index',
  161. })
  162. },
  163. swiperChange: function(e) {
  164. this.setData({
  165. swiperCurrent: e.detail.current
  166. });
  167. },
  168. gotogame: function() {
  169. let that = this;
  170. if (!that.data.showIf) {
  171. wx.showToast({
  172. title: '暂无游戏频道',
  173. icon: "none",
  174. duration: 3000
  175. })
  176. } else {
  177. Http.get({
  178. url: config.api.checkPhoneStatus,
  179. data: {}
  180. })
  181. .then(res => {
  182. var data = {
  183. couponChannelId: "" + that.data.couponChannelId,
  184. couponId: "" + that.data.couponId
  185. };
  186. if (that.data.couponChannelId == null) {
  187. var data = {
  188. couponId: "" + that.data.couponId
  189. };
  190. }
  191. wx.redirectTo({
  192. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  193. })
  194. })
  195. .catch(err => {
  196. if (err.code == 11005) {
  197. // 用户手机未授权
  198. /**
  199. * 将值传到用户手机号授权的页面
  200. *
  201. */
  202. wx.redirectTo({
  203. url: "/pages/getphoneInfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  204. });
  205. } else if (err.code == 11006) {
  206. // 用户手机已加密
  207. wx.redirectTo({
  208. url: "/pages/phoneinput/phoneinput?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  209. });
  210. } else {
  211. wx.showToast({
  212. title: err.message,
  213. icon: 'none',
  214. duration: 2000,
  215. mask: false
  216. });
  217. }
  218. })
  219. }
  220. },
  221. mySpecial: function() {
  222. console.log("special");
  223. wx.navigateTo({
  224. url: '/pages/specialcourtesy/specialcourtesy',
  225. })
  226. },
  227. //是否属于集团
  228. ifShowSqare() {
  229. if (wx.getStorageSync("squareList")) {
  230. this.setData({
  231. isShowSqare: true
  232. })
  233. } else {
  234. this.setData({
  235. isShowSqare: false
  236. })
  237. }
  238. },
  239. /**
  240. * 获取全局样式
  241. */
  242. getType() {
  243. Http.get({
  244. url: config.api.setType,
  245. data:{}
  246. }).then(res=>{
  247. const{code ,data}=res
  248. if(code==200){
  249. app.globalData.typeLsit=data
  250. this.setData({
  251. typeLsit: data,
  252. })
  253. }
  254. })
  255. },
  256. /**
  257. * 生命周期函数--监听页面初次渲染完成
  258. */
  259. onLoad: function(options) {
  260. this.getType()
  261. this.getLocation();
  262. let that = this;
  263. let optionss;
  264. let openId = wx.getStorageSync('openId')
  265. if (openId) {
  266. that.setData({
  267. openId: openId
  268. })
  269. }
  270. if (wx.getStorageSync('options')) {
  271. optionss = JSON.parse(wx.getStorageSync('options'));
  272. }
  273. if (options.played == "true") {
  274. that.setData({
  275. played: true
  276. })
  277. }
  278. if (optionss && optionss.couponChannelId || optionss && optionss.orderId) {
  279. that.setData({
  280. optionsData: optionss
  281. })
  282. that.getWeapNote(optionss.couponChannelId, optionss.orderId);
  283. } else {
  284. that.getWeapNote()
  285. }
  286. //获取条形码
  287. // util.barcode("barcode", optionss.quancode, 510, 100);
  288. // console.log(Http.headers.token, "?")
  289. },
  290. /**
  291. * 获得经纬度
  292. */
  293. getLocation() {
  294. let that = this;
  295. wx.getLocation({
  296. type: "wgs84",
  297. success: function(res) {
  298. console.log(res, 9999)
  299. if (res && res.longitude && res.latitude) {
  300. Http.post({
  301. url: config.api.updateLBS,
  302. data: {
  303. latitude: res.latitude,
  304. longitude: res.longitude
  305. }
  306. }).then(res => {
  307. console.log(res, 9999)
  308. })
  309. }
  310. },
  311. fail: error => {
  312. console.log(error);
  313. }
  314. })
  315. },
  316. onUnload() {
  317. // wx.removeStorageSync('squareList')
  318. },
  319. // 初始换底部导航栏
  320. setTabStyle: function () {
  321. this.getTabBar().setData({
  322. selectedColor: `${app.globalData.styleLsit.t_in_std.styleClass}`,
  323. list: [{
  324. "pagePath": "/index/index",
  325. "iconPath": `${app.globalData.styleLsit.t_in.icon}`,
  326. "selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
  327. "text": "首页"
  328. },
  329. {
  330. "pagePath": "/index/searchbar",
  331. "iconPath": `${app.globalData.styleLsit.t_md.icon}`,
  332. "selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
  333. "text": "门店"
  334. },
  335. {
  336. "pagePath": "/index/passCar",
  337. "iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
  338. "selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
  339. "text": "停车"
  340. },
  341. {
  342. "pagePath": "/index/user",
  343. "iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
  344. "selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
  345. "text": "我的"
  346. }
  347. ],
  348. })
  349. },
  350. onShow: function() {
  351. if(JSON.stringify(app.globalData.styleLsit)!="{}"){
  352. this.setTabStyle()
  353. }
  354. this.ifShowSqare();
  355. if (wx.getStorageSync("squareList")) {
  356. var temp = wx.getStorageSync("squareList").filter(item => item.tenantId == wx.getStorageSync("selectedMall"))[0].name
  357. this.setData({
  358. squareName: temp
  359. })
  360. }
  361. if (typeof this.getTabBar === 'function' &&
  362. this.getTabBar()) {
  363. this.getTabBar().setData({
  364. selected: 0,
  365. })
  366. }
  367. let that = this;
  368. that.setData({
  369. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  370. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  371. })
  372. /**
  373. * couponNum 是否有普通的优惠券购买
  374. * couponNum2 是否有新买的消费卡
  375. */
  376. let num = wx.getStorageSync('couponNum');
  377. let num1 = wx.getStorageSync('couponNum2');
  378. if (num == 'couponNum' || num1 == 'couponNum2') {
  379. wx.showTabBarRedDot({
  380. index: 3
  381. })
  382. } else {
  383. wx.hideTabBarRedDot({
  384. index: 3
  385. })
  386. }
  387. if (app.globalData.score) {
  388. that.setData({
  389. fistLogin: app.globalData.score
  390. })
  391. }
  392. // 如果有游戏
  393. setTimeout(function() {
  394. that.alphaClick();
  395. }, 8000)
  396. // 如果有广告
  397. setTimeout(function() {
  398. // debugger
  399. that.alphaClick1();
  400. }, 8000)
  401. },
  402. getmemberId: function(token) {
  403. let that = this;
  404. Http.get({
  405. url: config.api.getScore,
  406. data: {
  407. token: token
  408. }
  409. }).then(res => {
  410. that.setData({
  411. levelName: res.data.levelName,
  412. upgradePercent: res.data.upgradePercent,
  413. upgradeScore: res.data.upgradeScore,
  414. memberId: res.data.id,
  415. })
  416. })
  417. .catch(err => {
  418. wx.showModal({
  419. title: '提示',
  420. content: err.message,
  421. showCancel: false
  422. })
  423. })
  424. },
  425. gotoChengzhangzhi: function() {
  426. wx.navigateTo({
  427. url: '/pages/czdetail/czdetail',
  428. })
  429. },
  430. gotoBargain: function() {
  431. wx.navigateTo({
  432. url: '/pages/bargain/bargain',
  433. })
  434. },
  435. gotoSpellGroup: function() {
  436. wx.navigateTo({
  437. url: '/pages/spellGroup/spellGroup',
  438. })
  439. },
  440. gotoCard: function() {
  441. wx.navigateTo({
  442. url: '/pages/discountCardList/discountCardList',
  443. })
  444. },
  445. // gotoGame: function () {
  446. // wx.navigateTo({
  447. // url: '/pages/game/index',
  448. // })
  449. // },
  450. gotoJfsc: function() {
  451. wx.navigateTo({
  452. url: '/pages/integralmall/index',
  453. })
  454. },
  455. /**
  456. *
  457. * @param {code,page}
  458. * 子组件向父组件传值
  459. */
  460. onGetCode: function(e) {
  461. this.setData({
  462. code: e.detail.val,
  463. page: e.detail.pageNum,
  464. });
  465. console.log(e.detail.val)
  466. console.log(e.detail.pageNum)
  467. },
  468. getWeapNote: function(couponChannelId, couponId, orderId) {
  469. var that = this;
  470. if (app.globalData.token) {
  471. // 登录
  472. console.log(app.globalData.token)
  473. that.getmemberId(app.globalData.token);
  474. that.getBannerlist();
  475. that.topicShow();
  476. that.getxsList();
  477. that.getMallInfo(app.globalData.token);
  478. if (app.couponChannelListCallback) {
  479. app.couponChannelListCallback(app.globalData.token);
  480. }
  481. if (app.couponListCallback) {
  482. app.couponListCallback(app.globalData.token);
  483. }
  484. if (app.businessListCallback) {
  485. app.businessListCallback(app.globalData.token);
  486. }
  487. Http.get({
  488. url: config.api.getWeapNote,
  489. data: {
  490. appId: config.weapp.AppId,
  491. }
  492. })
  493. .then(res => {
  494. console.log(33333333333)
  495. console.log(app.globalData.token)
  496. console.log(res)
  497. console.log(33333333333)
  498. // that.getGameOne(app.globalData.token)
  499. that.getStaticGame(app.globalData.token)
  500. that.getGg(app.globalData.token)
  501. let weapNote = JSON.parse(res.data.weapNote);
  502. that.setData({
  503. desc: weapNote.firstpage.desc,
  504. title: weapNote.firstpage.title
  505. })
  506. })
  507. .catch(err => {
  508. // that.getGameOne(app.globalData.token)
  509. that.getStaticGame(app.globalData.token)
  510. that.getGg(app.globalData.token)
  511. wx.showModal({
  512. title: "提示",
  513. content: err.errMsg,
  514. showCancel: false
  515. });
  516. });
  517. } else {
  518. app.tokenCallback = token => {
  519. // 登录
  520. console.log(app.globalData.token)
  521. that.getmemberId(app.globalData.token);
  522. that.getBannerlist();
  523. that.topicShow();
  524. that.getxsList();
  525. that.getMallInfo(app.globalData.token);
  526. if (app.couponChannelListCallback) {
  527. app.couponChannelListCallback(app.globalData.token);
  528. }
  529. if (app.couponListCallback) {
  530. app.couponListCallback(app.globalData.token);
  531. }
  532. if (app.businessListCallback) {
  533. app.businessListCallback(app.globalData.token);
  534. }
  535. Http.get({
  536. url: config.api.getWeapNote,
  537. data: {
  538. appId: config.weapp.AppId,
  539. }
  540. })
  541. .then(res => {
  542. console.log(33333333333)
  543. console.log(app.globalData.token)
  544. console.log(res)
  545. console.log(33333333333)
  546. // that.getGameOne(app.globalData.token)
  547. that.getStaticGame(app.globalData.token)
  548. that.getGg(app.globalData.token)
  549. let weapNote = JSON.parse(res.data.weapNote);
  550. that.setData({
  551. desc: weapNote.firstpage.desc,
  552. title: weapNote.firstpage.title
  553. })
  554. })
  555. .catch(err => {
  556. // that.getGameOne(app.globalData.token)
  557. that.getStaticGame(app.globalData.token)
  558. that.getGg(app.globalData.token)
  559. wx.showModal({
  560. title: "提示",
  561. content: err.errMsg,
  562. showCancel: false
  563. });
  564. });
  565. }
  566. }
  567. },
  568. getStaticGame(token) {
  569. let _this = this;
  570. Http.get({
  571. url: config.api.getGame,
  572. data: {
  573. triggleAction: 2, // 固定入口
  574. token: token
  575. }
  576. }).then(res => {
  577. if (res.data.id) {
  578. _this.setData({
  579. showIf: true,
  580. newUrl: res.data.imgUrl
  581. })
  582. } else {
  583. _this.setData({
  584. showIf: false
  585. })
  586. }
  587. _this.setData({
  588. staticGamedata: res.data
  589. })
  590. })
  591. .catch(err => {
  592. _this.setData({
  593. showIf: false
  594. })
  595. console.log(err)
  596. })
  597. },
  598. getGameOne: function(token) {
  599. let _this = this;
  600. Http.get({
  601. url: config.api.getGame,
  602. data: {
  603. triggleAction: 1, // 登录触发
  604. token: token
  605. }
  606. }).then(res => {
  607. if (res.data.id) {
  608. _this.setData({
  609. showGame: true,
  610. })
  611. } else {
  612. _this.setData({
  613. showGame: false
  614. })
  615. }
  616. _this.setData({
  617. gamedata: res.data
  618. })
  619. })
  620. .catch(err => {
  621. _this.setData({
  622. showGame: false
  623. })
  624. this.alphaClick();
  625. })
  626. },
  627. /**
  628. * mallinfo
  629. */
  630. getMallInfo: function(token) {
  631. let that = this;
  632. Http.get({
  633. url: config.api.getMallInfo,
  634. data: {
  635. token: token,
  636. }
  637. }).then(res => {
  638. that.setData({
  639. liveFlag: res.data.liveSupport,
  640. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  641. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  642. });
  643. console.log(that.data.liveFlag, "||||")
  644. })
  645. .catch(err => {
  646. // 不需要错误提示
  647. });
  648. },
  649. //获取限时抢购列表
  650. getxsList() {
  651. let that = this;
  652. Http.get({
  653. url: config.api.couponChannelList,
  654. data: {
  655. pageNum: 1,
  656. pageSize: 3,
  657. targetAd: 2
  658. }
  659. }).then(res => {
  660. if (res && res.data.total > 0) {
  661. that.setData({
  662. xslist: res.data.list,
  663. showQg: true
  664. });
  665. } else {
  666. that.setData({
  667. showQg: false
  668. })
  669. }
  670. })
  671. .catch(err => {
  672. console.log(err)
  673. wx.showToast({
  674. title: err.errMsg,
  675. icon: 'none',
  676. duration: 2000,
  677. mask: false
  678. });
  679. })
  680. },
  681. /**
  682. * banner
  683. */
  684. getBannerlist: function() {
  685. let that = this;
  686. Http.get({
  687. url: config.api.bannerlist,
  688. data: {
  689. pageNum: 1,
  690. pageSize: 7
  691. }
  692. }).then(res => {
  693. that.getmemberId(app.globalData.token);
  694. // that.checkUserCarStatus();
  695. that.setData({
  696. list: res.data.list
  697. });
  698. })
  699. .catch(err => {
  700. that.getmemberId(app.globalData.token);
  701. // that.checkUserCarStatus();
  702. });
  703. },
  704. // 专题显示
  705. topicShow: function() {
  706. let that = this;
  707. Http.get({
  708. url: config.api.topicShow,
  709. data: {
  710. token: app.globalData.token
  711. }
  712. }).then(res => {
  713. if (res && res.data) {
  714. that.setData({
  715. name: res.data.name,
  716. cover: res.data.cover,
  717. id: res.data.id,
  718. showTopic: true
  719. })
  720. } else {
  721. that.setData({
  722. showTopic: false
  723. })
  724. }
  725. })
  726. .catch(err => {
  727. console.log(err);
  728. })
  729. },
  730. gotoTopic() {
  731. wx.navigateTo({
  732. url: `/pages/topicDetail/index?id=${this.data.id}`
  733. })
  734. },
  735. /**
  736. * 检查用户是否有车
  737. */
  738. // checkUserCarStatus: function() {
  739. // var that = this;
  740. // Http.get({
  741. // url: config.api.userCarCount,
  742. // data: {}
  743. // }).then(res => {
  744. // if (res.data > 0) {
  745. // // 用户名下有车
  746. // app.globalData.phone = res.data.phone;
  747. // app.globalData.supportCar = true;
  748. // // 共同登录
  749. // that.userCarLogin();
  750. // }
  751. // });
  752. // },
  753. /**
  754. * car共同登录
  755. */
  756. // userCarLogin: function() {
  757. // var that = this;
  758. // if (!app.globalData.carLogin) {
  759. // // 共同登录
  760. // Http.post({
  761. // url: config.api.carInit,
  762. // data: {
  763. // phone: app.globalData.phone
  764. // }
  765. // }).then(res => {
  766. // app.globalData.carLogin = true;
  767. // app.globalData.parkVendor = res.data.vendor;
  768. // if (res.data.token != "undefined") {
  769. // app.globalData.etcpToken = res.data.token;
  770. // }
  771. // });
  772. // }
  773. // },
  774. /**
  775. * 获取用户信息
  776. */
  777. // getUserInfo: function() {
  778. // // 获取用户信息
  779. // wx.getSetting({
  780. // success: res => {
  781. // if (res.authSetting["scope.userInfo"]) {
  782. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  783. // wx.getUserInfo({
  784. // success: res => {
  785. // // 可以将 res 发送给后台解码出 unionId
  786. // }
  787. // });
  788. // }
  789. // }
  790. // });
  791. // },
  792. gotoBargain: function() {
  793. wx.navigateTo({
  794. url: '/pages/bargain/bargain'
  795. })
  796. },
  797. //限时抢购的详情页面
  798. gotodetail: function(e) {
  799. wx.navigateTo({
  800. url: `/pages/coupon/detail/index?couponChannelId=${
  801. e.currentTarget.dataset.couponchannelid
  802. }&couponId=${e.currentTarget.dataset.couponid}`
  803. });
  804. },
  805. //浮层广告
  806. getGg: function(token) {
  807. let that = this
  808. Http.get({
  809. url: config.api.getGg,
  810. data: {
  811. token: token,
  812. appId: config.weapp.AppId,
  813. openId: that.data.openId
  814. }
  815. }).then(res => {
  816. console.log(res)
  817. if (res.data.id) {
  818. that.setData({
  819. showGg: true,
  820. })
  821. console.log(that.data.showGg, 1111111111111)
  822. } else {
  823. that.setData({
  824. showGg: false
  825. })
  826. that.getGameOne(app.globalData.token)
  827. console.log(that.data.showGg, 222222222222222222)
  828. }
  829. that.setData({
  830. ggdata: res.data
  831. })
  832. })
  833. .catch(err => {
  834. this.setData({
  835. showGg: false
  836. })
  837. that.getGameOne(app.globalData.token)
  838. that.alphaClick1();
  839. })
  840. },
  841. /**
  842. * 刷新
  843. */
  844. onPullDownRefresh: function(e) {
  845. let that = this;
  846. that.getWeapNote();
  847. that.setData({
  848. page: 1
  849. })
  850. if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) {
  851. this.getWeapNote(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
  852. } else {
  853. this.getWeapNote()
  854. }
  855. if (that.data.code == 0 || that.data.code == undefined) {
  856. that.selectComponent("#lists").getList(0, 1, "refresh");
  857. wx.stopPullDownRefresh();
  858. } else {
  859. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  860. wx.stopPullDownRefresh();
  861. };
  862. // 砍价下拉刷新
  863. // that.selectComponent("#bargain").getList();
  864. // that.selectComponent("#spellGroup").getList();
  865. // that.selectComponent("#rushtobyCard").getList();
  866. wx.stopPullDownRefresh();
  867. //爆款专区下拉刷新
  868. that.selectComponent("#hot").getList();
  869. that.getxsList();
  870. that.topicShow();
  871. },
  872. //加载更多
  873. onReachBottom: function() {
  874. let that = this;
  875. that.data.page++;
  876. that.setData({
  877. page: that.data.page
  878. });
  879. console.log("加载更多页数" + that.data.page);
  880. console.log("加载更多key" + that.data.code);
  881. //父组件获得子组件的方法
  882. //如果code == 0
  883. if (that.data.code == 0 || that.data.code == undefined) {
  884. that.selectComponent("#lists").getList(0, that.data.page);
  885. } else {
  886. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  887. }
  888. },
  889. // 用户点击右上角分享
  890. onShareAppMessage: function() {
  891. app.globalData.previewFlag = true
  892. return {
  893. title: this.data.weappShareTitle,
  894. imageUrl: this.data.weappShareCoverImg,
  895. // desc: this.data.desc,
  896. success: function(res) {
  897. wx.showToast({
  898. title: "分享成功",
  899. duration: 1000,
  900. icon: "success"
  901. });
  902. }
  903. };
  904. }
  905. });