抖音c端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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