Browse Source

fix(分享日志): 在多个页面中添加shareLog.clear()以重置分享日志

在group.vue、video.vue、article.vue和personal.vue中添加了shareLog.clear(),以确保在页面加载时重置分享日志,避免数据残留。同时,在shareLog.js中添加了clear方法来实现日志清空功能。此外,调整了popupAuditMsg.vue中的导航逻辑,使用uni.reLaunch代替uni.navigateTo,以确保页面正确跳转。
master
前端-胡立永 2 weeks ago
parent
commit
c31efa892a
8 changed files with 150 additions and 131 deletions
  1. +71
    -75
      components/home/popupAuditMsg.vue
  2. +31
    -28
      pages/index/index.vue
  3. +3
    -0
      pages/index/record.vue
  4. +2
    -0
      pages_order/sharing/article.vue
  5. +2
    -0
      pages_order/sharing/group.vue
  6. +2
    -0
      pages_order/sharing/personal.vue
  7. +2
    -1
      pages_order/sharing/video.vue
  8. +37
    -27
      utils/shareLog.js

+ 71
- 75
components/home/popupAuditMsg.vue View File

@ -1,94 +1,90 @@
<template>
<uv-popup
ref="popup"
:overlayOpacity="0.8"
:customStyle="{
<uv-popup ref="popup" :overlayOpacity="0.8" :customStyle="{
backgroundColor: 'transparent',
}"
>
<view class="popup">
<image class="popup-bg" src="@/static/image/home/bg-audit-pass.png"></image>
<view class="popup-content flex">
<text class="value">{{ count }}</text>
<image class="unit" src="@/static/image/home/text-share.png"></image>
</view>
<view class="flex popup-btns">
<button plain class="btn-simple" @click="close">
<image class="popup-btn" src="@/static/image/home/cancel.png"></image>
</button>
<button plain class="btn-simple" @click="go">
<image class="popup-btn" src="@/static/image/home/go.png"></image>
</button>
</view>
</view>
</uv-popup>
}">
<view class="popup">
<image class="popup-bg" src="@/static/image/home/bg-audit-pass.png"></image>
<view class="popup-content flex">
<text class="value">{{ count }}</text>
<image class="unit" src="@/static/image/home/text-share.png"></image>
</view>
<view class="flex popup-btns">
<button plain class="btn-simple" @click="close">
<image class="popup-btn" src="@/static/image/home/cancel.png"></image>
</button>
<button plain class="btn-simple" @click="go">
<image class="popup-btn" src="@/static/image/home/go.png"></image>
</button>
</view>
</view>
</uv-popup>
</template>
<script>
export default {
props: {
count: {
type: Number,
default: 15
}
},
props: {
count: {
type: Number,
default: 15
}
},
data() {
return {
}
},
methods: {
open() {
this.$refs.popup.open();
},
close() {
this.$refs.popup.close();
},
go() {
uni.navigateTo({
return {}
},
methods: {
open() {
this.$refs.popup.open();
},
close() {
this.$refs.popup.close();
},
go() {
uni.reLaunch({
url: `/pages/index/record`
})
},
},
}
},
},
}
</script>
<style scoped lang="scss">
.popup {
position: relative;
width: 578rpx;
.popup {
position: relative;
width: 578rpx;
&-bg {
width: 578rpx; height: 317rpx;
}
&-bg {
width: 578rpx;
height: 317rpx;
}
&-content {
position: absolute;
top: 123rpx;
left: 50%;
transform: translateX(-50%);
&-content {
position: absolute;
top: 123rpx;
left: 50%;
transform: translateX(-50%);
.value {
color: #FF2323;
font-size: 102rpx;
font-weight: 700;
line-height: 125rpx;
}
.value {
color: #FF2323;
font-size: 102rpx;
font-weight: 700;
line-height: 125rpx;
}
.unit {
width: 299rpx;
height: 77rpx;
margin-left: 9rpx;
}
}
.unit {
width: 299rpx;
height: 77rpx;
margin-left: 9rpx;
}
}
&-btns {
justify-content: space-between;
margin-top: 56rpx;
}
&-btns {
justify-content: space-between;
margin-top: 56rpx;
}
&-btn {
width: 265rpx;
height: 84rpx;
}
}
&-btn {
width: 265rpx;
height: 84rpx;
}
}
</style>

+ 31
- 28
pages/index/index.vue View File

