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

1377 行
36 KiB

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