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

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