@ -5,45 +5,40 @@
<view class="content">
<navbar title="首页" bgColor="transparent" color="#FFFFFF" />
<view class="btns">
<button
v-for="item in list"
:key="item.title"
class="btn"
plain
@click="onClick(item.path)"
>
<button v-for="item in list" :key="item.title" class="btn" plain @click="onClick(item.path)">
{{ item.title }}
</button>
</view>
</view>
<popupAuditMsg ref="popupAuditMsgRef"></popupAuditMsg>
<popupAuditMsg ref="popupAuditMsgRef" count="15"></popupAuditMsg>
<popupActivate ref="popupActivate"></popupActivate>
<tabber select="home"/>
<tabber select="home" />
</view>
</template>
<script>
import { mapState } from 'vuex'
<script>
import {
mapState
} from 'vuex'
import tabber from '@/components/base/tabbar.vue'
import popupAuditMsg from '@/components/home/popupAuditMsg.vue'
import popupActivate from '@/components/center/popupActivate.vue'
export default {
components : {
components: {
tabber,
popupAuditMsg,
popupActivate,
},
data() {
return {
list: [
{
list: [{
title: '个人分享',
path: '/pages_order/record/personalSharing'
},
@ -66,26 +61,30 @@
],
}
},
computed: {
computed: {
...mapState(['userInfo']),
},
onLoad(option) {
const { id, state, shareId } = option
const {
id,
state,
shareId
} = option
if (shareId) {
uni.setStorageSync('shareId', shareId)
}
if (state) {
uni.setStorageSync('state', state)
}
if (id) {
uni.setStorageSync('id', id)
}
if (shareId && !uni.getStorageSync('token')) {
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
@ -97,6 +96,9 @@
this.$store.commit('getUserInfo')
}
},
onShow() {
this.getMsg()
},
methods: {
onClick(url) {
if (!uni.getStorageSync('token')) {
@ -111,21 +113,23 @@
return
}
this.$utils.navigateTo(url)
}
},
getMsg(){
this.$refs.popupAuditMsgRef.open()
},
},
}
</script>
<style scoped lang="scss">
.page{
& /deep/ .uv-icon__icon{
.page {
& /deep/ .uv-icon__icon {
font-size: 30rpx !important;
}
position: relative;
height: 100vh;
overflow: hidden;
overflow: hidden;
.btns {
display: grid;
@ -158,5 +162,4 @@
height: 100vh;
top: 0;
}
</style>
</style>

+ 3
- 0
pages/index/record.vue View File

@ -244,6 +244,9 @@ export default {
.title {
color: #1B1B1B;
font-size: 28rpx;
overflow:hidden; //
text-overflow:ellipsis; //
white-space:nowrap; //
}
.desc {


+ 2
- 0
pages_order/sharing/article.vue View File

@ -93,6 +93,8 @@
// }
this.initData()
shareLog.clear()
},
onShareAppMessage(res) {
const {


+ 2
- 0
pages_order/sharing/group.vue View File

@ -89,6 +89,8 @@
// }
this.fetchDetails()
shareLog.clear()
},
onShareAppMessage(res) {


+ 2
- 0
pages_order/sharing/personal.vue View File

@ -89,6 +89,8 @@
// })
// }
this.fetchDetails()
shareLog.clear()
},
onShareAppMessage(res) {
const {


+ 2
- 1
pages_order/sharing/video.vue View File

@ -95,7 +95,8 @@
// }
this.initData()
shareLog.clear()
},
onShareAppMessage(res) {
const {


+ 37
- 27
utils/shareLog.js View File

@ -1,44 +1,54 @@
import fetch from '@/api/fetch.js'
const slog = {}
let slog = {}
const get = () => {
try {
return slog
// return JSON.parse(uni.getStorageSync('shareLog')) || {}
} catch (err) {
return {}
}
try {
return slog
// return JSON.parse(uni.getStorageSync('shareLog')) || {}
} catch (err) {
return {}
}
}
const clear = () => {
slog = {}
}
const insert = (id) => {
const log = get()
const log = get()
let bef = log[id] || 0
let bef = log[id] || 0
log[id] = bef + 1
log[id] = bef + 1
uni.setStorageSync('shareLog', JSON.stringify(log))
uni.setStorageSync('shareLog', JSON.stringify(log))
}
const check = async (id, need_num) => {
try {
const log = get()
const num = parseInt(log[id]) || 0
const safeNeedNum = parseInt(need_num) || 0
const open = num >= safeNeedNum
return { open, need_num: safeNeedNum, num, title: `已转发${num}` }
} catch (err) {
console.error('--校验达标异常', err)
return {}
}
try {
const log = get()
const num = parseInt(log[id]) || 0
const safeNeedNum = parseInt(need_num) || 0
const open = num >= safeNeedNum
return {
open,
need_num: safeNeedNum,
num,
title: `已转发${num}`
}
} catch (err) {
console.error('--校验达标异常', err)
return {}
}
}
export default {
get,
insert,
check,
get,
insert,
check,
clear,
}

Loading…
Cancel
Save