抖音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.

1389 line
36 KiB

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