C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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