抖音c端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

1606 satır
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. },
  842. getmemberId: function (token) {
  843. let that = this;
  844. Http.get({
  845. url: config.api.getScore,
  846. data: {
  847. token: token
  848. }
  849. }).then(res => {
  850. if (res.data.avatarUrl || res.data.nickName) {
  851. app.globalData.avatarUrl = res.data.avatarUrl
  852. app.globalData.nickName = res.data.nickName
  853. }
  854. that.setData({
  855. levelName: res.data.levelName,
  856. upgradePercent: res.data.upgradePercent,
  857. upgradeScore: res.data.upgradeScore,
  858. memberId: res.data.id,
  859. credit: res.data.credit,
  860. userAvatarUrl: res.data.avatarUrl ? res.data.avatarUrl : '',
  861. userName: res.data.nickName ? res.data.nickName : '',
  862. })
  863. })
  864. .catch(err => {
  865. tt.showModal({
  866. title: '提示',
  867. content: err.message,
  868. showCancel: false
  869. })
  870. })
  871. },
  872. gotoChengzhangzhi: function () {
  873. tt.navigateTo({
  874. url: '/pages/czdetail/czdetail',
  875. })
  876. },
  877. goIntegralmall() {
  878. tt.navigateTo({
  879. url: '/pages/integralmall/index',
  880. })
  881. },
  882. gotoBargain: function () {
  883. tt.navigateTo({
  884. url: '/pages/bargain/bargain',
  885. })
  886. },
  887. gotoSpellGroup: function () {
  888. tt.navigateTo({
  889. url: '/pages/spellGroup/spellGroup',
  890. })
  891. },
  892. gotoCard: function () {
  893. tt.navigateTo({
  894. url: '/pages/discountCardList/discountCardList',
  895. })
  896. },
  897. // gotoGame: function () {
  898. // tt.navigateTo({
  899. // url: '/pages/game/index',
  900. // })
  901. // },
  902. gotoJfsc: function () {
  903. tt.navigateTo({
  904. url: '/pages/integralmall/index',
  905. })
  906. },
  907. /**
  908. *
  909. * @param {code,page}
  910. * 子组件向父组件传值
  911. */
  912. onGetCode: function (e) {
  913. this.setData({
  914. code: e.detail.val,
  915. page: e.detail.pageNum,
  916. });
  917. console.log(e.detail.val)
  918. console.log(e.detail.pageNum)
  919. },
  920. getWeapNote: function (couponChannelId, couponId, orderId) {
  921. var that = this;
  922. if (app.globalData.token) {
  923. that.getsubMallList()
  924. // 登录
  925. console.log(app.globalData.token)
  926. that.getCongig() //获取小程序是否开通授权手机号
  927. that.setData({
  928. mouldType: app.globalData.mouldType,
  929. marketName: app.globalData.marketName,
  930. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  931. })
  932. //获取首页按钮 抖音暂时屏蔽
  933. // that.getModule()
  934. that.getmemberId(app.globalData.token);
  935. that.getBannerlist();
  936. // if (that.data.mouldType == 0) { //富茂原版
  937. // that.topicShow();
  938. // that.getxsList();
  939. // } else if (that.data.mouldType == 1) { //欢乐城模板
  940. // }
  941. that.getShowList()
  942. that.topicShowall(2);
  943. that.topicShowall(3);
  944. that.topicShowall(4);
  945. that.topicShowall(5);
  946. that.topicShowall(6);
  947. that.getBusinessList();
  948. that.getCouponChannelList(0)
  949. that.getsubMallList()
  950. that.getType()
  951. that.uesrInfo()
  952. // that.getLocation();
  953. that.getMallInfo(app.globalData.token);
  954. if (app.couponChannelListCallback) {
  955. app.couponChannelListCallback(app.globalData.token);
  956. }
  957. if (app.couponListCallback) {
  958. app.couponListCallback(app.globalData.token);
  959. }
  960. if (app.businessListCallback) {
  961. app.businessListCallback(app.globalData.token);
  962. }
  963. Http.get({
  964. url: config.api.getWeapNote,
  965. data: {
  966. appId: app.globalData.appId,
  967. }
  968. })
  969. .then(res => {
  970. console.log(33333333333)
  971. console.log(app.globalData.token)
  972. console.log(res)
  973. console.log(33333333333)
  974. // that.getGameOne(app.globalData.token)
  975. // that.getStaticGame(app.globalData.token)
  976. that.getGg(app.globalData.token)
  977. let weapNote = JSON.parse(res.data.weapNote);
  978. that.setData({
  979. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  980. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  981. })
  982. })
  983. .catch(err => {
  984. // that.getGameOne(app.globalData.token)
  985. // that.getStaticGame(app.globalData.token)
  986. that.getGg(app.globalData.token)
  987. tt.showModal({
  988. title: "提示",
  989. content: err.message,
  990. showCancel: false
  991. });
  992. });
  993. } else {
  994. app.tokenCallback = token => {
  995. that.getsubMallList()
  996. // 登录
  997. console.log(app.globalData.token)
  998. that.getCongig() //获取小程序是否开通授权手机号
  999. that.setData({
  1000. mouldType: app.globalData.mouldType,
  1001. marketName: app.globalData.marketName,
  1002. activeColor: app.globalData.mouldType == 1 ? "#E9D0AA" : bgColor.colorFirst.main.activeColor
  1003. })
  1004. //获取首页按钮 抖音暂时屏蔽
  1005. // that.getModule()
  1006. that.getmemberId(app.globalData.token);
  1007. that.getBannerlist();
  1008. // if (that.data.mouldType == 0) { //富茂原版
  1009. // that.topicShow();
  1010. // that.getxsList();
  1011. // } else if (that.data.mouldType == 1) { //欢乐城模板
  1012. // }
  1013. that.getShowList()
  1014. that.topicShowall(2);
  1015. that.topicShowall(3);
  1016. that.topicShowall(4);
  1017. that.topicShowall(5);
  1018. that.topicShowall(6);
  1019. that.getBusinessList();
  1020. that.getCouponChannelList(0)
  1021. that.getType()
  1022. that.uesrInfo()
  1023. // that.getLocation();
  1024. that.getMallInfo(app.globalData.token);
  1025. if (app.couponChannelListCallback) {
  1026. app.couponChannelListCallback(app.globalData.token);
  1027. }
  1028. if (app.couponListCallback) {
  1029. app.couponListCallback(app.globalData.token);
  1030. }
  1031. if (app.businessListCallback) {
  1032. app.businessListCallback(app.globalData.token);
  1033. }
  1034. Http.get({
  1035. url: config.api.getWeapNote,
  1036. data: {
  1037. appId: app.globalData.appId,
  1038. }
  1039. })
  1040. .then(res => {
  1041. console.log(33333333333)
  1042. console.log(app.globalData.token)
  1043. console.log(res)
  1044. console.log(33333333333)
  1045. // that.getGameOne(app.globalData.token)
  1046. // that.getStaticGame(app.globalData.token)
  1047. that.getGg(app.globalData.token)
  1048. let weapNote = JSON.parse(res.data.weapNote);
  1049. that.setData({
  1050. // desc: weapNote.firstpage.desc?weapNote.firstpage.desc:"",
  1051. // title: weapNote.firstpage.title?weapNote.firstpage.title:'',
  1052. })
  1053. })
  1054. .catch(err => {
  1055. // that.getGameOne(app.globalData.token)
  1056. // that.getStaticGame(app.globalData.token)
  1057. that.getGg(app.globalData.token)
  1058. tt.showModal({
  1059. title: "提示",
  1060. content: err.message,
  1061. showCancel: false
  1062. });
  1063. });
  1064. }
  1065. }
  1066. },
  1067. getStaticGame(token) {
  1068. let _this = this;
  1069. Http.get({
  1070. url: config.api.getGame,
  1071. data: {
  1072. triggleAction: 2, // 固定入口
  1073. token: token
  1074. }
  1075. }).then(res => {
  1076. if (res.data.id) {
  1077. _this.setData({
  1078. showIf: true,
  1079. newUrl: res.data.imgUrl
  1080. })
  1081. } else {
  1082. _this.setData({
  1083. showIf: false
  1084. })
  1085. }
  1086. _this.setData({
  1087. staticGamedata: res.data
  1088. })
  1089. })
  1090. .catch(err => {
  1091. _this.setData({
  1092. showIf: false
  1093. })
  1094. console.log(err)
  1095. })
  1096. },
  1097. getGameOne: function (token) {
  1098. let _this = this;
  1099. Http.get({
  1100. url: config.api.getGame,
  1101. data: {
  1102. triggleAction: 1, // 登录触发
  1103. token: token
  1104. }
  1105. }).then(res => {
  1106. if (res.data.id) {
  1107. _this.setData({
  1108. showGame: true,
  1109. })
  1110. } else {
  1111. _this.setData({
  1112. showGame: false
  1113. })
  1114. }
  1115. _this.setData({
  1116. gamedata: res.data
  1117. })
  1118. })
  1119. .catch(err => {
  1120. _this.setData({
  1121. showGame: false
  1122. })
  1123. this.alphaClick();
  1124. })
  1125. },
  1126. /**
  1127. * mallinfo
  1128. */
  1129. getMallInfo: function (token) {
  1130. let that = this;
  1131. Http.get({
  1132. url: config.api.getMallInfo,
  1133. data: {
  1134. token: token,
  1135. }
  1136. }).then(res => {
  1137. that.setData({
  1138. liveFlag: res.data.liveSupport,
  1139. weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null,
  1140. weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null,
  1141. });
  1142. console.log(that.data.liveFlag, "||||")
  1143. })
  1144. .catch(err => {
  1145. // 不需要错误提示
  1146. });
  1147. },
  1148. //获取限时抢购列表
  1149. getxsList() {
  1150. let that = this;
  1151. Http.get({
  1152. url: config.api.couponChannelList,
  1153. data: {
  1154. pageNum: 1,
  1155. pageSize: 3,
  1156. targetAd: 2
  1157. }
  1158. }).then(res => {
  1159. if (res && res.data.total > 0) {
  1160. that.setData({
  1161. xslist: res.data.list,
  1162. showQg: true
  1163. });
  1164. } else {
  1165. that.setData({
  1166. showQg: false
  1167. })
  1168. }
  1169. })
  1170. .catch(err => {
  1171. console.log(err)
  1172. tt.showToast({
  1173. title: err.message,
  1174. icon: 'none',
  1175. duration: 2000,
  1176. mask: false
  1177. });
  1178. })
  1179. },
  1180. /**
  1181. * banner
  1182. */
  1183. getBannerlist: function () {
  1184. let that = this;
  1185. Http.get({
  1186. url: config.api.bannerlist,
  1187. data: {
  1188. pageNum: 1,
  1189. pageSize: 7,
  1190. plat: 3,
  1191. mallTenantId: tt.getStorageSync('mallTenantId') || that.data.scanInTenantId || ""
  1192. }
  1193. }).then(res => {
  1194. that.getmemberId(app.globalData.token);
  1195. // that.checkUserCarStatus();
  1196. that.setData({
  1197. list: res.data.list
  1198. });
  1199. })
  1200. .catch(err => {
  1201. that.getmemberId(app.globalData.token);
  1202. // that.checkUserCarStatus();
  1203. });
  1204. },
  1205. //获取欢乐城专题
  1206. getShowList() {
  1207. Http.get({
  1208. url: config.api.showList
  1209. }).then(res => {
  1210. let tempData = res.data
  1211. tempData.map(item1 => {
  1212. if (item1.couponList) {
  1213. item1.couponList.map(item2 => {
  1214. if (item2.salePriceStr && item2.salePriceStr.indexOf('.') != -1) {
  1215. let str = item2.salePriceStr.split('.')
  1216. item2.salePriceStrQ = str[0]
  1217. item2.salePriceStrH = str[1]
  1218. }
  1219. })
  1220. }
  1221. })
  1222. this.setData({
  1223. specialLsit: res.data ? res.data : []
  1224. })
  1225. }).catch(err => {
  1226. tt.showToast({
  1227. title: err.message ? err.message : err.data,
  1228. icon: 'none',
  1229. duration: 2000,
  1230. mask: false
  1231. });
  1232. })
  1233. },
  1234. /**
  1235. * topicType=2 限时抢购
  1236. * topicType=3 砍价
  1237. * topicType=4 拼团
  1238. * topicType=5 消费卡
  1239. * topicType=6 积分商城
  1240. */
  1241. topicShowall(topicType) {
  1242. Http.get({
  1243. url: config.api.topicShow,
  1244. data: {
  1245. topicType
  1246. }
  1247. }).then(res => {
  1248. let data = res.data
  1249. if (data.couponList != null && data.couponList.length > 0) {
  1250. data.couponList.map(item => {
  1251. if (item.salePriceStr && item.salePriceStr.indexOf('.') != -1) {
  1252. let str = item.salePriceStr.split('.')
  1253. item.salePriceStrQ = str[0]
  1254. item.salePriceStrH = str[1]
  1255. }
  1256. })
  1257. }
  1258. if (topicType == 2) {
  1259. let tempData = data
  1260. this.setData({
  1261. topicObj2: data
  1262. })
  1263. } else if (topicType == 3) {
  1264. this.setData({
  1265. topicObj3: data
  1266. })
  1267. } else if (topicType == 4) {
  1268. this.setData({
  1269. topicObj4: data
  1270. })
  1271. } else if (topicType == 5) {
  1272. this.setData({
  1273. topicObj5: data
  1274. })
  1275. } else if (topicType == 6) {
  1276. this.setData({
  1277. topicObj6: data
  1278. })
  1279. }
  1280. }).catch(err => {
  1281. tt.showToast({
  1282. title: err.message ? err.message : err.data,
  1283. icon: 'none',
  1284. duration: 2000,
  1285. mask: false
  1286. });
  1287. })
  1288. },
  1289. // 专题显示
  1290. topicShow: function () {
  1291. let that = this;
  1292. Http.get({
  1293. url: config.api.topicShow,
  1294. data: {
  1295. token: app.globalData.token
  1296. }
  1297. }).then(res => {
  1298. if (res && res.data) {
  1299. that.setData({
  1300. name: res.data.name,
  1301. cover: res.data.cover,
  1302. id: res.data.id,
  1303. showTopic: true
  1304. })
  1305. } else {
  1306. that.setData({
  1307. showTopic: false
  1308. })
  1309. }
  1310. })
  1311. .catch(err => {
  1312. console.log(err);
  1313. })
  1314. },
  1315. gotoTopic() {
  1316. tt.navigateTo({
  1317. url: `/pages/topicDetail/index?id=${this.data.id}`
  1318. })
  1319. },
  1320. /**
  1321. * 检查用户是否有车
  1322. */
  1323. // checkUserCarStatus: function() {
  1324. // var that = this;
  1325. // Http.get({
  1326. // url: config.api.userCarCount,
  1327. // data: {}
  1328. // }).then(res => {
  1329. // if (res.data > 0) {
  1330. // // 用户名下有车
  1331. // app.globalData.phone = res.data.phone;
  1332. // app.globalData.supportCar = true;
  1333. // // 共同登录
  1334. // that.userCarLogin();
  1335. // }
  1336. // });
  1337. // },
  1338. /**
  1339. * car共同登录
  1340. */
  1341. // userCarLogin: function() {
  1342. // var that = this;
  1343. // if (!app.globalData.carLogin) {
  1344. // // 共同登录
  1345. // Http.post({
  1346. // url: config.api.carInit,
  1347. // data: {
  1348. // phone: app.globalData.phone
  1349. // }
  1350. // }).then(res => {
  1351. // app.globalData.carLogin = true;
  1352. // app.globalData.parkVendor = res.data.vendor;
  1353. // if (res.data.token != "undefined") {
  1354. // app.globalData.etcpToken = res.data.token;
  1355. // }
  1356. // });
  1357. // }
  1358. // },
  1359. /**
  1360. * 获取用户信息
  1361. */
  1362. // getUserInfo: function() {
  1363. // // 获取用户信息
  1364. // tt.getSetting({
  1365. // success: res => {
  1366. // if (res.authSetting["scope.userInfo"]) {
  1367. // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
  1368. // tt.getUserInfo({
  1369. // success: res => {
  1370. // // 可以将 res 发送给后台解码出 unionId
  1371. // }
  1372. // });
  1373. // }
  1374. // }
  1375. // });
  1376. // },
  1377. gotoBargain: function () {
  1378. tt.navigateTo({
  1379. url: '/pages/bargain/bargain'
  1380. })
  1381. },
  1382. //限时抢购的详情页面
  1383. gotodetail: function (e) {
  1384. tt.navigateTo({
  1385. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  1386. }&couponId=${e.currentTarget.dataset.couponid}`
  1387. });
  1388. },
  1389. //浮层广告
  1390. getGg: function (token) {
  1391. let that = this
  1392. Http.get({
  1393. url: config.api.getGg,
  1394. data: {
  1395. token: token,
  1396. appId: app.globalData.appId,
  1397. openId: "" // tt.getStorageSync('openId')
  1398. }
  1399. }).then(res => {
  1400. console.log(res)
  1401. if (res.data.id) {
  1402. that.setData({
  1403. showGg: true,
  1404. })
  1405. console.log(that.data.showGg, 1111111111111)
  1406. } else {
  1407. that.setData({
  1408. showGg: false
  1409. })
  1410. // that.getGameOne(app.globalData.token)
  1411. console.log(that.data.showGg, 222222222222222222)
  1412. }
  1413. that.setData({
  1414. ggdata: res.data
  1415. })
  1416. })
  1417. .catch(err => {
  1418. this.setData({
  1419. showGg: false
  1420. })
  1421. // that.getGameOne(app.globalData.token)
  1422. that.alphaClick1();
  1423. })
  1424. },
  1425. /**
  1426. * 刷新
  1427. */
  1428. onPullDownRefresh() {
  1429. tt.showLoading({
  1430. title: "加载中..."
  1431. });
  1432. let that = this;
  1433. // that.setData({
  1434. // topicObj2: null, //欢乐城首页限时抢购
  1435. // topicObj3: null, //欢乐城首页砍价
  1436. // topicObj4: null, //欢乐城首页拼团
  1437. // topicObj5: null, //欢乐城首页消费卡
  1438. // topicObj6: null, //欢乐城首页积分商城
  1439. // specialLsit: null, //专题
  1440. // })
  1441. // // that.getWeapNote();
  1442. that.setData({
  1443. page: 1,
  1444. businePageNum: 1,
  1445. noDataFlag: false
  1446. })
  1447. // if (that.data.optionsData != null && (that.data.optionsData.couponChannelId || that.data.optionsData.orderId)) {
  1448. // that.getWeapNote(that.data.optionsData.couponChannelId, that.data.optionsData.orderId);
  1449. // } else {
  1450. // that.getWeapNote()
  1451. // }
  1452. // if (that.selectComponent("#lists")) {
  1453. // if (that.data.code == 0 || that.data.code == undefined) {
  1454. // that.selectComponent("#lists").getList(0, 1, "refresh");
  1455. // tt.stopPullDownRefresh();
  1456. // } else {
  1457. // that.selectComponent("#lists").getList(that.data.code, 1, "refresh");
  1458. // tt.stopPullDownRefresh();
  1459. // };
  1460. // that.selectComponent("#hot").getList();
  1461. // }
  1462. // // 砍价下拉刷新
  1463. // // that.selectComponent("#bargain").getList();
  1464. // // that.selectComponent("#spellGroup").getList();
  1465. // // that.selectComponent("#rushtobyCard").getList();
  1466. // // 爆款专区下拉刷新
  1467. // that.getxsList();
  1468. // that.topicShow();
  1469. this.getBannerlist();
  1470. this.getBusinessList()
  1471. this.getCouponChannelList(this.data.busineKye)
  1472. setTimeout(() => {
  1473. tt.hideLoading();
  1474. tt.stopPullDownRefresh();
  1475. }, 1600);
  1476. },
  1477. //加载更多
  1478. onReachBottom: function () {
  1479. console.log("我到底了")
  1480. let that = this;
  1481. that.data.page++;
  1482. that.setData({
  1483. page: that.data.page,
  1484. businePageNum: that.data.businePageNum + 1
  1485. });
  1486. console.log("加载更多页数" + that.data.page, );
  1487. console.log("加载更多key" + that.data.code);
  1488. // if (that.data.mouldType == 0) { //富茂源模板
  1489. // //父组件获得子组件的方法
  1490. // //如果code == 0
  1491. // if (that.data.code == 0 || that.data.code == undefined) {
  1492. // that.selectComponent("#lists").getList(0, that.data.page);
  1493. // } else {
  1494. // that.selectComponent("#lists").getList(that.data.code, that.data.page);
  1495. // }
  1496. // } else if (that.data.mouldType == 1) {
  1497. // }
  1498. this.getCouponChannelList(that.data.busineKye)
  1499. },
  1500. // 用户点击右上角分享
  1501. onShareAppMessage: function () {
  1502. app.globalData.previewFlag = true
  1503. return {
  1504. path: "/pages/index/index",
  1505. title: this.data.weappShareTitle,
  1506. imageUrl: this.data.weappShareCoverImg,
  1507. success: function (res) {
  1508. tt.showToast({
  1509. title: "分享成功",
  1510. duration: 1000,
  1511. icon: "success"
  1512. });
  1513. }
  1514. };
  1515. }
  1516. });
  1517. Array.prototype.bubbleSort = function () {
  1518. for (let i = 0; i < this.length - 1; i += 1) {
  1519. for (let j = 0; j < this.length - 1 - i; j += 1) {
  1520. if (this[j] > this[j + 1]) {
  1521. const temp = this[j];
  1522. this[j] = this[j + 1];
  1523. this[j + 1] = temp;
  1524. }
  1525. }
  1526. }
  1527. }