C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1357 řádky
35 KiB

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