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.

1357 rivejä
35 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. aa: (app.statusBarHeight + 34) + "rpx",
  16. noDataFlag: false,
  17. busineKye: 0,
  18. businePageNum: 1,
  19. credit: 0,
  20. businessList: [], //优选好物导航
  21. businessData: [], //优选好物数据
  22. topicObj2: null, //欢乐城首页限时抢购
  23. topicObj3: null, //欢乐城首页砍价
  24. topicObj4: null, //欢乐城首页拼团
  25. topicObj5: null, //欢乐城首页消费卡
  26. topicObj6: null, //欢乐城首页积分商城
  27. specialLsit: [], //欢乐城首页专题
  28. marketName: "", //商场名称
  29. mouldType: 0,
  30. navLineHeight: ((app.statusBarHeight + app.statusBarHeight) + 44) + "px",
  31. huanlechengImgurl: "https://formall.oss-accelerate.aliyuncs.com/cimg/v20211214/",
  32. mch_id: mch_id,
  33. goUrl: "", //商圈跳转链接
  34. accreditFlag: 1, //1是未授权微信且未授权手机号 2授权了微信 没授权手机号 3微信和手机号都授权了
  35. businessSwitch: businessSwitch,
  36. typeLsit: {},
  37. showLocationIf: true,
  38. ifStoreApp: ifStoreApp,
  39. navigationBarTitle: '首页',
  40. navigationBarHeight,
  41. chengzhangBox: bgColor.colorFirst.main.chengzhangBox,
  42. activeColor: bgColor.colorFirst.main.activeColor,
  43. qg: bgColor.colorFirst.main.qg,
  44. newUrl: "",
  45. cover: "",
  46. kanjia: imgurl.kanjia.url,
  47. pintuan: imgurl.pintuan.url,
  48. xiaofeika: imgurl.xiaofeika.url,
  49. xingyun: imgurl.xingyun.url,
  50. jfshangcheng: imgurl.jfshangcheng.url,
  51. toutiao: imgurl.toutiao.url,
  52. more: imgurl.more.url,
  53. giftHr: imgurl.giftHr.url,
  54. giftHr: imgurl.giftHr.url,
  55. next: imgurl.next.url,
  56. usergift: imgurl.usergift.url,
  57. guanbi1: imgurl.guanbi1.url,
  58. icon0001: imgurl.icon0001.url,
  59. icon0002: imgurl.icon0002.url,
  60. icon0003: imgurl.icon0003.url,
  61. icon0004: imgurl.icon0004.url,
  62. icon0005: imgurl.icon0005.url,
  63. icon0006: imgurl.icon0006.url,
  64. icon0007: imgurl.icon0007.url,
  65. icon0008: imgurl.icon0008.url,
  66. barcode: imgurl.barcode.url,
  67. leftarrows: imgurl.leftarrows.url,
  68. newcard: imgurl.newcard.url,
  69. newseckill: imgurl.newseckill.url,
  70. newbargain: imgurl.newbargain.url,
  71. newgroup: imgurl.newgroup.url,
  72. product: imgurl.product.url,
  73. barginicon: imgurl.barginicon.url,
  74. pintuan: imgurl.pintuan.url,
  75. live: imgurl.live.url,
  76. duihuan: imgurl.duihuan.url,
  77. market: app.globalData.market,
  78. list: [],
  79. xslist: [],
  80. loading: true,
  81. fistLogin: null,
  82. alphaData: null,
  83. alphaData1: null,
  84. swiperCurrent: 0,
  85. title: null,
  86. weappShareTitle: '', //分享标题
  87. weappShareCoverImg: '', //分享图片
  88. desc: null,
  89. scrollTop: 0,
  90. showGame: false,
  91. showTopic: false,
  92. showQg: false,
  93. gamedata: {},
  94. couponId: '', //游戏返回时传回的字段
  95. played: false, //从游戏页面跳回首页返回true
  96. havePlayEd: app.globalData.havePlayEd,
  97. havePlayEd1: app.globalData.havePlayEd1,
  98. staticGamedata: {},
  99. showIf: false,
  100. showPages: false,
  101. display: 'none',
  102. display1: 'none',
  103. optionsData: null,
  104. page: 1, // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载
  105. openId: '',
  106. showGg: false,
  107. ggdata: {},
  108. liveFlag: 0, //直播按钮显隐标志位
  109. squareName: "", //当前广场
  110. isShowSqare: false,
  111. moduleList: [], //按钮列表
  112. userAvatarUrl: "",
  113. userName: "",
  114. },
  115. getBusineData(e) {
  116. this.setData({
  117. businePageNum: 1,
  118. busineKye: e.detail,
  119. noDataFlag: false,
  120. })
  121. this.getCouponChannelList(e.detail)
  122. },
  123. // 2022年11月8日微信收回接口“wx.getUserProfile”、“wx.getUserInfo”之后,需要手动设置用户头像与昵称
  124. goSetAvatar() {
  125. const accreditFlag = this.data.accreditFlag
  126. // 没授权手机号
  127. if (accreditFlag == 2) {
  128. wx.navigateTo({
  129. url: '/pages/getphoneInfo/index?go="setUserInfo"'
  130. })
  131. // 手机号已授权
  132. } else {
  133. wx.navigateTo({
  134. url: '/pages3/setUserInfo/index',
  135. })
  136. }
  137. },
  138. //获取优选导航
  139. getBusinessList() {
  140. Http.get({
  141. url: config.api.businessList,
  142. data: {
  143. filter: 2
  144. }
  145. }).then(res => {
  146. this.setData({
  147. businessList: [{
  148. id: 0,
  149. title: "全部",
  150. type: 1
  151. }].concat(res.data)
  152. });
  153. }).catch(err => {
  154. wx.showModal({
  155. title: '提示',
  156. content: err.message ? err.message : err.data,
  157. showCancel: false
  158. })
  159. })
  160. },
  161. getCouponChannelList(key) {
  162. if (this.data.noDataFlag) {
  163. return
  164. }
  165. wx.showLoading({
  166. title: "加载中"
  167. });
  168. let param = {}
  169. if (key == 0) {
  170. param = {
  171. pageNum: this.data.businePageNum,
  172. pageSize: 6,
  173. targetAd: 1
  174. }
  175. } else {
  176. param = {
  177. pageNum: this.data.businePageNum,
  178. pageSize: 6,
  179. business: key,
  180. targetAd: 1
  181. }
  182. }
  183. Http.get({
  184. url: config.api.couponChannelList,
  185. data: param
  186. }).then(res => {
  187. if (res.data.list && res.data.list.length != 0) {
  188. let tempLsit = this.data.businessData
  189. let data = res.data.list
  190. data.map(item => {
  191. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  192. let str = item.salePriceStr.split('.')
  193. item.salePriceStrQ = str[0]
  194. item.salePriceStrH = str[1]
  195. }
  196. item.sale = item.inventory - item.remainInventory
  197. })
  198. if (this.data.businePageNum > 1) {
  199. this.setData({
  200. businessData: [...tempLsit, ...data]
  201. })
  202. } else {
  203. this.setData({
  204. businessData: data
  205. })
  206. }
  207. } else {
  208. this.setData({
  209. noDataFlag: true
  210. })
  211. }
  212. wx.hideLoading();
  213. }).catch(err => {
  214. wx.hideLoading();
  215. wx.showModal({
  216. title: '提示',
  217. content: err.message ? err.message : err.data,
  218. showCancel: false
  219. })
  220. })
  221. },
  222. goPage(e) {
  223. let obj = e.currentTarget.dataset.obj
  224. console.log(obj, "obj")
  225. if (obj.linkType == 1) {
  226. if (obj.linkUrl == "/pages/game/index") {
  227. this.gotogame()
  228. } else {
  229. wx.navigateTo({
  230. url: obj.linkUrl,
  231. })
  232. }
  233. //小程序内部跳转
  234. } else if (obj.linkType == 2) {
  235. //跳转到外部小程序
  236. wx.navigateToMiniProgram({
  237. appId: obj.outLinkAppid,
  238. path: obj.linkUrl ? obj.linkUrl : '',
  239. fail: err => {
  240. wx.showModal({
  241. title: '提示',
  242. content: err,
  243. showCancel: false
  244. })
  245. }
  246. })
  247. }
  248. },
  249. //获取按钮列表
  250. getModule() {
  251. Http.get({
  252. url: config.api.wxCustomizeModule
  253. }).then(res => {
  254. this.setData({
  255. moduleList: res.data,
  256. })
  257. }).catch(err => {
  258. if (err.status != 404)
  259. wx.showModal({
  260. title: '提示',
  261. content: err.message ? err.message : err.data,
  262. showCancel: false
  263. })
  264. })
  265. },
  266. //判断用户是否授权
  267. uesrInfo() {
  268. Http.get({
  269. url: config.api.checkUserStatus,
  270. data: {
  271. token: app.globalData.token
  272. }
  273. }).then(res => {
  274. Http.get({
  275. url: config.api.checkPhoneStatus
  276. }).then(res => { //全部授权
  277. this.setData({
  278. accreditFlag: 3
  279. })
  280. }).catch(err => {
  281. if (err.code == 11005) { //未授权手机号
  282. this.setData({
  283. accreditFlag: 2
  284. })
  285. } else {
  286. wx.showToast({
  287. title: err.message,
  288. icon: 'none',
  289. duration: 2000,
  290. mask: false
  291. });
  292. }
  293. })
  294. }).catch(err => {
  295. if (err.code == 11004) { //未授权微信
  296. this.setData({
  297. accreditFlag: 1
  298. })
  299. } else {
  300. wx.showToast({
  301. title: err.message,
  302. icon: 'none',
  303. duration: 2000,
  304. mask: false
  305. });
  306. }
  307. })
  308. },
  309. //获取当前广场名
  310. //跳转到每日签到
  311. goSign() {
  312. wx.navigateTo({
  313. url: '/pages/activityCalendar/activityCalendar',
  314. })
  315. },
  316. //活动日历
  317. goCalendar() {
  318. wx.navigateTo({
  319. url: '/pages/dateLsit/dateLsit',
  320. })
  321. },
  322. //跳转到其他广场列表
  323. goSquareList() {
  324. if (this.data.isShowSqare) {
  325. wx.navigateTo({
  326. url: '/pages/location/location',
  327. })
  328. }
  329. },
  330. goLive() {
  331. wx.navigateTo({
  332. url: '/pages2/live/livelist/index',
  333. })
  334. },
  335. alphaClick1: function (even) {
  336. var animation = wx.createAnimation({})
  337. animation.opacity(0).step({
  338. duration: 2000
  339. })
  340. this.setData({
  341. alphaData: animation.export()
  342. })
  343. },
  344. alphaClick: function (even) {
  345. var animation = wx.createAnimation({})
  346. animation.opacity(0).step({
  347. duration: 2000
  348. })
  349. this.setData({
  350. alphaData1: animation.export()
  351. })
  352. },
  353. // 我的卡包
  354. mycard: function () {
  355. wx.navigateTo({
  356. url: '/pages/cardorder/index/index',
  357. })
  358. },
  359. //我的券包
  360. mycoupon: function () {
  361. wx.navigateTo({
  362. url: '/pages/couponorder/index/index',
  363. })
  364. },
  365. gotoSpellGroup: function () {
  366. wx.navigateTo({
  367. url: '/pages/spellGroup/spellGroup',
  368. })
  369. },
  370. qrcode: function () {
  371. var that = this;
  372. let memberId = that.data.memberId;
  373. if (memberId) {
  374. wx.navigateTo({
  375. url: '/pages/specialcourtesy/specialcourtesy'
  376. })
  377. }
  378. },
  379. //跳往限时秒杀
  380. gotoRushBuy: function () {
  381. wx.navigateTo({
  382. url: '/pages/rushToBuy/index',
  383. })
  384. },
  385. swiperChange: function (e) {
  386. this.setData({
  387. swiperCurrent: e.detail.current
  388. });
  389. },
  390. gotogame: function () {
  391. let that = this;
  392. if (!that.data.showIf) {
  393. wx.showToast({
  394. title: '暂无游戏频道',
  395. icon: "none",
  396. duration: 3000
  397. })
  398. } else {
  399. Http.get({
  400. url: config.api.checkUserStatus,
  401. data: {
  402. token: app.globalData.token
  403. }
  404. }).then(res1 => {
  405. app.globalData.type = 'gm'
  406. Http.get({
  407. url: config.api.checkPhoneStatus,
  408. data: {}
  409. }).then(res => {
  410. var data = {
  411. couponChannelId: "" + that.data.couponChannelId,
  412. couponId: "" + that.data.couponId
  413. };
  414. if (that.data.couponChannelId == null) {
  415. var data = {
  416. couponId: "" + that.data.couponId
  417. };
  418. }
  419. wx.redirectTo({
  420. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  421. })
  422. }).catch(err => {
  423. if (err.code == 11005) {
  424. // 用户手机未授权
  425. /**
  426. * 将值传到用户手机号授权的页面
  427. *
  428. */
  429. app.globalData.skipUrl = '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  430. app.globalData.skip = 'redirectTo'
  431. wx.redirectTo({
  432. url: "/pages/getphoneInfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  433. });
  434. } else if (err.code == 11006) {
  435. // 用户手机已加密
  436. wx.redirectTo({
  437. url: "/pages/phoneinput/phoneinput?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  438. });
  439. } else {
  440. wx.showToast({
  441. title: err.message,
  442. icon: 'none',
  443. duration: 2000,
  444. mask: false
  445. });
  446. }
  447. })
  448. }).catch(err => {
  449. if (err.code == 11004) { //未授权微信
  450. app.globalData.type = 'gm'
  451. wx.redirectTo({
  452. url: "/pages/getuserinfo/index?path=index&url=" + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  453. });
  454. } else {
  455. wx.showToast({
  456. title: err.message,
  457. icon: 'none',
  458. duration: 2000,
  459. mask: false
  460. });
  461. }
  462. })
  463. }
  464. },
  465. mySpecial: function () {
  466. console.log("special");
  467. wx.navigateTo({
  468. url: '/pages/specialcourtesy/specialcourtesy',
  469. })
  470. },
  471. //是否属于集团
  472. ifShowSqare() {
  473. if (wx.getStorageSync("squareList")) {
  474. this.setData({
  475. isShowSqare: true
  476. })
  477. } else {
  478. this.setData({
  479. isShowSqare: false
  480. })
  481. }
  482. },
  483. /**
  484. * 获取全局样式
  485. */
  486. getType() {
  487. Http.get({
  488. url: config.api.setType,
  489. data: {
  490. mouldType: app.globalData.mouldType
  491. }
  492. }).then(res => {
  493. const {
  494. code,
  495. data
  496. } = res
  497. if (code == 200) {
  498. app.globalData.typeLsit = data
  499. this.setData({
  500. typeLsit: data,
  501. })
  502. }
  503. })
  504. },
  505. /**
  506. * 生命周期函数--监听页面初次渲染完成
  507. */
  508. onLoad: function (options) {
  509. console.log("onLoad--")
  510. this.setData({
  511. mouldType: app.globalData.mouldType,
  512. marketName: app.globalData.marketName,
  513. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  514. })
  515. let that = this;
  516. let optionss;
  517. //获取首页按钮
  518. that.getModule()
  519. let openId = wx.getStorageSync('openId')
  520. if (wx.getStorageSync('options')) {
  521. optionss = JSON.parse(wx.getStorageSync('options'));
  522. }
  523. if (options.played == "true") {
  524. that.setData({
  525. played: true
  526. })
  527. }
  528. if (optionss && optionss.couponChannelId || optionss && optionss.orderId) {
  529. that.setData({
  530. optionsData: optionss
  531. })
  532. that.getWeapNote(optionss.couponChannelId, optionss.orderId);
  533. } else {
  534. that.getWeapNote()
  535. }
  536. //获取条形码
  537. // util.barcode("barcode", optionss.quancode, 510, 100);
  538. // console.log(Http.headers.token, "?")
  539. },
  540. /**
  541. * 获得经纬度
  542. */
  543. // getLocation() {
  544. // let that = this;
  545. // wx.getLocation({
  546. // type: "wgs84",
  547. // success: function(res) {
  548. // console.log(res, 9999)
  549. // if (res && res.longitude && res.latitude) {
  550. // Http.post({
  551. // url: config.api.updateLBS,
  552. // data: {
  553. // latitude: res.latitude,
  554. // longitude: res.longitude
  555. // }
  556. // }).then(res => {
  557. // console.log(res, 9999)
  558. // })
  559. // }
  560. // },
  561. // fail: error => {
  562. // console.log(error);
  563. // }
  564. // })
  565. // },
  566. onUnload() {
  567. // wx.removeStorageSync('squareList')
  568. },
  569. // 初始换底部导航栏
  570. setTabStyle: function () {
  571. this.getTabBar().setData({
  572. selectedColor: `${app.globalData.styleLsit.t_in_std.styleClass}`,
  573. list: [{
  574. "pagePath": "/index/index",
  575. "iconPath": `${app.globalData.styleLsit.t_in.icon}`,
  576. "selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
  577. "text": "首页"
  578. },
  579. {
  580. "pagePath": "/index/searchbar",
  581. "iconPath": `${app.globalData.styleLsit.t_md.icon}`,
  582. "selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
  583. "text": "门店"
  584. },
  585. {
  586. "pagePath": "/index/passCar",
  587. "iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
  588. "selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
  589. "text": "停车"
  590. },
  591. {
  592. "pagePath": "/index/user",
  593. "iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
  594. "selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
  595. "text": "我的"
  596. }
  597. ],
  598. })
  599. },
  600. onShow: function () {
  601. console.log("onShow--")
  602. console.log(app.globalData.mouldType, "mouldType")
  603. if (app.globalData.token) {
  604. this.getmemberId(app.globalData.token);
  605. } else {
  606. app.tokenCallback = token => {
  607. this.getmemberId(app.globalData.token);
  608. }
  609. }
  610. this.setData({
  611. mouldType: app.globalData.mouldType,
  612. marketName: app.globalData.marketName,
  613. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  614. })
  615. this.uesrInfo()
  616. if (businessSwitch) {
  617. let openId = wx.getStorageSync("openId")
  618. this.setData({
  619. goUrl: `plugin://auto-points-plugin/index?openid=${openId}&mch_id=${this.data.mch_id}`
  620. })
  621. }
  622. if (JSON.stringify(app.globalData.styleLsit) != "{}") {
  623. this.setTabStyle()
  624. }
  625. this.ifShowSqare();
  626. if (wx.getStorageSync("squareList") && wx.getStorageSync("selectedMall")) {
  627. var temp = wx.getStorageSync("squareList").filter(item => item.tenantId == wx.getStorageSync("selectedMall"))[0].name
  628. this.setData({
  629. squareName: temp
  630. })
  631. }
  632. if (typeof this.getTabBar === 'function' &&
  633. this.getTabBar()) {
  634. this.getTabBar().setData({
  635. selected: 0,
  636. })
  637. }
  638. let that = this;
  639. that.setData({
  640. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  641. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  642. })
  643. /**
  644. * couponNum 是否有普通的优惠券购买
  645. * couponNum2 是否有新买的消费卡
  646. */
  647. let num = wx.getStorageSync('couponNum');
  648. let num1 = wx.getStorageSync('couponNum2');
  649. // if (num == 'couponNum' || num1 == 'couponNum2') {
  650. // wx.showTabBarRedDot({
  651. // index: 3
  652. // })
  653. // } else {
  654. // wx.hideTabBarRedDot({
  655. // index: 3
  656. // })
  657. // }
  658. if (app.globalData.score) {
  659. that.setData({
  660. fistLogin: app.globalData.score
  661. })
  662. }
  663. // 如果有游戏
  664. setTimeout(function () {
  665. that.alphaClick();
  666. }, 8000)
  667. // 如果有广告
  668. setTimeout(function () {
  669. that.alphaClick1();
  670. }, 8000)
  671. },
  672. getmemberId: function (token) {
  673. let that = this;
  674. Http.get({
  675. url: config.api.getScore,
  676. data: {
  677. token: token
  678. }
  679. }).then(res => {
  680. if (res.data.avatarUrl && res.data.nickName) {
  681. app.globalData.userAvatarUrl = res.data.avatarUrl,
  682. app.globalData.userName = res.data.nickName
  683. }
  684. that.setData({
  685. levelName: res.data.levelName,
  686. upgradePercent: res.data.upgradePercent,
  687. upgradeScore: res.data.upgradeScore,
  688. memberId: res.data.id,
  689. credit: res.data.credit,
  690. userAvatarUrl: res.data.avatarUrl,
  691. userName: res.data.nickName,
  692. })
  693. })
  694. .catch(err => {
  695. wx.showModal({
  696. title: '提示',
  697. content: err.message,
  698. showCancel: false
  699. })
  700. })
  701. },
  702. gotoChengzhangzhi: function () {
  703. wx.navigateTo({
  704. url: '/pages/czdetail/czdetail',
  705. })
  706. },
  707. goIntegralmall() {
  708. wx.navigateTo({
  709. url: '/pages/integralmall/index',
  710. })
  711. },
  712. gotoBargain: function () {
  713. wx.navigateTo({
  714. url: '/pages/bargain/bargain',
  715. })
  716. },
  717. gotoSpellGroup: function () {
  718. wx.navigateTo({
  719. url: '/pages/spellGroup/spellGroup',
  720. })
  721. },
  722. gotoCard: function () {
  723. wx.navigateTo({
  724. url: '/pages/discountCardList/discountCardList',
  725. })
  726. },
  727. // gotoGame: function () {
  728. // wx.navigateTo({
  729. // url: '/pages/game/index',
  730. // })
  731. // },
  732. gotoJfsc: function () {
  733. wx.navigateTo({
  734. url: '/pages/integralmall/index',
  735. })
  736. },
  737. /**
  738. *
  739. * @param {code,page}
  740. * 子组件向父组件传值
  741. */
  742. onGetCode: function (e) {
  743. this.setData({
  744. code: e.detail.val,
  745. page: e.detail.pageNum,
  746. });
  747. console.log(e.detail.val)
  748. console.log(e.detail.pageNum)
  749. },
  750. getWeapNote: function (couponChannelId, couponId, orderId) {
  751. var that = this;
  752. if (app.globalData.token) {
  753. // 登录
  754. console.log(app.globalData.token)
  755. that.getmemberId(app.globalData.token);
  756. that.getBannerlist();
  757. if (that.data.mouldType == 0) { //富茂原版
  758. that.topicShow();
  759. that.getxsList();
  760. } else if (that.data.mouldType == 1) { //欢乐城模板
  761. that.getShowList()
  762. that.topicShowall(2);
  763. that.topicShowall(3);
  764. that.topicShowall(4);
  765. that.topicShowall(5);
  766. that.topicShowall(6);
  767. that.getBusinessList();
  768. that.getCouponChannelList(0)
  769. }
  770. that.getType()
  771. // that.uesrInfo()
  772. // that.getLocation();
  773. that.getMallInfo(app.globalData.token);
  774. if (app.couponChannelListCallback) {
  775. app.couponChannelListCallback(app.globalData.token);
  776. }
  777. if (app.couponListCallback) {
  778. app.couponListCallback(app.globalData.token);
  779. }
  780. if (app.businessListCallback) {
  781. app.businessListCallback(app.globalData.token);
  782. }
  783. Http.get({
  784. url: config.api.getWeapNote,
  785. data: {
  786. appId: config.weapp.AppId,
  787. }
  788. })
  789. .then(res => {
  790. console.log(33333333333)
  791. console.log(app.globalData.token)
  792. console.log(res)
  793. console.log(33333333333)
  794. // that.getGameOne(app.globalData.token)
  795. that.getStaticGame(app.globalData.token)
  796. that.getGg(app.globalData.token)
  797. let weapNote = JSON.parse(res.data.weapNote);
  798. that.setData({
  799. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  800. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  801. })
  802. })
  803. .catch(err => {
  804. // that.getGameOne(app.globalData.token)
  805. that.getStaticGame(app.globalData.token)
  806. that.getGg(app.globalData.token)
  807. wx.showModal({
  808. title: "提示",
  809. content: err.message,
  810. showCancel: false
  811. });
  812. });
  813. } else {
  814. app.tokenCallback = token => {
  815. // 登录
  816. console.log(app.globalData.token)
  817. that.getmemberId(app.globalData.token);
  818. that.getBannerlist();
  819. if (that.data.mouldType == 0) { //富茂原版
  820. that.topicShow();
  821. that.getxsList();
  822. } else if (that.data.mouldType == 1) { //欢乐城模板
  823. that.getShowList()
  824. that.topicShowall(2);
  825. that.topicShowall(3);
  826. that.topicShowall(4);
  827. that.topicShowall(5);
  828. that.topicShowall(6);
  829. that.getBusinessList();
  830. that.getCouponChannelList(0)
  831. }
  832. that.getType()
  833. // that.uesrInfo()
  834. // that.getLocation();
  835. that.getMallInfo(app.globalData.token);
  836. if (app.couponChannelListCallback) {
  837. app.couponChannelListCallback(app.globalData.token);
  838. }
  839. if (app.couponListCallback) {
  840. app.couponListCallback(app.globalData.token);
  841. }
  842. if (app.businessListCallback) {
  843. app.businessListCallback(app.globalData.token);
  844. }
  845. Http.get({
  846. url: config.api.getWeapNote,
  847. data: {
  848. appId: config.weapp.AppId,
  849. }
  850. })
  851. .then(res => {
  852. console.log(33333333333)
  853. console.log(app.globalData.token)
  854. console.log(res)
  855. console.log(33333333333)
  856. // that.getGameOne(app.globalData.token)
  857. that.getStaticGame(app.globalData.token)
  858. that.getGg(app.globalData.token)
  859. let weapNote = JSON.parse(res.data.weapNote);
  860. that.setData({
  861. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  862. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  863. })
  864. })
  865. .catch(err => {
  866. // that.getGameOne(app.globalData.token)
  867. that.getStaticGame(app.globalData.token)
  868. that.getGg(app.globalData.token)
  869. wx.showModal({
  870. title: "提示",
  871. content: err.message,
  872. showCancel: false
  873. });
  874. });
  875. }
  876. }
  877. },
  878. getStaticGame(token) {
  879. let _this = this;
  880. Http.get({
  881. url: config.api.getGame,
  882. data: {
  883. triggleAction: 2, // 固定入口
  884. token: token
  885. }
  886. }).then(res => {
  887. if (res.data.id) {
  888. _this.setData({
  889. showIf: true,
  890. newUrl: res.data.imgUrl
  891. })
  892. } else {
  893. _this.setData({
  894. showIf: false
  895. })
  896. }
  897. _this.setData({
  898. staticGamedata: res.data
  899. })
  900. })
  901. .catch(err => {
  902. _this.setData({
  903. showIf: false
  904. })
  905. console.log(err)
  906. })
  907. },
  908. getGameOne: function (token) {
  909. let _this = this;
  910. Http.get({
  911. url: config.api.getGame,
  912. data: {
  913. triggleAction: 1, // 登录触发
  914. token: token
  915. }
  916. }).then(res => {
  917. if (res.data.id) {
  918. _this.setData({
  919. showGame: true,
  920. })
  921. } else {
  922. _this.setData({
  923. showGame: false
  924. })
  925. }
  926. _this.setData({
  927. gamedata: res.data
  928. })
  929. })
  930. .catch(err => {
  931. _this.setData({
  932. showGame: false
  933. })
  934. this.alphaClick();
  935. })
  936. },
  937. /**
  938. * mallinfo
  939. */
  940. getMallInfo: function (token) {
  941. let that = this;
  942. Http.get({
  943. url: config.api.getMallInfo,
  944. data: {
  945. token: token,
  946. }
  947. }).then(res => {
  948. that.setData({
  949. liveFlag: res.data.liveSupport,
  950. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  951. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  952. });
  953. console.log(that.data.liveFlag, "||||")
  954. })
  955. .catch(err => {
  956. // 不需要错误提示
  957. });
  958. },
  959. //获取限时抢购列表
  960. getxsList() {
  961. let that = this;
  962. Http.get({
  963. url: config.api.couponChannelList,
  964. data: {
  965. pageNum: 1,
  966. pageSize: 3,
  967. targetAd: 2
  968. }
  969. }).then(res => {
  970. if (res && res.data.total > 0) {
  971. that.setData({
  972. xslist: res.data.list,
  973. showQg: true
  974. });
  975. } else {
  976. that.setData({
  977. showQg: false
  978. })
  979. }
  980. })
  981. .catch(err => {
  982. console.log(err)
  983. wx.showToast({
  984. title: err.message,
  985. icon: 'none',
  986. duration: 2000,
  987. mask: false
  988. });
  989. })
  990. },
  991. /**
  992. * banner
  993. */
  994. getBannerlist: function () {
  995. let that = this;
  996. Http.get({
  997. url: config.api.bannerlist,
  998. data: {
  999. pageNum: 1,
  1000. pageSize: 7
  1001. }
  1002. }).then(res => {
  1003. that.getmemberId(app.globalData.token);
  1004. // that.checkUserCarStatus();
  1005. that.setData({
  1006. list: res.data.list
  1007. });
  1008. })
  1009. .catch(err => {
  1010. that.getmemberId(app.globalData.token);
  1011. // that.checkUserCarStatus();
  1012. });
  1013. },
  1014. //获取欢乐城专题
  1015. getShowList() {
  1016. Http.get({
  1017. url: config.api.showList
  1018. }).then(res => {
  1019. let tempData = res.data
  1020. tempData.map(item1 => {
  1021. if (item1.couponList) {
  1022. item1.couponList.map(item2 => {
  1023. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  1024. let str = item2.salePriceStr.split('.')
  1025. item2.salePriceStrQ = str[0]
  1026. item2.salePriceStrH = str[1]
  1027. }
  1028. })
  1029. }
  1030. })
  1031. this.setData({
  1032. specialLsit: res.data ? res.data : []
  1033. })
  1034. }).catch(err => {
  1035. wx.showToast({
  1036. title: err.message ? err.message : err.data,
  1037. icon: 'none',
  1038. duration: 2000,
  1039. mask: false
  1040. });
  1041. })
  1042. },
  1043. /**
  1044. * topicType=2 限时抢购
  1045. * topicType=3 砍价
  1046. * topicType=4 拼团
  1047. * topicType=5 消费卡
  1048. * topicType=6 积分商城
  1049. */
  1050. topicShowall(topicType) {
  1051. Http.get({
  1052. url: config.api.topicShow,
  1053. data: {
  1054. topicType
  1055. }
  1056. }).then(res => {
  1057. let data = res.data
  1058. if (data.couponList != null && data.couponList.length > 0) {
  1059. data.couponList.map(item => {
  1060. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1061. let str = item.salePriceStr.split('.')
  1062. item.salePriceStrQ = str[0]
  1063. item.salePriceStrH = str[1]
  1064. }
  1065. })
  1066. }
  1067. if (topicType == 2) {
  1068. let tempData = data
  1069. this.setData({
  1070. topicObj2: data
  1071. })
  1072. } else if (topicType == 3) {
  1073. this.setData({
  1074. topicObj3: data
  1075. })
  1076. } else if (topicType == 4) {
  1077. this.setData({
  1078. topicObj4: data
  1079. })
  1080. } else if (topicType == 5) {
  1081. this.setData({
  1082. topicObj5: data
  1083. })
  1084. } else if (topicType == 6) {
  1085. this.setData({
  1086. topicObj6: data
  1087. })
  1088. }
  1089. }).catch(err => {
  1090. wx.showToast({
  1091. title: err.message ? err.message : err.data,
  1092. icon: 'none',
  1093. duration: 2000,
  1094. mask: false
  1095. });
  1096. })
  1097. },
  1098. // 专题显示
  1099. topicShow: function () {
  1100. let that = this;
  1101. Http.get({
  1102. url: config.api.topicShow,
  1103. data: {
  1104. token: app.globalData.token
  1105. }
  1106. }).then(res => {
  1107. if (res && res.data) {
  1108. that.setData({
  1109. name: res.data.name,
  1110. cover: res.data.cover,
  1111. id: res.data.id,
  1112. showTopic: true
  1113. })
  1114. } else {
  1115. that.setData({
  1116. showTopic: false
  1117. })
  1118. }
  1119. })
  1120. .catch(err => {
  1121. console.log(err);
  1122. })
  1123. },
  1124. gotoTopic() {
  1125. wx.navigateTo({
  1126. url: `/pages/topicDetail/index?id=${this.data.id}`
  1127. })
  1128. },
  1129. /**
  1130. * 检查用户是否有车
  1131. */
  1132. // checkUserCarStatus: function() {
  1133. // var that = this;
  1134. // Http.get({
  1135. // url: config.api.userCarCount,
  1136. // data: {}
  1137. // }).then(res => {
  1138. // if (res.data > 0) {
  1139. // // 用户名下有车
  1140. // app.globalData.phone = res.data.phone;
  1141. // app.globalData.supportCar = true;
  1142. // // 共同登录
  1143. // that.userCarLogin();
  1144. // }
  1145. // });
  1146. // },
  1147. /**
  1148. * car共同登录
  1149. */
  1150. // userCarLogin: function() {
  1151. // var that = this;
  1152. // if (!app.globalData.carLogin) {
  1153. // // 共同登录
  1154. // Http.post({
  1155. // url: config.api.carInit,
  1156. // data: {
  1157. // phone: app.globalData.phone
  1158. // }
  1159. // }).then(res => {
  1160. // app.globalData.carLogin = true;
  1161. // app.globalData.parkVendor = res.data.vendor;
  1162. // if (res.data.token != "undefined") {
  1163. // app.globalData.etcpToken = res.data.token;
  1164. // }
  1165. // });
  1166. // }
  1167. // },
  1168. /**
  1169. * 获取用户信息
  1170. */
  1171. // getUserInfo: function() {
  1172. // // 获取用户信息
  1173. // wx.getSetting({
  1174. // success: res => {
  1175. // if (res.authSetting["scope.userInfo"]) {
  1176. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1177. // wx.getUserInfo({
  1178. // success: res => {
  1179. // // 可以将 res 发送给后台解码出 unionId
  1180. // }
  1181. // });
  1182. // }
  1183. // }
  1184. // });
  1185. // },
  1186. gotoBargain: function () {
  1187. wx.navigateTo({
  1188. url: '/pages/bargain/bargain'
  1189. })
  1190. },
  1191. //限时抢购的详情页面
  1192. gotodetail: function (e) {
  1193. wx.navigateTo({
  1194. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1195. }&couponId=${e.currentTarget.dataset.couponid}`
  1196. });
  1197. },
  1198. //浮层广告
  1199. getGg: function (token) {
  1200. let that = this
  1201. Http.get({
  1202. url: config.api.getGg,
  1203. data: {
  1204. token: token,
  1205. appId: config.weapp.AppId,
  1206. openId: "" // wx.getStorageSync('openId')
  1207. }
  1208. }).then(res => {
  1209. console.log(res)
  1210. if (res.data.id) {
  1211. that.setData({
  1212. showGg: true,
  1213. })
  1214. console.log(that.data.showGg, 1111111111111)
  1215. } else {
  1216. that.setData({
  1217. showGg: false
  1218. })
  1219. that.getGameOne(app.globalData.token)
  1220. console.log(that.data.showGg, 222222222222222222)
  1221. }
  1222. that.setData({
  1223. ggdata: res.data
  1224. })
  1225. })
  1226. .catch(err => {
  1227. this.setData({
  1228. showGg: false
  1229. })
  1230. that.getGameOne(app.globalData.token)
  1231. that.alphaClick1();
  1232. })
  1233. },
  1234. /**
  1235. * 刷新
  1236. */
  1237. onPullDownRefresh: function (e) {
  1238. this.setData({
  1239. topicObj2: null, //欢乐城首页限时抢购
  1240. topicObj3: null, //欢乐城首页砍价
  1241. topicObj4: null, //欢乐城首页拼团
  1242. topicObj5: null, //欢乐城首页消费卡
  1243. topicObj6: null, //欢乐城首页积分商城
  1244. })
  1245. let that = this;
  1246. // that.getWeapNote();
  1247. that.setData({
  1248. page: 1
  1249. })
  1250. if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) {
  1251. this.getWeapNote(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
  1252. } else {
  1253. this.getWeapNote()
  1254. }
  1255. if (that.selectComponent("#lists")) {
  1256. if (that.data.code == 0 || that.data.code == undefined) {
  1257. that.selectComponent("#lists").getList(0, 1, "refresh");
  1258. wx.stopPullDownRefresh();
  1259. } else {
  1260. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1261. wx.stopPullDownRefresh();
  1262. };
  1263. that.selectComponent("#hot").getList();
  1264. }
  1265. // 砍价下拉刷新
  1266. // that.selectComponent("#bargain").getList();
  1267. // that.selectComponent("#spellGroup").getList();
  1268. // that.selectComponent("#rushtobyCard").getList();
  1269. wx.stopPullDownRefresh();
  1270. //爆款专区下拉刷新
  1271. that.getxsList();
  1272. that.topicShow();
  1273. },
  1274. //加载更多
  1275. onReachBottom: function () {
  1276. console.log("我到底了")
  1277. let that = this;
  1278. that.data.page++;
  1279. that.setData({
  1280. page: that.data.page,
  1281. businePageNum: that.data.businePageNum + 1
  1282. });
  1283. console.log("加载更多页数" + that.data.page,);
  1284. console.log("加载更多key" + that.data.code);
  1285. if (that.data.mouldType == 0) { //富茂源模板
  1286. //父组件获得子组件的方法
  1287. //如果code == 0
  1288. if (that.data.code == 0 || that.data.code == undefined) {
  1289. that.selectComponent("#lists").getList(0, that.data.page);
  1290. } else {
  1291. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1292. }
  1293. } else if (that.data.mouldType == 1) {
  1294. this.getCouponChannelList(that.data.busineKye)
  1295. }
  1296. },
  1297. // 用户点击右上角分享
  1298. onShareAppMessage: function () {
  1299. app.globalData.previewFlag = true
  1300. return {
  1301. path: "/pages/index/index",
  1302. title: this.data.weappShareTitle,
  1303. imageUrl: this.data.weappShareCoverImg,
  1304. success: function (res) {
  1305. wx.showToast({
  1306. title: "分享成功",
  1307. duration: 1000,
  1308. icon: "success"
  1309. });
  1310. }
  1311. };
  1312. }
  1313. });