抖音c端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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