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.

981 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. let that = this;
  310. let optionss;
  311. let openId = wx.getStorageSync('openId')
  312. if (wx.getStorageSync('options')) {
  313. optionss = JSON.parse(wx.getStorageSync('options'));
  314. }
  315. if (options.played == "true") {
  316. that.setData({
  317. played: true
  318. })
  319. }
  320. if (optionss && optionss.couponChannelId || optionss && optionss.orderId) {
  321. that.setData({
  322. optionsData: optionss
  323. })
  324. that.getWeapNote(optionss.couponChannelId, optionss.orderId);
  325. } else {
  326. that.getWeapNote()
  327. }
  328. //获取条形码
  329. // util.barcode("barcode", optionss.quancode, 510, 100);
  330. // console.log(Http.headers.token, "?")
  331. },
  332. /**
  333. * 获得经纬度
  334. */
  335. getLocation() {
  336. let that = this;
  337. wx.getLocation({
  338. type: "wgs84",
  339. success: function(res) {
  340. console.log(res, 9999)
  341. if (res && res.longitude && res.latitude) {
  342. Http.post({
  343. url: config.api.updateLBS,
  344. data: {
  345. latitude: res.latitude,
  346. longitude: res.longitude
  347. }
  348. }).then(res => {
  349. console.log(res, 9999)
  350. })
  351. }
  352. },
  353. fail: error => {
  354. console.log(error);
  355. }
  356. })
  357. },
  358. onUnload() {
  359. // wx.removeStorageSync('squareList')
  360. },
  361. // 初始换底部导航栏
  362. setTabStyle: function () {
  363. this.getTabBar().setData({
  364. selectedColor: `${app.globalData.styleLsit.t_in_std.styleClass}`,
  365. list: [{
  366. "pagePath": "/index/index",
  367. "iconPath": `${app.globalData.styleLsit.t_in.icon}`,
  368. "selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
  369. "text": "首页"
  370. },
  371. {
  372. "pagePath": "/index/searchbar",
  373. "iconPath": `${app.globalData.styleLsit.t_md.icon}`,
  374. "selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
  375. "text": "门店"
  376. },
  377. {
  378. "pagePath": "/index/passCar",
  379. "iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
  380. "selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
  381. "text": "停车"
  382. },
  383. {
  384. "pagePath": "/index/user",
  385. "iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
  386. "selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
  387. "text": "我的"
  388. }
  389. ],
  390. })
  391. },
  392. onShow: function() {
  393. this.uesrInfo()
  394. if (businessSwitch) {
  395. let openId = wx.getStorageSync("openId")
  396. this.setData({
  397. goUrl: `plugin://auto-points-plugin/index?openid=${openId}&mch_id=${this.data.mch_id}`
  398. })
  399. }
  400. if(JSON.stringify(app.globalData.styleLsit)!="{}"){
  401. this.setTabStyle()
  402. }
  403. this.ifShowSqare();
  404. if (wx.getStorageSync("squareList")) {
  405. var temp = wx.getStorageSync("squareList").filter(item => item.tenantId == wx.getStorageSync("selectedMall"))[0].name
  406. this.setData({
  407. squareName: temp
  408. })
  409. }
  410. if (typeof this.getTabBar === 'function' &&
  411. this.getTabBar()) {
  412. this.getTabBar().setData({
  413. selected: 0,
  414. })
  415. }
  416. let that = this;
  417. that.setData({
  418. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  419. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  420. })
  421. /**
  422. * couponNum 是否有普通的优惠券购买
  423. * couponNum2 是否有新买的消费卡
  424. */
  425. let num = wx.getStorageSync('couponNum');
  426. let num1 = wx.getStorageSync('couponNum2');
  427. // if (num == 'couponNum' || num1 == 'couponNum2') {
  428. // wx.showTabBarRedDot({
  429. // index: 3
  430. // })
  431. // } else {
  432. // wx.hideTabBarRedDot({
  433. // index: 3
  434. // })
  435. // }
  436. if (app.globalData.score) {
  437. that.setData({
  438. fistLogin: app.globalData.score
  439. })
  440. }
  441. // 如果有游戏
  442. setTimeout(function() {
  443. that.alphaClick();
  444. }, 8000)
  445. // 如果有广告
  446. setTimeout(function() {
  447. // debugger
  448. that.alphaClick1();
  449. }, 8000)
  450. },
  451. getmemberId: function(token) {
  452. let that = this;
  453. Http.get({
  454. url: config.api.getScore,
  455. data: {
  456. token: token
  457. }
  458. }).then(res => {
  459. that.setData({
  460. levelName: res.data.levelName,
  461. upgradePercent: res.data.upgradePercent,
  462. upgradeScore: res.data.upgradeScore,
  463. memberId: res.data.id,
  464. })
  465. })
  466. .catch(err => {
  467. wx.showModal({
  468. title: '提示',
  469. content: err.message,
  470. showCancel: false
  471. })
  472. })
  473. },
  474. gotoChengzhangzhi: function() {
  475. wx.navigateTo({
  476. url: '/pages/czdetail/czdetail',
  477. })
  478. },
  479. gotoBargain: function() {
  480. wx.navigateTo({
  481. url: '/pages/bargain/bargain',
  482. })
  483. },
  484. gotoSpellGroup: function() {
  485. wx.navigateTo({
  486. url: '/pages/spellGroup/spellGroup',
  487. })
  488. },
  489. gotoCard: function() {
  490. wx.navigateTo({
  491. url: '/pages/discountCardList/discountCardList',
  492. })
  493. },
  494. // gotoGame: function () {
  495. // wx.navigateTo({
  496. // url: '/pages/game/index',
  497. // })
  498. // },
  499. gotoJfsc: function() {
  500. wx.navigateTo({
  501. url: '/pages/integralmall/index',
  502. })
  503. },
  504. /**
  505. *
  506. * @param {code,page}
  507. * 子组件向父组件传值
  508. */
  509. onGetCode: function(e) {
  510. this.setData({
  511. code: e.detail.val,
  512. page: e.detail.pageNum,
  513. });
  514. console.log(e.detail.val)
  515. console.log(e.detail.pageNum)
  516. },
  517. getWeapNote: function(couponChannelId, couponId, orderId) {
  518. var that = this;
  519. if (app.globalData.token) {
  520. // 登录
  521. console.log(app.globalData.token)
  522. that.getmemberId(app.globalData.token);
  523. that.getBannerlist();
  524. that.topicShow();
  525. that.getxsList();
  526. that.getType()
  527. // that.uesrInfo()
  528. that.getLocation();
  529. that.getMallInfo(app.globalData.token);
  530. if (app.couponChannelListCallback) {
  531. app.couponChannelListCallback(app.globalData.token);
  532. }
  533. if (app.couponListCallback) {
  534. app.couponListCallback(app.globalData.token);
  535. }
  536. if (app.businessListCallback) {
  537. app.businessListCallback(app.globalData.token);
  538. }
  539. Http.get({
  540. url: config.api.getWeapNote,
  541. data: {
  542. appId: config.weapp.AppId,
  543. }
  544. })
  545. .then(res => {
  546. console.log(33333333333)
  547. console.log(app.globalData.token)
  548. console.log(res)
  549. console.log(33333333333)
  550. // that.getGameOne(app.globalData.token)
  551. that.getStaticGame(app.globalData.token)
  552. that.getGg(app.globalData.token)
  553. let weapNote = JSON.parse(res.data.weapNote);
  554. that.setData({
  555. desc: weapNote.firstpage.desc,
  556. title: weapNote.firstpage.title
  557. })
  558. })
  559. .catch(err => {
  560. // that.getGameOne(app.globalData.token)
  561. that.getStaticGame(app.globalData.token)
  562. that.getGg(app.globalData.token)
  563. wx.showModal({
  564. title: "提示",
  565. content: err.errMsg,
  566. showCancel: false
  567. });
  568. });
  569. } else {
  570. app.tokenCallback = token => {
  571. // 登录
  572. console.log(app.globalData.token)
  573. that.getmemberId(app.globalData.token);
  574. that.getBannerlist();
  575. that.topicShow();
  576. that.getxsList();
  577. that.getType()
  578. // that.uesrInfo()
  579. that.getLocation();
  580. that.getMallInfo(app.globalData.token);
  581. if (app.couponChannelListCallback) {
  582. app.couponChannelListCallback(app.globalData.token);
  583. }
  584. if (app.couponListCallback) {
  585. app.couponListCallback(app.globalData.token);
  586. }
  587. if (app.businessListCallback) {
  588. app.businessListCallback(app.globalData.token);
  589. }
  590. Http.get({
  591. url: config.api.getWeapNote,
  592. data: {
  593. appId: config.weapp.AppId,
  594. }
  595. })
  596. .then(res => {
  597. console.log(33333333333)
  598. console.log(app.globalData.token)
  599. console.log(res)
  600. console.log(33333333333)
  601. // that.getGameOne(app.globalData.token)
  602. that.getStaticGame(app.globalData.token)
  603. that.getGg(app.globalData.token)
  604. let weapNote = JSON.parse(res.data.weapNote);
  605. that.setData({
  606. desc: weapNote.firstpage.desc,
  607. title: weapNote.firstpage.title
  608. })
  609. })
  610. .catch(err => {
  611. // that.getGameOne(app.globalData.token)
  612. that.getStaticGame(app.globalData.token)
  613. that.getGg(app.globalData.token)
  614. wx.showModal({
  615. title: "提示",
  616. content: err.errMsg,
  617. showCancel: false
  618. });
  619. });
  620. }
  621. }
  622. },
  623. getStaticGame(token) {
  624. let _this = this;
  625. Http.get({
  626. url: config.api.getGame,
  627. data: {
  628. triggleAction: 2, // 固定入口
  629. token: token
  630. }
  631. }).then(res => {
  632. if (res.data.id) {
  633. _this.setData({
  634. showIf: true,
  635. newUrl: res.data.imgUrl
  636. })
  637. } else {
  638. _this.setData({
  639. showIf: false
  640. })
  641. }
  642. _this.setData({
  643. staticGamedata: res.data
  644. })
  645. })
  646. .catch(err => {
  647. _this.setData({
  648. showIf: false
  649. })
  650. console.log(err)
  651. })
  652. },
  653. getGameOne: function(token) {
  654. let _this = this;
  655. Http.get({
  656. url: config.api.getGame,
  657. data: {
  658. triggleAction: 1, // 登录触发
  659. token: token
  660. }
  661. }).then(res => {
  662. if (res.data.id) {
  663. _this.setData({
  664. showGame: true,
  665. })
  666. } else {
  667. _this.setData({
  668. showGame: false
  669. })
  670. }
  671. _this.setData({
  672. gamedata: res.data
  673. })
  674. })
  675. .catch(err => {
  676. _this.setData({
  677. showGame: false
  678. })
  679. this.alphaClick();
  680. })
  681. },
  682. /**
  683. * mallinfo
  684. */
  685. getMallInfo: function(token) {
  686. let that = this;
  687. Http.get({
  688. url: config.api.getMallInfo,
  689. data: {
  690. token: token,
  691. }
  692. }).then(res => {
  693. that.setData({
  694. liveFlag: res.data.liveSupport,
  695. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  696. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  697. });
  698. console.log(that.data.liveFlag, "||||")
  699. })
  700. .catch(err => {
  701. // 不需要错误提示
  702. });
  703. },
  704. //获取限时抢购列表
  705. getxsList() {
  706. let that = this;
  707. Http.get({
  708. url: config.api.couponChannelList,
  709. data: {
  710. pageNum: 1,
  711. pageSize: 3,
  712. targetAd: 2
  713. }
  714. }).then(res => {
  715. if (res && res.data.total > 0) {
  716. that.setData({
  717. xslist: res.data.list,
  718. showQg: true
  719. });
  720. } else {
  721. that.setData({
  722. showQg: false
  723. })
  724. }
  725. })
  726. .catch(err => {
  727. console.log(err)
  728. wx.showToast({
  729. title: err.errMsg,
  730. icon: 'none',
  731. duration: 2000,
  732. mask: false
  733. });
  734. })
  735. },
  736. /**
  737. * banner
  738. */
  739. getBannerlist: function() {
  740. let that = this;
  741. Http.get({
  742. url: config.api.bannerlist,
  743. data: {
  744. pageNum: 1,
  745. pageSize: 7
  746. }
  747. }).then(res => {
  748. that.getmemberId(app.globalData.token);
  749. // that.checkUserCarStatus();
  750. that.setData({
  751. list: res.data.list
  752. });
  753. })
  754. .catch(err => {
  755. that.getmemberId(app.globalData.token);
  756. // that.checkUserCarStatus();
  757. });
  758. },
  759. // 专题显示
  760. topicShow: function() {
  761. let that = this;
  762. Http.get({
  763. url: config.api.topicShow,
  764. data: {
  765. token: app.globalData.token
  766. }
  767. }).then(res => {
  768. if (res && res.data) {
  769. that.setData({
  770. name: res.data.name,
  771. cover: res.data.cover,
  772. id: res.data.id,
  773. showTopic: true
  774. })
  775. } else {
  776. that.setData({
  777. showTopic: false
  778. })
  779. }
  780. })
  781. .catch(err => {
  782. console.log(err);
  783. })
  784. },
  785. gotoTopic() {
  786. wx.navigateTo({
  787. url: `/pages/topicDetail/index?id=${this.data.id}`
  788. })
  789. },
  790. /**
  791. * 检查用户是否有车
  792. */
  793. // checkUserCarStatus: function() {
  794. // var that = this;
  795. // Http.get({
  796. // url: config.api.userCarCount,
  797. // data: {}
  798. // }).then(res => {
  799. // if (res.data > 0) {
  800. // // 用户名下有车
  801. // app.globalData.phone = res.data.phone;
  802. // app.globalData.supportCar = true;
  803. // // 共同登录
  804. // that.userCarLogin();
  805. // }
  806. // });
  807. // },
  808. /**
  809. * car共同登录
  810. */
  811. // userCarLogin: function() {
  812. // var that = this;
  813. // if (!app.globalData.carLogin) {
  814. // // 共同登录
  815. // Http.post({
  816. // url: config.api.carInit,
  817. // data: {
  818. // phone: app.globalData.phone
  819. // }
  820. // }).then(res => {
  821. // app.globalData.carLogin = true;
  822. // app.globalData.parkVendor = res.data.vendor;
  823. // if (res.data.token != "undefined") {
  824. // app.globalData.etcpToken = res.data.token;
  825. // }
  826. // });
  827. // }
  828. // },
  829. /**
  830. * 获取用户信息
  831. */
  832. // getUserInfo: function() {
  833. // // 获取用户信息
  834. // wx.getSetting({
  835. // success: res => {
  836. // if (res.authSetting["scope.userInfo"]) {
  837. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  838. // wx.getUserInfo({
  839. // success: res => {
  840. // // 可以将 res 发送给后台解码出 unionId
  841. // }
  842. // });
  843. // }
  844. // }
  845. // });
  846. // },
  847. gotoBargain: function() {
  848. wx.navigateTo({
  849. url: '/pages/bargain/bargain'
  850. })
  851. },
  852. //限时抢购的详情页面
  853. gotodetail: function(e) {
  854. wx.navigateTo({
  855. url: `/pages/coupon/detail/index?couponChannelId=${
  856. e.currentTarget.dataset.couponchannelid
  857. }&couponId=${e.currentTarget.dataset.couponid}`
  858. });
  859. },
  860. //浮层广告
  861. getGg: function(token) {
  862. let that = this
  863. Http.get({
  864. url: config.api.getGg,
  865. data: {
  866. token: token,
  867. appId: config.weapp.AppId,
  868. openId: "" // wx.getStorageSync('openId')
  869. }
  870. }).then(res => {
  871. console.log(res)
  872. if (res.data.id) {
  873. that.setData({
  874. showGg: true,
  875. })
  876. console.log(that.data.showGg, 1111111111111)
  877. } else {
  878. that.setData({
  879. showGg: false
  880. })
  881. that.getGameOne(app.globalData.token)
  882. console.log(that.data.showGg, 222222222222222222)
  883. }
  884. that.setData({
  885. ggdata: res.data
  886. })
  887. })
  888. .catch(err => {
  889. this.setData({
  890. showGg: false
  891. })
  892. that.getGameOne(app.globalData.token)
  893. that.alphaClick1();
  894. })
  895. },
  896. /**
  897. * 刷新
  898. */
  899. onPullDownRefresh: function(e) {
  900. let that = this;
  901. that.getWeapNote();
  902. that.setData({
  903. page: 1
  904. })
  905. if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) {
  906. this.getWeapNote(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
  907. } else {
  908. this.getWeapNote()
  909. }
  910. if (that.data.code == 0 || that.data.code == undefined) {
  911. that.selectComponent("#lists").getList(0, 1, "refresh");
  912. wx.stopPullDownRefresh();
  913. } else {
  914. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  915. wx.stopPullDownRefresh();
  916. };
  917. // 砍价下拉刷新
  918. // that.selectComponent("#bargain").getList();
  919. // that.selectComponent("#spellGroup").getList();
  920. // that.selectComponent("#rushtobyCard").getList();
  921. wx.stopPullDownRefresh();
  922. //爆款专区下拉刷新
  923. that.selectComponent("#hot").getList();
  924. that.getxsList();
  925. that.topicShow();
  926. },
  927. //加载更多
  928. onReachBottom: function() {
  929. let that = this;
  930. that.data.page++;
  931. that.setData({
  932. page: that.data.page
  933. });
  934. console.log("加载更多页数" + that.data.page);
  935. console.log("加载更多key" + that.data.code);
  936. //父组件获得子组件的方法
  937. //如果code == 0
  938. if (that.data.code == 0 || that.data.code == undefined) {
  939. that.selectComponent("#lists").getList(0, that.data.page);
  940. } else {
  941. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  942. }
  943. },
  944. // 用户点击右上角分享
  945. onShareAppMessage: function() {
  946. app.globalData.previewFlag = true
  947. return {
  948. title: this.data.weappShareTitle,
  949. imageUrl: this.data.weappShareCoverImg,
  950. // desc: this.data.desc,
  951. success: function(res) {
  952. wx.showToast({
  953. title: "分享成功",
  954. duration: 1000,
  955. icon: "success"
  956. });
  957. }
  958. };
  959. }
  960. });