diff --git a/pages/index/center.vue b/pages/index/center.vue
index cb0ba85..76ae1f1 100644
--- a/pages/index/center.vue
+++ b/pages/index/center.vue
@@ -74,14 +74,14 @@
-
+
隐私政策
diff --git a/pages/index/index.vue b/pages/index/index.vue
index de90eb9..e22a9d7 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -59,6 +59,10 @@
title: '文章分享',
path: '/pages_order/record/articleSharing'
},
+ // {
+ // title: '视频',
+ // path: '/pages_order/sharing/video?id=1922875315630133249'
+ // },
],
}
},
diff --git a/pages_order/components/popupUnlock.vue b/pages_order/components/popupUnlock.vue
index b657ed5..baf9ad1 100644
--- a/pages_order/components/popupUnlock.vue
+++ b/pages_order/components/popupUnlock.vue
@@ -1,63 +1,59 @@
-
-
-
-
-
-
+ }">
+
+
+
+
+
\ No newline at end of file
diff --git a/pages_order/record/videoSharing.vue b/pages_order/record/videoSharing.vue
index 2785a15..e294cb2 100644
--- a/pages_order/record/videoSharing.vue
+++ b/pages_order/record/videoSharing.vue
@@ -1,158 +1,138 @@
-
+
-
-
+
-
-
-
-
-
-
-
-
-
- 设置封面
-
-
-
-
-
-
-
-
-
- 上传视频
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ }" errorType="toast">
+
+
+
+
+
+
+
+
+
+ 设置封面
+
+
+
+
+
+
+
+
+
+ 上传视频
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages_order/sharing/video.vue b/pages_order/sharing/video.vue
index ca1bbab..fbb8d2c 100644
--- a/pages_order/sharing/video.vue
+++ b/pages_order/sharing/video.vue
@@ -28,6 +28,7 @@
import popupUnlock from '../components/popupUnlock.vue'
import popupQrCode from '../components/popupQrCode.vue'
+ import shareLog from '@/utils/shareLog'
export default {
components: {
@@ -108,6 +109,7 @@
query: `id=${this.id}&state=1&shareId=${this.userInfo.id}`,
}
+
//调用增加分享次数的方法
const params = {
id: this.id,
@@ -115,6 +117,7 @@
}
// this.$fetch('addLogShareInfo', params)
+ // 将分享记录移到回调成功里面,避免分享取消也计数
shareLog.insert(this.id)
return o
@@ -125,6 +128,12 @@
this.detail = await this.$fetch('getVideoShareInfo', {
id
})
+
+ // 确保num和timeNum是数字类型
+ if (this.detail) {
+ this.detail.num = parseInt(this.detail.num) || 0;
+ this.detail.timeNum = parseFloat(this.detail.timeNum) || 0;
+ }
} catch (err) {
}
@@ -132,14 +141,20 @@
async initData() {
this.isLocked = true
await this.fetchDetails(this.id)
-
this.videoContext = uni.createVideoContext('video');
+
+ // 初始加载时检查是否已经解锁
+ const result = await this.fetchCheckShare()
+ if (result.open) {
+ this.isLocked = false
+ this.timeIsUp = false
+ }
},
async refreshLockStatus() {
- this.isLocked = false
- this.timeIsUp = false
+ // 不要在这里设置timeIsUp = false,这会导致弹窗被关闭
+ // this.timeIsUp = false
+
setTimeout(async () => {
-
const result = await this.fetchCheckShare()
const {
open,
@@ -147,14 +162,18 @@
num
} = result
- console.log('--open', open)
-
if (open) { // 转发已达标
this.videoContext.play()
this.isLocked = false
+ this.timeIsUp = false // 只有在达标时才关闭弹窗
return
- }
+ }else{
+ if(this.timeIsUp){
+ this.onPlay()
+ }
+ }
+ // 如果未达标,只显示提示,不改变弹窗状态
uni.showToast({
title: `还需转发${need_num - num}次`,
icon: 'none',
@@ -163,7 +182,9 @@
},
async fetchCheckShare() {
try {
- return await shareLog.check(this.id, this.detail.num)
+ // 确保detail.num被转换为数字,因为API返回的是字符串类型
+ const numValue = parseInt(this.detail.num) || 0;
+ return await shareLog.check(this.id, numValue)
} catch (err) {
return {}
}
@@ -173,6 +194,16 @@
return
}
+ // 先检查是否已经达到分享条件
+ const result = await this.fetchCheckShare()
+ if (result.open) {
+ this.isLocked = false
+ this.timeIsUp = false
+ this.videoContext.play()
+ return
+ }
+
+ // 如果未达到条件,则暂停视频并显示弹窗
this.videoContext.pause()
this.timeIsUp = true
this.$refs.popupUnlock.open();
@@ -183,8 +214,6 @@
} = e.target
if (currentTime >= this.detail.timeNum && this.isLocked) {
- this.videoContext.pause()
- this.timeIsUp = true
this.onPlay()
}
},
diff --git a/utils/shareLog.js b/utils/shareLog.js
index 8b7cbc7..3b51192 100644
--- a/utils/shareLog.js
+++ b/utils/shareLog.js
@@ -1,9 +1,11 @@
-
import fetch from '@/api/fetch.js'
+const slog = {}
+
const get = () => {
try {
- return JSON.parse(uni.getStorageSync('shareLog')) || {}
+ return slog
+ // return JSON.parse(uni.getStorageSync('shareLog')) || {}
} catch (err) {
return {}
}
@@ -23,11 +25,12 @@ const check = async (id, need_num) => {
try {
const log = get()
- const num = log[id] || 0
+ const num = parseInt(log[id]) || 0
+ const safeNeedNum = parseInt(need_num) || 0
- const open = num >= need_num
+ const open = num >= safeNeedNum
- return { open, need_num, num, title: `已转发${num}次` }
+ return { open, need_num: safeNeedNum, num, title: `已转发${num}次` }
} catch (err) {
console.error('--校验达标异常', err)
return {}