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

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