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.

1505 rivejä
39 KiB

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