C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

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