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

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