抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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