C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

973 lines
25 KiB

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