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

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