C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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