抖音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.

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