抖音c端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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