C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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