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.

1356 lines
35 KiB

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