抖音c端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

1445 lignes
38 KiB

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