抖音c端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

1344 rader
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. plat:3
  977. }
  978. }).then(res => {
  979. that.getmemberId(app.globalData.token);
  980. // that.checkUserCarStatus();
  981. that.setData({
  982. list: res.data.list
  983. });
  984. })
  985. .catch(err => {
  986. that.getmemberId(app.globalData.token);
  987. // that.checkUserCarStatus();
  988. });
  989. },
  990. //获取欢乐城专题
  991. getShowList() {
  992. Http.get({
  993. url: config.api.showList
  994. }).then(res => {
  995. let tempData = res.data
  996. tempData.map(item1 => {
  997. if (item1.couponList) {
  998. item1.couponList.map(item2 => {
  999. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  1000. let str = item2.salePriceStr.split('.')
  1001. item2.salePriceStrQ = str[0]
  1002. item2.salePriceStrH = str[1]
  1003. }
  1004. })
  1005. }
  1006. })
  1007. this.setData({
  1008. specialLsit: res.data ? res.data : []
  1009. })
  1010. }).catch(err => {
  1011. tt.showToast({
  1012. title: err.message ? err.message : err.data,
  1013. icon: 'none',
  1014. duration: 2000,
  1015. mask: false
  1016. });
  1017. })
  1018. },
  1019. /**
  1020. * topicType=2 限时抢购
  1021. * topicType=3 砍价
  1022. * topicType=4 拼团
  1023. * topicType=5 消费卡
  1024. * topicType=6 积分商城
  1025. */
  1026. topicShowall(topicType) {
  1027. Http.get({
  1028. url: config.api.topicShow,
  1029. data: {
  1030. topicType
  1031. }
  1032. }).then(res => {
  1033. let data = res.data
  1034. if (data.couponList != null && data.couponList.length > 0) {
  1035. data.couponList.map(item => {
  1036. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1037. let str = item.salePriceStr.split('.')
  1038. item.salePriceStrQ = str[0]
  1039. item.salePriceStrH = str[1]
  1040. }
  1041. })
  1042. }
  1043. if (topicType == 2) {
  1044. let tempData = data
  1045. this.setData({
  1046. topicObj2: data
  1047. })
  1048. } else if (topicType == 3) {
  1049. this.setData({
  1050. topicObj3: data
  1051. })
  1052. } else if (topicType == 4) {
  1053. this.setData({
  1054. topicObj4: data
  1055. })
  1056. } else if (topicType == 5) {
  1057. this.setData({
  1058. topicObj5: data
  1059. })
  1060. } else if (topicType == 6) {
  1061. this.setData({
  1062. topicObj6: data
  1063. })
  1064. }
  1065. }).catch(err => {
  1066. tt.showToast({
  1067. title: err.message ? err.message : err.data,
  1068. icon: 'none',
  1069. duration: 2000,
  1070. mask: false
  1071. });
  1072. })
  1073. },
  1074. // 专题显示
  1075. topicShow: function () {
  1076. let that = this;
  1077. Http.get({
  1078. url: config.api.topicShow,
  1079. data: {
  1080. token: app.globalData.token
  1081. }
  1082. }).then(res => {
  1083. if (res && res.data) {
  1084. that.setData({
  1085. name: res.data.name,
  1086. cover: res.data.cover,
  1087. id: res.data.id,
  1088. showTopic: true
  1089. })
  1090. } else {
  1091. that.setData({
  1092. showTopic: false
  1093. })
  1094. }
  1095. })
  1096. .catch(err => {
  1097. console.log(err);
  1098. })
  1099. },
  1100. gotoTopic() {
  1101. tt.navigateTo({
  1102. url: `/pages/topicDetail/index?id=${this.data.id}`
  1103. })
  1104. },
  1105. /**
  1106. * 检查用户是否有车
  1107. */
  1108. // checkUserCarStatus: function() {
  1109. // var that = this;
  1110. // Http.get({
  1111. // url: config.api.userCarCount,
  1112. // data: {}
  1113. // }).then(res => {
  1114. // if (res.data > 0) {
  1115. // // 用户名下有车
  1116. // app.globalData.phone = res.data.phone;
  1117. // app.globalData.supportCar = true;
  1118. // // 共同登录
  1119. // that.userCarLogin();
  1120. // }
  1121. // });
  1122. // },
  1123. /**
  1124. * car共同登录
  1125. */
  1126. // userCarLogin: function() {
  1127. // var that = this;
  1128. // if (!app.globalData.carLogin) {
  1129. // // 共同登录
  1130. // Http.post({
  1131. // url: config.api.carInit,
  1132. // data: {
  1133. // phone: app.globalData.phone
  1134. // }
  1135. // }).then(res => {
  1136. // app.globalData.carLogin = true;
  1137. // app.globalData.parkVendor = res.data.vendor;
  1138. // if (res.data.token != "undefined") {
  1139. // app.globalData.etcpToken = res.data.token;
  1140. // }
  1141. // });
  1142. // }
  1143. // },
  1144. /**
  1145. * 获取用户信息
  1146. */
  1147. // getUserInfo: function() {
  1148. // // 获取用户信息
  1149. // tt.getSetting({
  1150. // success: res => {
  1151. // if (res.authSetting["scope.userInfo"]) {
  1152. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1153. // tt.getUserInfo({
  1154. // success: res => {
  1155. // // 可以将 res 发送给后台解码出 unionId
  1156. // }
  1157. // });
  1158. // }
  1159. // }
  1160. // });
  1161. // },
  1162. gotoBargain: function () {
  1163. tt.navigateTo({
  1164. url: '/pages/bargain/bargain'
  1165. })
  1166. },
  1167. //限时抢购的详情页面
  1168. gotodetail: function (e) {
  1169. tt.navigateTo({
  1170. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1171. }&couponId=${e.currentTarget.dataset.couponid}`
  1172. });
  1173. },
  1174. //浮层广告
  1175. getGg: function (token) {
  1176. let that = this
  1177. Http.get({
  1178. url: config.api.getGg,
  1179. data: {
  1180. token: token,
  1181. appId: app.globalData.appId,
  1182. openId: "" // tt.getStorageSync('openId')
  1183. }
  1184. }).then(res => {
  1185. console.log(res)
  1186. if (res.data.id) {
  1187. that.setData({
  1188. showGg: true,
  1189. })
  1190. console.log(that.data.showGg, 1111111111111)
  1191. } else {
  1192. that.setData({
  1193. showGg: false
  1194. })
  1195. // that.getGameOne(app.globalData.token)
  1196. console.log(that.data.showGg, 222222222222222222)
  1197. }
  1198. that.setData({
  1199. ggdata: res.data
  1200. })
  1201. })
  1202. .catch(err => {
  1203. this.setData({
  1204. showGg: false
  1205. })
  1206. // that.getGameOne(app.globalData.token)
  1207. that.alphaClick1();
  1208. })
  1209. },
  1210. /**
  1211. * 刷新
  1212. */
  1213. onPullDownRefresh: function (e) {
  1214. tt.showLoading({
  1215. title: "加载中..."
  1216. });
  1217. let that = this;
  1218. that.setData({
  1219. topicObj2: null, //欢乐城首页限时抢购
  1220. topicObj3: null, //欢乐城首页砍价
  1221. topicObj4: null, //欢乐城首页拼团
  1222. topicObj5: null, //欢乐城首页消费卡
  1223. topicObj6: null, //欢乐城首页积分商城
  1224. specialLsit: null,//专题
  1225. })
  1226. // that.getWeapNote();
  1227. that.setData({
  1228. page: 1
  1229. })
  1230. if (that.data.optionsData != null && (that.data.optionsData.couponChannelId || that.data.optionsData.orderId)) {
  1231. that.getWeapNote(that.data.optionsData.couponChannelId, that.data.optionsData.orderId);
  1232. } else {
  1233. that.getWeapNote()
  1234. }
  1235. if (that.selectComponent("#lists")) {
  1236. if (that.data.code == 0 || that.data.code == undefined) {
  1237. that.selectComponent("#lists").getList(0, 1, "refresh");
  1238. tt.stopPullDownRefresh();
  1239. } else {
  1240. that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1241. tt.stopPullDownRefresh();
  1242. };
  1243. that.selectComponent("#hot").getList();
  1244. }
  1245. // 砍价下拉刷新
  1246. // that.selectComponent("#bargain").getList();
  1247. // that.selectComponent("#spellGroup").getList();
  1248. // that.selectComponent("#rushtobyCard").getList();
  1249. //爆款专区下拉刷新
  1250. that.getxsList();
  1251. that.topicShow();
  1252. setTimeout(function () {
  1253. tt.hideLoading();
  1254. tt.stopPullDownRefresh();
  1255. }, 1600);
  1256. },
  1257. //加载更多
  1258. onReachBottom: function () {
  1259. console.log("我到底了")
  1260. let that = this;
  1261. that.data.page++;
  1262. that.setData({
  1263. page: that.data.page,
  1264. businePageNum: that.data.businePageNum + 1
  1265. });
  1266. console.log("加载更多页数" + that.data.page,);
  1267. console.log("加载更多key" + that.data.code);
  1268. if (that.data.mouldType == 0) { //富茂源模板
  1269. //父组件获得子组件的方法
  1270. //如果code == 0
  1271. if (that.data.code == 0 || that.data.code == undefined) {
  1272. that.selectComponent("#lists").getList(0, that.data.page);
  1273. } else {
  1274. that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1275. }
  1276. } else if (that.data.mouldType == 1) {
  1277. this.getCouponChannelList(that.data.busineKye)
  1278. }
  1279. },
  1280. // 用户点击右上角分享
  1281. onShareAppMessage: function () {
  1282. app.globalData.previewFlag = true
  1283. return {
  1284. path: "/pages/index/index",
  1285. title: this.data.weappShareTitle,
  1286. imageUrl: this.data.weappShareCoverImg,
  1287. success: function (res) {
  1288. tt.showToast({
  1289. title: "分享成功",
  1290. duration: 1000,
  1291. icon: "success"
  1292. });
  1293. }
  1294. };
  1295. }
  1296. });