feat: 版本更新、列表记录数量取值、
This commit is contained in:
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
"name" : "优购商城",
|
"name" : "优购商城",
|
||||||
"appid" : "__UNI__8B19741",
|
"appid" : "__UNI__8B19741",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.4.1",
|
"versionName" : "1.4.2",
|
||||||
"versionCode" : 141,
|
"versionCode" : 142,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"privacy" : {
|
"privacy" : {
|
||||||
|
|||||||
+11
-1
@@ -87,7 +87,17 @@
|
|||||||
let cardPages = ref(null);
|
let cardPages = ref(null);
|
||||||
let height = ref('100%');
|
let height = ref('100%');
|
||||||
let sysInfo = uni.getSystemInfoSync();
|
let sysInfo = uni.getSystemInfoSync();
|
||||||
height.value = sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
|
const headerHeight = uni.upx2px(248);
|
||||||
|
const headerMargin = uni.upx2px(64);
|
||||||
|
const listTopMargin = uni.upx2px(16);
|
||||||
|
height.value =
|
||||||
|
sysInfo.windowHeight -
|
||||||
|
sysInfo.statusBarHeight -
|
||||||
|
uni.upx2px(88) -
|
||||||
|
headerHeight -
|
||||||
|
headerMargin -
|
||||||
|
listTopMargin +
|
||||||
|
'px';
|
||||||
const sum_list = ref([{
|
const sum_list = ref([{
|
||||||
text: '总人数',
|
text: '总人数',
|
||||||
value: 0,
|
value: 0,
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
const items = Array.isArray(order?.items) ? order.items : [];
|
const items = Array.isArray(order?.items) ? order.items : [];
|
||||||
const firstItem = items[0] || {};
|
const firstItem = items[0] || {};
|
||||||
const titleText = firstItem?.spuName || order?.no || '-';
|
const titleText = firstItem?.spuName || order?.no || '-';
|
||||||
const qty = Number(order?.productCount ?? 0) || 0;
|
const qty = Number(firstItem?.count ?? 0) || 0;
|
||||||
const statusText = formatOrderStatus(order || {});
|
const statusText = formatOrderStatus(order || {});
|
||||||
const sumItemTotalPrice = items.reduce((acc, cur) => acc + (Number(cur?.totalPrice) || 0), 0);
|
const sumItemTotalPrice = items.reduce((acc, cur) => acc + (Number(cur?.totalPrice) || 0), 0);
|
||||||
const sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0);
|
const sumItemTotalRevenue = items.reduce((acc, cur) => acc + (Number(cur?.totalRevenue) || 0), 0);
|
||||||
|
|||||||
+172
-20
@@ -34,7 +34,7 @@
|
|||||||
@click="onMediaClick"
|
@click="onMediaClick"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
v-if="(USE_STATIC_START_PAGE || bgSrc) && mediaReady && countDown > 0"
|
v-if="(USE_STATIC_START_PAGE || bgSrc) && mediaReady && countDown > 0 && !useNativeSkip"
|
||||||
class="count-down"
|
class="count-down"
|
||||||
@click.stop="toHome"
|
@click.stop="toHome"
|
||||||
>
|
>
|
||||||
@@ -49,24 +49,29 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onUnmounted } from 'vue'
|
import { ref, onMounted, onUnmounted, watch } from 'vue'
|
||||||
import * as IndexApi from '@/sheep/api/index/index'
|
import * as IndexApi from '@/sheep/api/index/index'
|
||||||
|
|
||||||
const USE_STATIC_START_PAGE = false
|
const USE_STATIC_START_PAGE = false
|
||||||
|
|
||||||
const DEFAULT_IMAGE_SECONDS = 3
|
const DEFAULT_IMAGE_SECONDS = 3
|
||||||
const MAX_VIDEO_SECONDS = 9
|
const FIXED_VIDEO_SECONDS = 5
|
||||||
|
|
||||||
const bgSrc = ref('')
|
const bgSrc = ref('')
|
||||||
const jumpUrl = ref('')
|
const jumpUrl = ref('')
|
||||||
const isVideo = ref(false)
|
const isVideo = ref(false)
|
||||||
const mediaReady = ref(false)
|
const mediaReady = ref(false)
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
|
const useNativeSkip = ref(false)
|
||||||
let downloadToken = 0
|
let downloadToken = 0
|
||||||
let readyFallbackTimer = null
|
let readyFallbackTimer = null
|
||||||
let countDownTimer = null
|
let countDownTimer = null
|
||||||
let jumpTimer = null
|
let jumpTimer = null
|
||||||
let videoCountdownBootTimer = null
|
let videoCountdownBootTimer = null
|
||||||
|
let nativeSkipView = null
|
||||||
|
let nativeSkipViewId = ''
|
||||||
|
let plusReadyListenerBound = false
|
||||||
|
let lastVideoTime = 0
|
||||||
|
|
||||||
const normalizeAppFileUrl = (path) => {
|
const normalizeAppFileUrl = (path) => {
|
||||||
const p = String(path || '')
|
const p = String(path || '')
|
||||||
@@ -149,6 +154,120 @@ function closeNativeSplashIfNeeded() {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function destroyNativeSkipView() {
|
||||||
|
try {
|
||||||
|
if (!nativeSkipView) return
|
||||||
|
if (typeof nativeSkipView.hide === 'function') nativeSkipView.hide()
|
||||||
|
if (typeof nativeSkipView.close === 'function') nativeSkipView.close()
|
||||||
|
} catch (e) {}
|
||||||
|
nativeSkipView = null
|
||||||
|
nativeSkipViewId = ''
|
||||||
|
useNativeSkip.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureNativeSkipView() {
|
||||||
|
try {
|
||||||
|
if (typeof plus === 'undefined') return
|
||||||
|
if (nativeSkipView) return
|
||||||
|
const screenWidth = Number(plus?.screen?.resolutionWidth || 0)
|
||||||
|
if (!screenWidth) return
|
||||||
|
const pxPerRpx = screenWidth / 750
|
||||||
|
const widthPx = Math.round(pxPerRpx * 180)
|
||||||
|
const heightPx = Math.round(pxPerRpx * 64)
|
||||||
|
const rightPx = Math.round(pxPerRpx * 60)
|
||||||
|
const topPx = Math.round(pxPerRpx * 100)
|
||||||
|
const leftPx = Math.max(0, screenWidth - rightPx - widthPx)
|
||||||
|
const radiusPx = Math.round(heightPx / 2)
|
||||||
|
const fontPx = Math.round(pxPerRpx * 28)
|
||||||
|
|
||||||
|
nativeSkipViewId = `start-page-skip-${Date.now()}-${Math.floor(Math.random() * 1e6)}`
|
||||||
|
nativeSkipView = new plus.nativeObj.View(
|
||||||
|
nativeSkipViewId,
|
||||||
|
{
|
||||||
|
top: `${topPx}px`,
|
||||||
|
left: `${leftPx}px`,
|
||||||
|
width: `${widthPx}px`,
|
||||||
|
height: `${heightPx}px`,
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
|
nativeSkipView.drawRect(
|
||||||
|
{
|
||||||
|
color: 'rgba(0,0,0,0.4)',
|
||||||
|
radius: `${radiusPx}px`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
top: '0px',
|
||||||
|
left: '0px',
|
||||||
|
width: `${widthPx}px`,
|
||||||
|
height: `${heightPx}px`,
|
||||||
|
},
|
||||||
|
'bg'
|
||||||
|
)
|
||||||
|
|
||||||
|
nativeSkipView.addEventListener('click', () => {
|
||||||
|
toHome()
|
||||||
|
})
|
||||||
|
|
||||||
|
nativeSkipView.drawText(
|
||||||
|
getSkipText(),
|
||||||
|
{
|
||||||
|
top: '0px',
|
||||||
|
left: '0px',
|
||||||
|
width: `${widthPx}px`,
|
||||||
|
height: `${heightPx}px`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
size: `${fontPx}px`,
|
||||||
|
color: '#ffffff',
|
||||||
|
align: 'center',
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
},
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const wv = typeof plus?.webview?.currentWebview === 'function' ? plus.webview.currentWebview() : null
|
||||||
|
if (wv && typeof wv.append === 'function') {
|
||||||
|
wv.append(nativeSkipView)
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
nativeSkipView.show()
|
||||||
|
useNativeSkip.value = true
|
||||||
|
} catch (e) {
|
||||||
|
destroyNativeSkipView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateNativeSkipText() {
|
||||||
|
try {
|
||||||
|
if (!nativeSkipView) return
|
||||||
|
const screenWidth = Number(plus?.screen?.resolutionWidth || 0)
|
||||||
|
if (!screenWidth) return
|
||||||
|
const pxPerRpx = screenWidth / 750
|
||||||
|
const widthPx = Math.round(pxPerRpx * 180)
|
||||||
|
const heightPx = Math.round(pxPerRpx * 64)
|
||||||
|
const fontPx = Math.round(pxPerRpx * 28)
|
||||||
|
nativeSkipView.drawText(
|
||||||
|
getSkipText(),
|
||||||
|
{
|
||||||
|
top: '0px',
|
||||||
|
left: '0px',
|
||||||
|
width: `${widthPx}px`,
|
||||||
|
height: `${heightPx}px`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
size: `${fontPx}px`,
|
||||||
|
color: '#ffffff',
|
||||||
|
align: 'center',
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
},
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
function clearTimers() {
|
function clearTimers() {
|
||||||
if (readyFallbackTimer) clearTimeout(readyFallbackTimer)
|
if (readyFallbackTimer) clearTimeout(readyFallbackTimer)
|
||||||
readyFallbackTimer = null
|
readyFallbackTimer = null
|
||||||
@@ -158,6 +277,7 @@ function clearTimers() {
|
|||||||
jumpTimer = null
|
jumpTimer = null
|
||||||
if (videoCountdownBootTimer) clearTimeout(videoCountdownBootTimer)
|
if (videoCountdownBootTimer) clearTimeout(videoCountdownBootTimer)
|
||||||
videoCountdownBootTimer = null
|
videoCountdownBootTimer = null
|
||||||
|
destroyNativeSkipView()
|
||||||
}
|
}
|
||||||
|
|
||||||
function startCountDown(seconds) {
|
function startCountDown(seconds) {
|
||||||
@@ -203,8 +323,8 @@ function onVideoReady() {
|
|||||||
videoCountdownBootTimer = setTimeout(() => {
|
videoCountdownBootTimer = setTimeout(() => {
|
||||||
videoCountdownBootTimer = null
|
videoCountdownBootTimer = null
|
||||||
if (countDownTimer) return
|
if (countDownTimer) return
|
||||||
startCountDown(MAX_VIDEO_SECONDS)
|
startCountDown(FIXED_VIDEO_SECONDS)
|
||||||
scheduleJumpAfter(MAX_VIDEO_SECONDS + 0.2)
|
scheduleJumpAfter(FIXED_VIDEO_SECONDS + 0.2)
|
||||||
}, 300)
|
}, 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,24 +338,22 @@ function onVideoMetadata(e) {
|
|||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
closeNativeSplashIfNeeded()
|
closeNativeSplashIfNeeded()
|
||||||
}
|
}
|
||||||
const duration = Number(e?.detail?.duration || e?.detail?.totalTime || 0)
|
startCountDown(FIXED_VIDEO_SECONDS)
|
||||||
const limit = duration > 0 ? Math.min(MAX_VIDEO_SECONDS, Math.ceil(duration)) : MAX_VIDEO_SECONDS
|
scheduleJumpAfter(FIXED_VIDEO_SECONDS + 0.2)
|
||||||
startCountDown(limit)
|
|
||||||
scheduleJumpAfter(limit + 0.2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onVideoTimeUpdate(e) {
|
function onVideoTimeUpdate(e) {
|
||||||
const duration = Number(e?.detail?.duration || e?.detail?.totalTime || 0)
|
const currentTime = Number(e?.detail?.currentTime || 0)
|
||||||
if (!Number.isFinite(duration) || duration <= 0) return
|
if (!Number.isFinite(currentTime) || currentTime <= 0) return
|
||||||
const limit = Math.min(MAX_VIDEO_SECONDS, Math.ceil(duration))
|
const loopDetected = lastVideoTime > 0.4 && currentTime + 0.2 < lastVideoTime
|
||||||
if (countDown.value === limit) return
|
lastVideoTime = currentTime
|
||||||
if (countDownTimer && countDown.value < MAX_VIDEO_SECONDS) return
|
if (loopDetected) {
|
||||||
if (videoCountdownBootTimer) {
|
toHome()
|
||||||
clearTimeout(videoCountdownBootTimer)
|
return
|
||||||
videoCountdownBootTimer = null
|
}
|
||||||
|
if (currentTime + 0.12 >= FIXED_VIDEO_SECONDS) {
|
||||||
|
toHome()
|
||||||
}
|
}
|
||||||
startCountDown(limit)
|
|
||||||
scheduleJumpAfter(limit + 0.2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onVideoEnded() {
|
function onVideoEnded() {
|
||||||
@@ -288,6 +406,39 @@ function onMediaClick() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[() => isVideo.value, () => countDown.value],
|
||||||
|
([v, s]) => {
|
||||||
|
if (!v || s <= 0) {
|
||||||
|
destroyNativeSkipView()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (typeof plus !== 'undefined') {
|
||||||
|
ensureNativeSkipView()
|
||||||
|
updateNativeSkipText()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (plusReadyListenerBound) return
|
||||||
|
plusReadyListenerBound = true
|
||||||
|
try {
|
||||||
|
if (typeof document !== 'undefined' && document?.addEventListener) {
|
||||||
|
document.addEventListener(
|
||||||
|
'plusready',
|
||||||
|
() => {
|
||||||
|
plusReadyListenerBound = false
|
||||||
|
if (isVideo.value && countDown.value > 0) {
|
||||||
|
ensureNativeSkipView()
|
||||||
|
updateNativeSkipText()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ once: true }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.start-page {
|
.start-page {
|
||||||
@@ -303,6 +454,7 @@ function onMediaClick() {
|
|||||||
inset: 0;
|
inset: 0;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
.count-down {
|
.count-down {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -315,7 +467,7 @@ function onMediaClick() {
|
|||||||
line-height: 32rpx;
|
line-height: 32rpx;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: rgba(0, 0, 0, 0.4);
|
background: rgba(0, 0, 0, 0.4);
|
||||||
z-index: 9999;
|
z-index: 999999;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
+20
-1
@@ -256,6 +256,20 @@ export const downloadAndOpenApk = async (url, { progress } = {}) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const tempFilePath = await downloadFileWithProgress(url, { progress, stageText: '下载中...' })
|
const tempFilePath = await downloadFileWithProgress(url, { progress, stageText: '下载中...' })
|
||||||
|
const isAppPlus = typeof plus !== 'undefined' && !!plus?.runtime?.install
|
||||||
|
if (isAppPlus) {
|
||||||
|
if (progress?.set) progress.set(100, '安装中...')
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
plus.runtime.install(
|
||||||
|
tempFilePath,
|
||||||
|
{},
|
||||||
|
() => resolve(),
|
||||||
|
(e) => reject(e),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
if (progress?.hide) progress.hide()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (progress?.hide) progress.hide()
|
if (progress?.hide) progress.hide()
|
||||||
uni.showToast({ title: '下载成功', icon: 'success' })
|
uni.showToast({ title: '下载成功', icon: 'success' })
|
||||||
uni.saveFile({
|
uni.saveFile({
|
||||||
@@ -266,7 +280,12 @@ export const downloadAndOpenApk = async (url, { progress } = {}) => {
|
|||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (progress?.hide) progress.hide()
|
if (progress?.hide) progress.hide()
|
||||||
uni.showToast({ title: '下载失败,请检查网络', icon: 'none' })
|
uni.showModal({
|
||||||
|
title: '失败提示',
|
||||||
|
content: String(e?.message || e?.code || e || '安装失败'),
|
||||||
|
showCancel: false,
|
||||||
|
confirmColor: 'var(--color2)',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user