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.

1358 lines
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 = 1 * 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. console.log(this.data.mch_id, 'this.data.mch_id');
  619. this.setData({
  620. goUrl: `plugin://auto-points-plugin/index?openid=${openId}&mch_id=${this.data.mch_id}&member_status=${1}`
  621. })
  622. } else {
  623. this.setData({
  624. goUrl: `plugin://auto-points-plugin/index?openid=${openId}&mch_id=${this.data.mch_id}`
  625. })
  626. }
  627. }
  628. console.log(JSON.stringify(app.globalData.styleLsit), "styleLsit")
  629. this.ifShowSqare();
  630. if (wx.getStorageSync("squareList") && wx.getStorageSync("selectedMall")) {
  631. var temp = wx.getStorageSync("squareList").filter(item => item.tenantId == wx.getStorageSync("selectedMall"))[0].name
  632. this.setData({
  633. squareName: temp
  634. })
  635. }
  636. if (typeof this.getTabBar === 'function' &&
  637. this.getTabBar()) {
  638. this.getTabBar().setData({
  639. selected: 0,
  640. })
  641. }
  642. let that = this;
  643. that.setData({
  644. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  645. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  646. })
  647. /**
  648. * couponNum 是否有普通的优惠券购买
  649. * couponNum2 是否有新买的消费卡
  650. */
  651. let num = wx.getStorageSync('couponNum');
  652. let num1 = wx.getStorageSync('couponNum2');
  653. // if (num == 'couponNum' || num1 == 'couponNum2') {
  654. // wx.showTabBarRedDot({
  655. // index: 3
  656. // })
  657. // } else {
  658. // wx.hideTabBarRedDot({
  659. // index: 3
  660. // })
  661. // }
  662. if (app.globalData.score) {
  663. that.setData({
  664. fistLogin: app.globalData.score
  665. })
  666. }
  667. // 如果有游戏
  668. setTimeout(function () {
  669. that.alphaClick();
  670. }, 8000)
  671. // 如果有广告
  672. setTimeout(function () {
  673. that.alphaClick1();
  674. }, 8000)
  675. },
  676. getmemberId: function (token) {
  677. let that = this;
  678. Http.get({
  679. url: config.api.getScore,
  680. data: {
  681. token: token
  682. }
  683. }).then(res => {
  684. if (res.data.avatarUrl && res.data.nickName) {
  685. app.globalData.userAvatarUrl = res.data.avatarUrl,
  686. app.globalData.userName = res.data.nickName
  687. }
  688. that.setData({
  689. levelName: res.data.levelName,
  690. upgradePercent: res.data.upgradePercent,
  691. upgradeScore: res.data.upgradeScore,
  692. memberId: res.data.id,
  693. credit: res.data.credit,
  694. userAvatarUrl: res.data.avatarUrl ? res.data.avatarUrl : '',
  695. userName: res.data.nickName ? res.data.nickName : '',
  696. })
  697. })
  698. .catch(err => {
  699. wx.showModal({
  700. title: '提示',
  701. content: err.message,
  702. showCancel: false
  703. })
  704. })
  705. },
  706. gotoChengzhangzhi: function () {
  707. wx.navigateTo({
  708. url: '/pages/czdetail/czdetail',
  709. })
  710. },
  711. goIntegralmall() {
  712. wx.navigateTo({
  713. url: '/pages/integralmall/index',
  714. })
  715. },
  716. gotoBargain: function () {
  717. wx.navigateTo({
  718. url: '/pages/bargain/bargain',
  719. })
  720. },
  721. gotoSpellGroup: function () {
  722. wx.navigateTo({
  723. url: '/pages/spellGroup/spellGroup',
  724. })
  725. },
  726. gotoCard: function () {
  727. wx.navigateTo({
  728. url: '/pages/discountCardList/discountCardList',
  729. })
  730. },
  731. // gotoGame: function () {
  732. // wx.navigateTo({
  733. // url: '/pages/game/index',
  734. // })
  735. // },
  736. gotoJfsc: function () {
  737. wx.navigateTo({
  738. url: '/pages/integralmall/index',
  739. })
  740. },
  741. /**
  742. *
  743. * @param {code,page}
  744. * 子组件向父组件传值
  745. */
  746. onGetCode: function (e) {
  747. this.setData({
  748. code: e.detail.val,
  749. page: e.detail.pageNum,
  750. });
  751. console.log(e.detail.val)
  752. console.log(e.detail.pageNum)
  753. },
  754. getWeapNote: function (couponChannelId, couponId, orderId) {
  755. var that = this;
  756. if (app.globalData.token) {
  757. // 登录
  758. that.setTabStyle()
  759. that.getmemberId(app.globalData.token);
  760. that.getBannerlist();
  761. if (that.data.mouldType == 0) { //富茂原版
  762. that.topicShow();
  763. that.getxsList();
  764. } else if (that.data.mouldType == 1) { //欢乐城模板
  765. that.getShowList()
  766. that.topicShowall(2);
  767. that.topicShowall(3);
  768. that.topicShowall(4);
  769. that.topicShowall(5);
  770. that.topicShowall(6);
  771. that.getBusinessList();
  772. that.getCouponChannelList(0)
  773. }
  774. that.getType()
  775. // that.uesrInfo()
  776. // that.getLocation();
  777. that.getMallInfo(app.globalData.token);
  778. if (app.couponChannelListCallback) {
  779. app.couponChannelListCallback(app.globalData.token);
  780. }
  781. if (app.couponListCallback) {
  782. app.couponListCallback(app.globalData.token);
  783. }
  784. if (app.businessListCallback) {
  785. app.businessListCallback(app.globalData.token);
  786. }
  787. Http.get({
  788. url: config.api.getWeapNote,
  789. data: {
  790. appId: config.weapp.AppId,
  791. }
  792. })
  793. .then(res => {
  794. console.log(33333333333)
  795. console.log(app.globalData.token)
  796. console.log(res)
  797. console.log(33333333333)
  798. // that.getGameOne(app.globalData.token)
  799. that.getStaticGame(app.globalData.token)
  800. that.getGg(app.globalData.token)
  801. let weapNote = JSON.parse(res.data.weapNote);
  802. that.setData({
  803. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  804. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  805. })
  806. })
  807. .catch(err => {
  808. // that.getGameOne(app.globalData.token)
  809. that.getStaticGame(app.globalData.token)
  810. that.getGg(app.globalData.token)
  811. wx.showModal({
  812. title: "提示",
  813. content: err.message,
  814. showCancel: false
  815. });
  816. });
  817. } else {
  818. app.tokenCallback = token => {
  819. // 登录
  820. that.setTabStyle()
  821. that.getmemberId(app.globalData.token);
  822. that.getBannerlist();
  823. if (that.data.mouldType == 0) { //富茂原版
  824. that.topicShow();
  825. that.getxsList();
  826. } else if (that.data.mouldType == 1) { //欢乐城模板
  827. that.getShowList()
  828. that.topicShowall(2);
  829. that.topicShowall(3);
  830. that.topicShowall(4);
  831. that.topicShowall(5);
  832. that.topicShowall(6);
  833. that.getBusinessList();
  834. that.getCouponChannelList(0)
  835. }
  836. that.getType()
  837. // that.uesrInfo()
  838. // that.getLocation();
  839. that.getMallInfo(app.globalData.token);
  840. if (app.couponChannelListCallback) {
  841. app.couponChannelListCallback(app.globalData.token);
  842. }
  843. if (app.couponListCallback) {
  844. app.couponListCallback(app.globalData.token);
  845. }
  846. if (app.businessListCallback) {
  847. app.businessListCallback(app.globalData.token);
  848. }
  849. Http.get({
  850. url: config.api.getWeapNote,
  851. data: {
  852. appId: config.weapp.AppId,
  853. }
  854. })
  855. .then(res => {
  856. console.log(33333333333)
  857. console.log(app.globalData.token)
  858. console.log(res)
  859. console.log(33333333333)
  860. // that.getGameOne(app.globalData.token)
  861. that.getStaticGame(app.globalData.token)
  862. that.getGg(app.globalData.token)
  863. let weapNote = JSON.parse(res.data.weapNote);
  864. that.setData({
  865. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  866. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  867. })
  868. })
  869. .catch(err => {
  870. // that.getGameOne(app.globalData.token)
  871. that.getStaticGame(app.globalData.token)
  872. that.getGg(app.globalData.token)
  873. wx.showModal({
  874. title: "提示",
  875. content: err.message,
  876. showCancel: false
  877. });
  878. });
  879. }
  880. }
  881. },
  882. getStaticGame(token) {
  883. let _this = this;
  884. Http.get({
  885. url: config.api.getGame,
  886. data: {
  887. triggleAction: 2, // 固定入口
  888. token: token
  889. }
  890. }).then(res => {
  891. if (res.data.id) {
  892. _this.setData({
  893. showIf: true,
  894. newUrl: res.data.imgUrl
  895. })
  896. } else {
  897. _this.setData({
  898. showIf: false
  899. })
  900. }
  901. _this.setData({
  902. staticGamedata: res.data
  903. })
  904. })
  905. .catch(err => {
  906. _this.setData({
  907. showIf: false
  908. })
  909. console.log(err)
  910. })
  911. },
  912. getGameOne: function (token) {
  913. let _this = this;
  914. Http.get({
  915. url: config.api.getGame,
  916. data: {
  917. triggleAction: 1, // 登录触发
  918. token: token
  919. }
  920. }).then(res => {
  921. if (res.data.id) {
  922. _this.setData({
  923. showGame: true,
  924. })
  925. } else {
  926. _this.setData({
  927. showGame: false
  928. })
  929. }
  930. _this.setData({
  931. gamedata: res.data
  932. })
  933. })
  934. .catch(err => {
  935. _this.setData({
  936. showGame: false
  937. })
  938. this.alphaClick();
  939. })
  940. },
  941. /**
  942. * mallinfo
  943. */
  944. getMallInfo: function (token) {
  945. let that = this;
  946. Http.get({
  947. url: config.api.getMallInfo,
  948. data: {
  949. token: token,
  950. }
  951. }).then(res => {
  952. that.setData({
  953. liveFlag: res.data.liveSupport,
  954. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  955. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  956. });
  957. console.log(that.data.liveFlag, "||||")
  958. })
  959. .catch(err => {
  960. // 不需要错误提示
  961. });
  962. },
  963. //获取限时抢购列表
  964. getxsList() {
  965. let that = this;
  966. Http.get({
  967. url: config.api.couponChannelList,
  968. data: {
  969. pageNum: 1,
  970. pageSize: 3,
  971. targetAd: 2
  972. }
  973. }).then(res => {
  974. if (res && res.data.total > 0) {
  975. that.setData({
  976. xslist: res.data.list,
  977. showQg: true
  978. });
  979. } else {
  980. that.setData({
  981. showQg: false
  982. })
  983. }
  984. })
  985. .catch(err => {
  986. console.log(err)
  987. wx.showToast({
  988. title: err.message,
  989. icon: 'none',
  990. duration: 2000,
  991. mask: false
  992. });
  993. })
  994. },
  995. /**
  996. * banner
  997. */
  998. getBannerlist: function () {
  999. let that = this;
  1000. Http.get({
  1001. url: config.api.bannerlist,
  1002. data: {
  1003. pageNum: 1,
  1004. pageSize: 7
  1005. }
  1006. }).then(res => {
  1007. that.getmemberId(app.globalData.token);
  1008. // that.checkUserCarStatus();
  1009. that.setData({
  1010. list: res.data.list
  1011. });
  1012. })
  1013. .catch(err => {
  1014. that.getmemberId(app.globalData.token);
  1015. // that.checkUserCarStatus();
  1016. });
  1017. },
  1018. //获取欢乐城专题
  1019. getShowList() {
  1020. Http.get({
  1021. url: config.api.showList
  1022. }).then(res => {
  1023. let tempData = res.data
  1024. tempData.map(item1 => {
  1025. if (item1.couponList) {
  1026. item1.couponList.map(item2 => {
  1027. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  1028. let str = item2.salePriceStr.split('.')
  1029. item2.salePriceStrQ = str[0]
  1030. item2.salePriceStrH = str[1]
  1031. }
  1032. })
  1033. }
  1034. })
  1035. this.setData({
  1036. specialLsit: res.data ? res.data : []
  1037. })
  1038. }).catch(err => {
  1039. wx.showToast({
  1040. title: err.message ? err.message : err.data,
  1041. icon: 'none',
  1042. duration: 2000,
  1043. mask: false
  1044. });
  1045. })
  1046. },
  1047. /**
  1048. * topicType=2 限时抢购
  1049. * topicType=3 砍价
  1050. * topicType=4 拼团
  1051. * topicType=5 消费卡
  1052. * topicType=6 积分商城
  1053. */
  1054. topicShowall(topicType) {
  1055. Http.get({
  1056. url: config.api.topicShow,
  1057. data: {
  1058. topicType
  1059. }
  1060. }).then(res => {
  1061. let data = res.data
  1062. if (data.couponList != null && data.couponList.length > 0) {
  1063. data.couponList.map(item => {
  1064. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1065. let str = item.salePriceStr.split('.')
  1066. item.salePriceStrQ = str[0]
  1067. item.salePriceStrH = str[1]
  1068. }
  1069. })
  1070. }
  1071. if (topicType == 2) {
  1072. let tempData = data
  1073. this.setData({
  1074. topicObj2: data
  1075. })
  1076. } else if (topicType == 3) {
  1077. this.setData({
  1078. topicObj3: data
  1079. })
  1080. } else if (topicType == 4) {
  1081. this.setData({
  1082. topicObj4: data
  1083. })
  1084. } else if (topicType == 5) {
  1085. this.setData({
  1086. topicObj5: data
  1087. })
  1088. } else if (topicType == 6) {
  1089. this.setData({
  1090. topicObj6: data
  1091. })
  1092. }
  1093. }).catch(err => {
  1094. wx.showToast({
  1095. title: err.message ? err.message : err.data,
  1096. icon: 'none',
  1097. duration: 2000,
  1098. mask: false
  1099. });
  1100. })
  1101. },
  1102. // 专题显示
  1103. topicShow: function () {
  1104. let that = this;
  1105. Http.get({
  1106. url: config.api.topicShow,
  1107. data: {
  1108. token: app.globalData.token
  1109. }
  1110. }).then(res => {
  1111. if (res && res.data) {
  1112. that.setData({
  1113. name: res.data.name,
  1114. cover: res.data.cover,
  1115. id: res.data.id,
  1116. showTopic: true
  1117. })
  1118. } else {
  1119. that.setData({
  1120. showTopic: false
  1121. })
  1122. }
  1123. })
  1124. .catch(err => {
  1125. console.log(err);
  1126. })
  1127. },
  1128. gotoTopic() {
  1129. wx.navigateTo({
  1130. url: `/pages/topicDetail/index?id=${this.data.id}`
  1131. })
  1132. },
  1133. /**
  1134. * 检查用户是否有车
  1135. */
  1136. // checkUserCarStatus: function() {
  1137. // var that = this;
  1138. // Http.get({
  1139. // url: config.api.userCarCount,
  1140. // data: {}
  1141. // }).then(res => {
  1142. // if (res.data > 0) {
  1143. // // 用户名下有车
  1144. // app.globalData.phone = res.data.phone;
  1145. // app.globalData.supportCar = true;
  1146. // // 共同登录
  1147. // that.userCarLogin();
  1148. // }
  1149. // });
  1150. // },
  1151. /**
  1152. * car共同登录
  1153. */
  1154. // userCarLogin: function() {
  1155. // var that = this;
  1156. // if (!app.globalData.carLogin) {
  1157. // // 共同登录
  1158. // Http.post({
  1159. // url: config.api.carInit,
  1160. // data: {
  1161. // phone: app.globalData.phone
  1162. // }
  1163. // }).then(res => {
  1164. // app.globalData.carLogin = true;
  1165. // app.globalData.parkVendor = res.data.vendor;
  1166. // if (res.data.token != "undefined") {
  1167. // app.globalData.etcpToken = res.data.token;
  1168. // }
  1169. // });
  1170. // }
  1171. // },
  1172. /**
  1173. * 获取用户信息
  1174. */
  1175. // getUserInfo: function() {
  1176. // // 获取用户信息
  1177. // wx.getSetting({
  1178. // success: res => {
  1179. // if (res.authSetting["scope.userInfo"]) {
  1180. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1181. // wx.getUserInfo({
  1182. // success: res => {
  1183. // // 可以将 res 发送给后台解码出 unionId
  1184. // }
  1185. // });
  1186. // }
  1187. // }
  1188. // });
  1189. // },
  1190. gotoBargain: function () {
  1191. wx.navigateTo({
  1192. url: '/pages/bargain/bargain'
  1193. })
  1194. },
  1195. //限时抢购的详情页面
  1196. gotodetail: function (e) {
  1197. wx.navigateTo({
  1198. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1199. }&couponId=${e.currentTarget.dataset.couponid}`
  1200. });
  1201. },
  1202. //浮层广告
  1203. getGg: function (token) {
  1204. let that = this
  1205. Http.get({
  1206. url: config.api.getGg,
  1207. data: {
  1208. token: token,
  1209. appId: config.weapp.AppId,
  1210. openId: "" // wx.getStorageSync('openId')
  1211. }
  1212. }).then(res => {
  1213. console.log(res)
  1214. if (res.data.id) {
  1215. that.setData({
  1216. showGg: true,
  1217. })
  1218. console.log(that.data.showGg, 1111111111111)
  1219. } else {
  1220. that.setData({
  1221. showGg: false
  1222. })
  1223. that.getGameOne(app.globalData.token)
  1224. console.log(that.data.showGg, 222222222222222222)
  1225. }
  1226. that.setData({
  1227. ggdata: res.data
  1228. })
  1229. })
  1230. .catch(err => {
  1231. this.setData({
  1232. showGg: false
  1233. })
  1234. that.getGameOne(app.globalData.token)
  1235. that.alphaClick1();
  1236. })
  1237. },
  1238. /**
  1239. * 刷新
  1240. */
  1241. onPullDownRefresh: function (e) {
  1242. this.setData({
  1243. topicObj2: null, //欢乐城首页限时抢购
  1244. topicObj3: null, //欢乐城首页砍价
  1245. topicObj4: null, //欢乐城首页拼团
  1246. topicObj5: null, //欢乐城首页消费卡
  1247. topicObj6: null, //欢乐城首页积分商城
  1248. })
  1249. let that = this;
  1250. // that.getWeapNote();
  1251. that.setData({
  1252. page: 1
  1253. })
  1254. if (this.data.optionsData != null && (this.data.optionsData.couponChannelId || this.data.optionsData.orderId)) {
  1255. this.getWeapNote(this.data.optionsData.couponChannelId, this.data.optionsData.orderId);
  1256. } else {
  1257. this.getWeapNote()
  1258. }
  1259. if (that.selectComponent("#lists")) {
  1260. if (that.data.code == 0 || that.data.code == undefined) {
  1261. that.selectComponent("#lists").getList(0, 1, "refresh");
  1262. wx.stopPullDownRefresh();
  1263. } else {
  1264. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1265. wx.stopPullDownRefresh();
  1266. };
  1267. that.selectComponent("#hot").getList();
  1268. }
  1269. // 砍价下拉刷新
  1270. // that.selectComponent("#bargain").getList();
  1271. // that.selectComponent("#spellGroup").getList();
  1272. // that.selectComponent("#rushtobyCard").getList();
  1273. wx.stopPullDownRefresh();
  1274. //爆款专区下拉刷新
  1275. that.getxsList();
  1276. that.topicShow();
  1277. },
  1278. //加载更多
  1279. onReachBottom: function () {
  1280. console.log("我到底了")
  1281. let that = this;
  1282. that.data.page++;
  1283. that.setData({
  1284. page: that.data.page,
  1285. businePageNum: that.data.businePageNum + 1
  1286. });
  1287. console.log("加载更多页数" + that.data.page);
  1288. console.log("加载更多key" + that.data.code);
  1289. if (that.data.mouldType == 0) { //富茂源模板
  1290. //父组件获得子组件的方法
  1291. //如果code == 0
  1292. if (that.data.code == 0 || that.data.code == undefined) {
  1293. that.selectComponent("#lists").getList(0, that.data.page);
  1294. } else {
  1295. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1296. }
  1297. } else if (that.data.mouldType == 1) {
  1298. this.getCouponChannelList(that.data.busineKye)
  1299. }
  1300. },
  1301. // 用户点击右上角分享
  1302. onShareAppMessage: function () {
  1303. app.globalData.previewFlag = true
  1304. return {
  1305. path: "/pages/index/index",
  1306. title: this.data.weappShareTitle,
  1307. imageUrl: this.data.weappShareCoverImg,
  1308. success: function (res) {
  1309. wx.showToast({
  1310. title: "分享成功",
  1311. duration: 1000,
  1312. icon: "success"
  1313. });
  1314. }
  1315. };
  1316. }
  1317. });