C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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