wangfukang 21 hours ago
parent
commit
19787e19f6
  1. 49
      pages/index/index.vue

49
pages/index/index.vue

@ -1,4 +1,5 @@
<template> <template>
<page-meta :page-style="areaPopupVisible ? 'overflow: hidden;' : ''"></page-meta>
<view class="page1" :class="{'is-sticky': lastScrollTop>stickyTrigger}"> <view class="page1" :class="{'is-sticky': lastScrollTop>stickyTrigger}">
<view class="swiper-container"> <view class="swiper-container">
<view class="swiper-page" v-show="currentIndex == 0"> <view class="swiper-page" v-show="currentIndex == 0">
@ -466,8 +467,8 @@
</view> </view>
</view> --> </view> -->
<!-- 弹出区域选择 --> <!-- 弹出区域选择 -->
<uni-popup ref="areaPopup" class="home-popup-layer" :is-mask-click="areaPopupCanClose" background-color="transparent"> <uni-popup ref="areaPopup" class="home-popup-layer" :is-mask-click="areaPopupCanClose" background-color="transparent" @change="onAreaPopupChange">
<view class="campus-area-popup"> <view class="campus-area-popup" @touchmove.stop>
<view class="area-popup-glow area-popup-glow-a"></view> <view class="area-popup-glow area-popup-glow-a"></view>
<view class="area-popup-glow area-popup-glow-b"></view> <view class="area-popup-glow area-popup-glow-b"></view>
<view class="campus-area-header"> <view class="campus-area-header">
@ -486,7 +487,7 @@
<input v-model="areaKeyword" confirm-type="search" placeholder="搜索学校 / 校区 / 区域" <input v-model="areaKeyword" confirm-type="search" placeholder="搜索学校 / 校区 / 区域"
placeholder-class="area-search-placeholder" /> placeholder-class="area-search-placeholder" />
</view> </view>
<scroll-view scroll-y class="campus-area-list"> <scroll-view scroll-y class="campus-area-list" @touchmove.stop>
<view <view
class="campus-area-item" class="campus-area-item"
:class="{ 'campus-area-item--suggest': suggestedArea && suggestedArea.id == item.id }" :class="{ 'campus-area-item--suggest': suggestedArea && suggestedArea.id == item.id }"
@ -569,7 +570,7 @@
import myCenter from "@/components/tab-bar/myCenter.vue"; import myCenter from "@/components/tab-bar/myCenter.vue";
import homeGroupPending from "@/components/tab-bar/homeGroupPending.vue"; import homeGroupPending from "@/components/tab-bar/homeGroupPending.vue";
import { getIeRealNameAuditSetting } from '@/common/ieApi.js' import { getIeRealNameAuditSetting } from '@/common/ieApi.js'
import { resolveHomeShareTarget, normalizeShareTargetPath } from '@/utils/sharePath.js' import { resolveHomeShareTarget, normalizeShareTargetPath, resolveMiniCodeSceneTarget } from '@/utils/sharePath.js'
const HOME_AD_IMAGE_CACHE_KEY = 'home_ad_image_cache_v1' const HOME_AD_IMAGE_CACHE_KEY = 'home_ad_image_cache_v1'
const HOME_POPUP_AD_SHOWN_KEY_PREFIX = 'home_popup_ad_shown_v1' const HOME_POPUP_AD_SHOWN_KEY_PREFIX = 'home_popup_ad_shown_v1'
@ -578,6 +579,7 @@
const homeAdImageDownloading = {} const homeAdImageDownloading = {}
let groupBuySubPackagePreloaded = false let groupBuySubPackagePreloaded = false
let groupBuySubPackagePreloading = false let groupBuySubPackagePreloading = false
let groupBuySubPackagePromise = null
const HOME_MENU_ICON_URLS = { const HOME_MENU_ICON_URLS = {
food: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/553230c20dea4e5c85f1e396058a7493.png', food: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/553230c20dea4e5c85f1e396058a7493.png',
store: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/28b5cfec79d74871b0ce67743fb7619c.png', store: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/28b5cfec79d74871b0ce67743fb7619c.png',
@ -747,6 +749,7 @@
areaList: [], areaList: [],
areaKeyword: '', areaKeyword: '',
areaPopupCanClose: false, areaPopupCanClose: false,
areaPopupVisible: false,
suggestedArea: null, suggestedArea: null,
orderLists: [], orderLists: [],
waimaiCount: 0, waimaiCount: 0,
@ -957,7 +960,7 @@
if (option && option.deliveryRuleEdited == 1) { if (option && option.deliveryRuleEdited == 1) {
this.pendingDeliveryRuleConfirm = true this.pendingDeliveryRuleConfirm = true
} }
const shareTargetPath = resolveHomeShareTarget(option) const shareTargetPath = resolveMiniCodeSceneTarget(option && option.scene) || resolveHomeShareTarget(option)
if (shareTargetPath) { if (shareTargetPath) {
this.pendingShareTargetPath = shareTargetPath this.pendingShareTargetPath = shareTargetPath
uni.setStorageSync('pendingShareTargetPath', shareTargetPath) uni.setStorageSync('pendingShareTargetPath', shareTargetPath)
@ -999,7 +1002,9 @@
} }
}, },
onHide() { onHide() {
this.areaPopupVisible = false
this.closeProductPopup() this.closeProductPopup()
clearTimeout(this._groupBuyPreloadTimer)
this.stopDeliveryTimeTimer() this.stopDeliveryTimeTimer()
}, },
onReady() { onReady() {
@ -1009,13 +1014,19 @@
}, 500); }, 500);
}, },
onUnload() { onUnload() {
this.areaPopupVisible = false
this.closeProductPopup() this.closeProductPopup()
clearTimeout(this._groupBuyPreloadTimer)
this.stopDeliveryTimeTimer() this.stopDeliveryTimeTimer()
}, },
onShareAppMessage() { onShareAppMessage() {
return this.buildHomeShareInfo() return this.buildHomeShareInfo()
}, },
methods: { methods: {
onAreaPopupChange(e) {
const detail = e && e.detail ? e.detail : e
this.areaPopupVisible = !!(detail && detail.show)
},
enableShareMenu() { enableShareMenu() {
if (!uni.showShareMenu) return if (!uni.showShareMenu) return
uni.showShareMenu({ uni.showShareMenu({
@ -1073,10 +1084,12 @@
}, 300) }, 300)
}, },
preloadGroupBuyListPage() { preloadGroupBuyListPage() {
if (groupBuySubPackagePreloaded || groupBuySubPackagePreloading) return if (groupBuySubPackagePreloaded) return Promise.resolve()
if (groupBuySubPackagePromise) return groupBuySubPackagePromise
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
if (typeof wx === 'undefined' || !wx.loadSubpackage) return if (typeof wx === 'undefined' || !wx.loadSubpackage) return Promise.resolve()
groupBuySubPackagePreloading = true groupBuySubPackagePreloading = true
groupBuySubPackagePromise = new Promise((resolve) => {
wx.loadSubpackage({ wx.loadSubpackage({
root: 'package2', root: 'package2',
success: () => { success: () => {
@ -1084,9 +1097,14 @@
}, },
complete: () => { complete: () => {
groupBuySubPackagePreloading = false groupBuySubPackagePreloading = false
groupBuySubPackagePromise = null
resolve()
} }
}) })
})
return groupBuySubPackagePromise
// #endif // #endif
return Promise.resolve()
}, },
normalizeShareTargetPath(value) { normalizeShareTargetPath(value) {
return normalizeShareTargetPath(value) return normalizeShareTargetPath(value)
@ -1125,6 +1143,13 @@
uni.removeStorageSync('authPendingTargetPath') uni.removeStorageSync('authPendingTargetPath')
this.$nextTick(() => { this.$nextTick(() => {
setTimeout(() => { setTimeout(() => {
const pages = getCurrentPages ? getCurrentPages() : []
const currentPage = pages[pages.length - 1]
const currentRoute = currentPage && currentPage.route ? '/' + currentPage.route : ''
if (currentRoute && currentRoute !== '/pages/index/index') {
this.openingShareTargetPath = ''
return
}
uni.navigateTo({ uni.navigateTo({
url: targetPath, url: targetPath,
fail: () => { fail: () => {
@ -1962,8 +1987,9 @@
url: '/package3/seckill/seckillGroup' url: '/package3/seckill/seckillGroup'
}) })
}, },
goPendingGroup() { async goPendingGroup() {
this.preloadGroupBuyListPage() clearTimeout(this._groupBuyPreloadTimer)
await this.preloadGroupBuyListPage()
uni.navigateTo({ uni.navigateTo({
url: '/package2/group/groupPendingList' url: '/package2/group/groupPendingList'
}) })
@ -1976,7 +2002,8 @@
url = '/package1/runErrand/runErrand' url = '/package1/runErrand/runErrand'
break; break;
case '2': case '2':
this.preloadGroupBuyListPage() clearTimeout(this._groupBuyPreloadTimer)
await this.preloadGroupBuyListPage()
url = '/package2/group/groupBuyList' url = '/package2/group/groupBuyList'
break; break;
case '3': case '3':
@ -2052,6 +2079,7 @@
if (this.$refs.areaPopup) { if (this.$refs.areaPopup) {
this.$refs.areaPopup.close() this.$refs.areaPopup.close()
} }
this.areaPopupVisible = false
this.tui.toast(fromManual ? '切换成功' : ('已定位到:' + (item.title || '当前区域'))) this.tui.toast(fromManual ? '切换成功' : ('已定位到:' + (item.title || '当前区域')))
if (this.$refs.myCenterPage && this.$refs.myCenterPage.init) { if (this.$refs.myCenterPage && this.$refs.myCenterPage.init) {
this.$refs.myCenterPage.init() this.$refs.myCenterPage.init()
@ -2152,6 +2180,7 @@
this.suggestedArea = hit this.suggestedArea = hit
} }
} }
this.areaPopupVisible = true
this.$refs.areaPopup.open(); this.$refs.areaPopup.open();
} else { } else {
this.tui.toast(res.message) this.tui.toast(res.message)

Loading…
Cancel
Save