抖音c端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1570 rindas
42 KiB

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