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

1343 lines
34 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. },
  531. /**
  532. * 获得经纬度
  533. */
  534. // getLocation() {
  535. // let that = this;
  536. // tt.getLocation({
  537. // type: "wgs84",
  538. // success: function(res) {
  539. // console.log(res, 9999)
  540. // if (res && res.longitude && res.latitude) {
  541. // Http.post({
  542. // url: config.api.updateLBS,
  543. // data: {
  544. // latitude: res.latitude,
  545. // longitude: res.longitude
  546. // }
  547. // }).then(res => {
  548. // console.log(res, 9999)
  549. // })
  550. // }
  551. // },
  552. // fail: error => {
  553. // console.log(error);
  554. // }
  555. // })
  556. // },
  557. onShow: function () {
  558. console.log(app.globalData.mouldType, "mouldType")
  559. // tt.requestSubscribeMessage({
  560. // tmplIds: [], // 需要填入开放平台申请的模版id,支持最多3个同类型模版
  561. // success(res) {
  562. // //订阅成功
  563. // console.log("订阅成功", res);
  564. // },
  565. // fail(error) {
  566. // //订阅失败
  567. // console.log("订阅失败, 错误详情: ", error);
  568. // tt.showToast({
  569. // title: "订阅失败",
  570. // icon: "fail",
  571. // });
  572. // },
  573. // complete(res) {
  574. // //订阅完成
  575. // console.log("tt.requestSubscribeMessage API调用完成: ", res);
  576. // },
  577. // });
  578. this.setData({
  579. mouldType: app.globalData.mouldType,
  580. marketName: app.globalData.marketName,
  581. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  582. })
  583. // this.uesrInfo()
  584. this.ifShowSqare();
  585. if (tt.getStorageSync("squareList") && tt.getStorageSync("selectedMall")) {
  586. var temp = tt.getStorageSync("squareList").filter(item => item.tenantId == tt.getStorageSync("selectedMall"))[0].name
  587. this.setData({
  588. squareName: temp
  589. })
  590. }
  591. if (typeof this.getTabBar === 'function' &&
  592. this.getTabBar()) {
  593. this.getTabBar().setData({
  594. selected: 0,
  595. })
  596. }
  597. let that = this;
  598. that.setData({
  599. havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false,
  600. havePlayEd1: app.globalData.havePlayEd1 ? app.globalData.havePlayEd1 : false
  601. })
  602. /**
  603. * couponNum 是否有普通的优惠券购买
  604. * couponNum2 是否有新买的消费卡
  605. */
  606. let num = tt.getStorageSync('couponNum');
  607. let num1 = tt.getStorageSync('couponNum2');
  608. // if (num == 'couponNum' || num1 == 'couponNum2') {
  609. // tt.showTabBarRedDot({
  610. // index: 3
  611. // })
  612. // } else {
  613. // tt.hideTabBarRedDot({
  614. // index: 3
  615. // })
  616. // }
  617. if (app.globalData.score) {
  618. that.setData({
  619. fistLogin: app.globalData.score
  620. })
  621. }
  622. // 如果有游戏
  623. setTimeout(function () {
  624. that.alphaClick();
  625. }, 8000)
  626. // 如果有广告
  627. setTimeout(function () {
  628. that.alphaClick1();
  629. }, 8000)
  630. },
  631. getmemberId: function (token) {
  632. let that = this;
  633. Http.get({
  634. url: config.api.getScore,
  635. data: {
  636. token: token
  637. }
  638. }).then(res => {
  639. if(res.data.avatarUrl||res.data.nickName){
  640. app.globalData.avatarUrl = res.data.avatarUrl
  641. app.globalData.nickName = res.data.nickName
  642. }
  643. that.setData({
  644. levelName: res.data.levelName,
  645. upgradePercent: res.data.upgradePercent,
  646. upgradeScore: res.data.upgradeScore,
  647. memberId: res.data.id,
  648. credit: res.data.credit,
  649. userAvatarUrl: res.data.avatarUrl ? res.data.avatarUrl:'',
  650. userName: res.data.nickName ? res.data.nickName:'',
  651. })
  652. })
  653. .catch(err => {
  654. tt.showModal({
  655. title: '提示',
  656. content: err.message,
  657. showCancel: false
  658. })
  659. })
  660. },
  661. gotoChengzhangzhi: function () {
  662. tt.navigateTo({
  663. url: '/pages/czdetail/czdetail',
  664. })
  665. },
  666. goIntegralmall() {
  667. tt.navigateTo({
  668. url: '/pages/integralmall/index',
  669. })
  670. },
  671. gotoBargain: function () {
  672. tt.navigateTo({
  673. url: '/pages/bargain/bargain',
  674. })
  675. },
  676. gotoSpellGroup: function () {
  677. tt.navigateTo({
  678. url: '/pages/spellGroup/spellGroup',
  679. })
  680. },
  681. gotoCard: function () {
  682. tt.navigateTo({
  683. url: '/pages/discountCardList/discountCardList',
  684. })
  685. },
  686. // gotoGame: function () {
  687. // tt.navigateTo({
  688. // url: '/pages/game/index',
  689. // })
  690. // },
  691. gotoJfsc: function () {
  692. tt.navigateTo({
  693. url: '/pages/integralmall/index',
  694. })
  695. },
  696. /**
  697. *
  698. * @param {code,page}
  699. * 子组件向父组件传值
  700. */
  701. onGetCode: function (e) {
  702. this.setData({
  703. code: e.detail.val,
  704. page: e.detail.pageNum,
  705. });
  706. console.log(e.detail.val)
  707. console.log(e.detail.pageNum)
  708. },
  709. getWeapNote: function (couponChannelId, couponId, orderId) {
  710. var that = this;
  711. if (app.globalData.token) {
  712. // 登录
  713. console.log(app.globalData.token)
  714. that.getCongig()//获取小程序是否开通授权手机号
  715. that.setData({
  716. mouldType: app.globalData.mouldType,
  717. marketName: app.globalData.marketName,
  718. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  719. })
  720. //获取首页按钮 抖音暂时屏蔽
  721. // that.getModule()
  722. that.getmemberId(app.globalData.token);
  723. that.getBannerlist();
  724. if (that.data.mouldType == 0) { //富茂原版
  725. that.topicShow();
  726. that.getxsList();
  727. } else if (that.data.mouldType == 1) { //欢乐城模板
  728. that.getShowList()
  729. that.topicShowall(2);
  730. that.topicShowall(3);
  731. that.topicShowall(4);
  732. that.topicShowall(5);
  733. that.topicShowall(6);
  734. that.getBusinessList();
  735. that.getCouponChannelList(0)
  736. }
  737. that.getType()
  738. that.uesrInfo()
  739. // that.getLocation();
  740. that.getMallInfo(app.globalData.token);
  741. if (app.couponChannelListCallback) {
  742. app.couponChannelListCallback(app.globalData.token);
  743. }
  744. if (app.couponListCallback) {
  745. app.couponListCallback(app.globalData.token);
  746. }
  747. if (app.businessListCallback) {
  748. app.businessListCallback(app.globalData.token);
  749. }
  750. Http.get({
  751. url: config.api.getWeapNote,
  752. data: {
  753. appId: app.globalData.appId,
  754. }
  755. })
  756. .then(res => {
  757. console.log(33333333333)
  758. console.log(app.globalData.token)
  759. console.log(res)
  760. console.log(33333333333)
  761. // that.getGameOne(app.globalData.token)
  762. // that.getStaticGame(app.globalData.token)
  763. that.getGg(app.globalData.token)
  764. let weapNote = JSON.parse(res.data.weapNote);
  765. that.setData({
  766. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  767. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  768. })
  769. })
  770. .catch(err => {
  771. // that.getGameOne(app.globalData.token)
  772. // that.getStaticGame(app.globalData.token)
  773. that.getGg(app.globalData.token)
  774. tt.showModal({
  775. title: "提示",
  776. content: err.message,
  777. showCancel: false
  778. });
  779. });
  780. } else {
  781. app.tokenCallback = token => {
  782. // 登录
  783. console.log(app.globalData.token)
  784. that.getCongig()//获取小程序是否开通授权手机号
  785. that.setData({
  786. mouldType: app.globalData.mouldType,
  787. marketName: app.globalData.marketName,
  788. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  789. })
  790. //获取首页按钮 抖音暂时屏蔽
  791. // that.getModule()
  792. that.getmemberId(app.globalData.token);
  793. that.getBannerlist();
  794. if (that.data.mouldType == 0) { //富茂原版
  795. that.topicShow();
  796. that.getxsList();
  797. } else if (that.data.mouldType == 1) { //欢乐城模板
  798. that.getShowList()
  799. that.topicShowall(2);
  800. that.topicShowall(3);
  801. that.topicShowall(4);
  802. that.topicShowall(5);
  803. that.topicShowall(6);
  804. that.getBusinessList();
  805. that.getCouponChannelList(0)
  806. }
  807. that.getType()
  808. that.uesrInfo()
  809. // that.getLocation();
  810. that.getMallInfo(app.globalData.token);
  811. if (app.couponChannelListCallback) {
  812. app.couponChannelListCallback(app.globalData.token);
  813. }
  814. if (app.couponListCallback) {
  815. app.couponListCallback(app.globalData.token);
  816. }
  817. if (app.businessListCallback) {
  818. app.businessListCallback(app.globalData.token);
  819. }
  820. Http.get({
  821. url: config.api.getWeapNote,
  822. data: {
  823. appId: app.globalData.appId,
  824. }
  825. })
  826. .then(res => {
  827. console.log(33333333333)
  828. console.log(app.globalData.token)
  829. console.log(res)
  830. console.log(33333333333)
  831. // that.getGameOne(app.globalData.token)
  832. // that.getStaticGame(app.globalData.token)
  833. that.getGg(app.globalData.token)
  834. let weapNote = JSON.parse(res.data.weapNote);
  835. that.setData({
  836. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  837. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  838. })
  839. })
  840. .catch(err => {
  841. // that.getGameOne(app.globalData.token)
  842. // that.getStaticGame(app.globalData.token)
  843. that.getGg(app.globalData.token)
  844. tt.showModal({
  845. title: "提示",
  846. content: err.message,
  847. showCancel: false
  848. });
  849. });
  850. }
  851. }
  852. },
  853. getStaticGame(token) {
  854. let _this = this;
  855. Http.get({
  856. url: config.api.getGame,
  857. data: {
  858. triggleAction: 2, // 固定入口
  859. token: token
  860. }
  861. }).then(res => {
  862. if (res.data.id) {
  863. _this.setData({
  864. showIf: true,
  865. newUrl: res.data.imgUrl
  866. })
  867. } else {
  868. _this.setData({
  869. showIf: false
  870. })
  871. }
  872. _this.setData({
  873. staticGamedata: res.data
  874. })
  875. })
  876. .catch(err => {
  877. _this.setData({
  878. showIf: false
  879. })
  880. console.log(err)
  881. })
  882. },
  883. getGameOne: function (token) {
  884. let _this = this;
  885. Http.get({
  886. url: config.api.getGame,
  887. data: {
  888. triggleAction: 1, // 登录触发
  889. token: token
  890. }
  891. }).then(res => {
  892. if (res.data.id) {
  893. _this.setData({
  894. showGame: true,
  895. })
  896. } else {
  897. _this.setData({
  898. showGame: false
  899. })
  900. }
  901. _this.setData({
  902. gamedata: res.data
  903. })
  904. })
  905. .catch(err => {
  906. _this.setData({
  907. showGame: false
  908. })
  909. this.alphaClick();
  910. })
  911. },
  912. /**
  913. * mallinfo
  914. */
  915. getMallInfo: function (token) {
  916. let that = this;
  917. Http.get({
  918. url: config.api.getMallInfo,
  919. data: {
  920. token: token,
  921. }
  922. }).then(res => {
  923. that.setData({
  924. liveFlag: res.data.liveSupport,
  925. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  926. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  927. });
  928. console.log(that.data.liveFlag, "||||")
  929. })
  930. .catch(err => {
  931. // 不需要错误提示
  932. });
  933. },
  934. //获取限时抢购列表
  935. getxsList() {
  936. let that = this;
  937. Http.get({
  938. url: config.api.couponChannelList,
  939. data: {
  940. pageNum: 1,
  941. pageSize: 3,
  942. targetAd: 2
  943. }
  944. }).then(res => {
  945. if (res && res.data.total > 0) {
  946. that.setData({
  947. xslist: res.data.list,
  948. showQg: true
  949. });
  950. } else {
  951. that.setData({
  952. showQg: false
  953. })
  954. }
  955. })
  956. .catch(err => {
  957. console.log(err)
  958. tt.showToast({
  959. title: err.message,
  960. icon: 'none',
  961. duration: 2000,
  962. mask: false
  963. });
  964. })
  965. },
  966. /**
  967. * banner
  968. */
  969. getBannerlist: function () {
  970. let that = this;
  971. Http.get({
  972. url: config.api.bannerlist,
  973. data: {
  974. pageNum: 1,
  975. pageSize: 7
  976. }
  977. }).then(res => {
  978. that.getmemberId(app.globalData.token);
  979. // that.checkUserCarStatus();
  980. that.setData({
  981. list: res.data.list
  982. });
  983. })
  984. .catch(err => {
  985. that.getmemberId(app.globalData.token);
  986. // that.checkUserCarStatus();
  987. });
  988. },
  989. //获取欢乐城专题
  990. getShowList() {
  991. Http.get({
  992. url: config.api.showList
  993. }).then(res => {
  994. let tempData = res.data
  995. tempData.map(item1 => {
  996. if (item1.couponList) {
  997. item1.couponList.map(item2 => {
  998. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  999. let str = item2.salePriceStr.split('.')
  1000. item2.salePriceStrQ = str[0]
  1001. item2.salePriceStrH = str[1]
  1002. }
  1003. })
  1004. }
  1005. })
  1006. this.setData({
  1007. specialLsit: res.data ? res.data : []
  1008. })
  1009. }).catch(err => {
  1010. tt.showToast({
  1011. title: err.message ? err.message : err.data,
  1012. icon: 'none',
  1013. duration: 2000,
  1014. mask: false
  1015. });
  1016. })
  1017. },
  1018. /**
  1019. * topicType=2 限时抢购
  1020. * topicType=3 砍价
  1021. * topicType=4 拼团
  1022. * topicType=5 消费卡
  1023. * topicType=6 积分商城
  1024. */
  1025. topicShowall(topicType) {
  1026. Http.get({
  1027. url: config.api.topicShow,
  1028. data: {
  1029. topicType
  1030. }
  1031. }).then(res => {
  1032. let data = res.data
  1033. if (data.couponList != null && data.couponList.length > 0) {
  1034. data.couponList.map(item => {
  1035. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1036. let str = item.salePriceStr.split('.')
  1037. item.salePriceStrQ = str[0]
  1038. item.salePriceStrH = str[1]
  1039. }
  1040. })
  1041. }
  1042. if (topicType == 2) {
  1043. let tempData = data
  1044. this.setData({
  1045. topicObj2: data
  1046. })
  1047. } else if (topicType == 3) {
  1048. this.setData({
  1049. topicObj3: data
  1050. })
  1051. } else if (topicType == 4) {
  1052. this.setData({
  1053. topicObj4: data
  1054. })
  1055. } else if (topicType == 5) {
  1056. this.setData({
  1057. topicObj5: data
  1058. })
  1059. } else if (topicType == 6) {
  1060. this.setData({
  1061. topicObj6: data
  1062. })
  1063. }
  1064. }).catch(err => {
  1065. tt.showToast({
  1066. title: err.message ? err.message : err.data,
  1067. icon: 'none',
  1068. duration: 2000,
  1069. mask: false
  1070. });
  1071. })
  1072. },
  1073. // 专题显示
  1074. topicShow: function () {
  1075. let that = this;
  1076. Http.get({
  1077. url: config.api.topicShow,
  1078. data: {
  1079. token: app.globalData.token
  1080. }
  1081. }).then(res => {
  1082. if (res && res.data) {
  1083. that.setData({
  1084. name: res.data.name,
  1085. cover: res.data.cover,
  1086. id: res.data.id,
  1087. showTopic: true
  1088. })
  1089. } else {
  1090. that.setData({
  1091. showTopic: false
  1092. })
  1093. }
  1094. })
  1095. .catch(err => {
  1096. console.log(err);
  1097. })
  1098. },
  1099. gotoTopic() {
  1100. tt.navigateTo({
  1101. url: `/pages/topicDetail/index?id=${this.data.id}`
  1102. })
  1103. },
  1104. /**
  1105. * 检查用户是否有车
  1106. */
  1107. // checkUserCarStatus: function() {
  1108. // var that = this;
  1109. // Http.get({
  1110. // url: config.api.userCarCount,
  1111. // data: {}
  1112. // }).then(res => {
  1113. // if (res.data > 0) {
  1114. // // 用户名下有车
  1115. // app.globalData.phone = res.data.phone;
  1116. // app.globalData.supportCar = true;
  1117. // // 共同登录
  1118. // that.userCarLogin();
  1119. // }
  1120. // });
  1121. // },
  1122. /**
  1123. * car共同登录
  1124. */
  1125. // userCarLogin: function() {
  1126. // var that = this;
  1127. // if (!app.globalData.carLogin) {
  1128. // // 共同登录
  1129. // Http.post({
  1130. // url: config.api.carInit,
  1131. // data: {
  1132. // phone: app.globalData.phone
  1133. // }
  1134. // }).then(res => {
  1135. // app.globalData.carLogin = true;
  1136. // app.globalData.parkVendor = res.data.vendor;
  1137. // if (res.data.token != "undefined") {
  1138. // app.globalData.etcpToken = res.data.token;
  1139. // }
  1140. // });
  1141. // }
  1142. // },
  1143. /**
  1144. * 获取用户信息
  1145. */
  1146. // getUserInfo: function() {
  1147. // // 获取用户信息
  1148. // tt.getSetting({
  1149. // success: res => {
  1150. // if (res.authSetting["scope.userInfo"]) {
  1151. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1152. // tt.getUserInfo({
  1153. // success: res => {
  1154. // // 可以将 res 发送给后台解码出 unionId
  1155. // }
  1156. // });
  1157. // }
  1158. // }
  1159. // });
  1160. // },
  1161. gotoBargain: function () {
  1162. tt.navigateTo({
  1163. url: '/pages/bargain/bargain'
  1164. })
  1165. },
  1166. //限时抢购的详情页面
  1167. gotodetail: function (e) {
  1168. tt.navigateTo({
  1169. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1170. }&couponId=${e.currentTarget.dataset.couponid}`
  1171. });
  1172. },
  1173. //浮层广告
  1174. getGg: function (token) {
  1175. let that = this
  1176. Http.get({
  1177. url: config.api.getGg,
  1178. data: {
  1179. token: token,
  1180. appId: app.globalData.appId,
  1181. openId: "" // tt.getStorageSync('openId')
  1182. }
  1183. }).then(res => {
  1184. console.log(res)
  1185. if (res.data.id) {
  1186. that.setData({
  1187. showGg: true,
  1188. })
  1189. console.log(that.data.showGg, 1111111111111)
  1190. } else {
  1191. that.setData({
  1192. showGg: false
  1193. })
  1194. // that.getGameOne(app.globalData.token)
  1195. console.log(that.data.showGg, 222222222222222222)
  1196. }
  1197. that.setData({
  1198. ggdata: res.data
  1199. })
  1200. })
  1201. .catch(err => {
  1202. this.setData({
  1203. showGg: false
  1204. })
  1205. // that.getGameOne(app.globalData.token)
  1206. that.alphaClick1();
  1207. })
  1208. },
  1209. /**
  1210. * 刷新
  1211. */
  1212. onPullDownRefresh: function (e) {
  1213. tt.showLoading({
  1214. title: "加载中..."
  1215. });
  1216. let that = this;
  1217. that.setData({
  1218. topicObj2: null, //欢乐城首页限时抢购
  1219. topicObj3: null, //欢乐城首页砍价
  1220. topicObj4: null, //欢乐城首页拼团
  1221. topicObj5: null, //欢乐城首页消费卡
  1222. topicObj6: null, //欢乐城首页积分商城
  1223. specialLsit: null,//专题
  1224. })
  1225. // that.getWeapNote();
  1226. that.setData({
  1227. page: 1
  1228. })
  1229. if (that.data.optionsData != null && (that.data.optionsData.couponChannelId || that.data.optionsData.orderId)) {
  1230. that.getWeapNote(that.data.optionsData.couponChannelId, that.data.optionsData.orderId);
  1231. } else {
  1232. that.getWeapNote()
  1233. }
  1234. if (that.selectComponent("#lists")) {
  1235. if (that.data.code == 0 || that.data.code == undefined) {
  1236. that.selectComponent("#lists").getList(0, 1, "refresh");
  1237. tt.stopPullDownRefresh();
  1238. } else {
  1239. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1240. tt.stopPullDownRefresh();
  1241. };
  1242. that.selectComponent("#hot").getList();
  1243. }
  1244. // 砍价下拉刷新
  1245. // that.selectComponent("#bargain").getList();
  1246. // that.selectComponent("#spellGroup").getList();
  1247. // that.selectComponent("#rushtobyCard").getList();
  1248. //爆款专区下拉刷新
  1249. that.getxsList();
  1250. that.topicShow();
  1251. setTimeout(function () {
  1252. tt.hideLoading();
  1253. tt.stopPullDownRefresh();
  1254. }, 1600);
  1255. },
  1256. //加载更多
  1257. onReachBottom: function () {
  1258. console.log("我到底了")
  1259. let that = this;
  1260. that.data.page++;
  1261. that.setData({
  1262. page: that.data.page,
  1263. businePageNum: that.data.businePageNum + 1
  1264. });
  1265. console.log("加载更多页数" + that.data.page,);
  1266. console.log("加载更多key" + that.data.code);
  1267. if (that.data.mouldType == 0) { //富茂源模板
  1268. //父组件获得子组件的方法
  1269. //如果code == 0
  1270. if (that.data.code == 0 || that.data.code == undefined) {
  1271. that.selectComponent("#lists").getList(0, that.data.page);
  1272. } else {
  1273. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1274. }
  1275. } else if (that.data.mouldType == 1) {
  1276. this.getCouponChannelList(that.data.busineKye)
  1277. }
  1278. },
  1279. // 用户点击右上角分享
  1280. onShareAppMessage: function () {
  1281. app.globalData.previewFlag = true
  1282. return {
  1283. path: "/pages/index/index",
  1284. title: this.data.weappShareTitle,
  1285. imageUrl: this.data.weappShareCoverImg,
  1286. success: function (res) {
  1287. tt.showToast({
  1288. title: "分享成功",
  1289. duration: 1000,
  1290. icon: "success"
  1291. });
  1292. }
  1293. };
  1294. }
  1295. });