C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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