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.

1288 line
33 KiB

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