Browse Source

feat: 支持不登录转发;

pull/12/head
Fox-33 1 month ago
parent
commit
6cedd4d0e1
9 changed files with 128 additions and 47 deletions
  1. +3
    -1
      pages_order/record/articleSharing.vue
  2. +3
    -0
      pages_order/record/groupSharing.vue
  3. +3
    -0
      pages_order/record/personalSharing.vue
  4. +3
    -0
      pages_order/record/videoSharing.vue
  5. +19
    -10
      pages_order/sharing/article.vue
  6. +21
    -10
      pages_order/sharing/group.vue
  7. +19
    -10
      pages_order/sharing/personal.vue
  8. +16
    -16
      pages_order/sharing/video.vue
  9. +41
    -0
      utils/shareLog.js

+ 3
- 1
pages_order/record/articleSharing.vue View File

@ -119,6 +119,7 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import formInput from '../components/formInput.vue'
import formNumberBox from '../components/formNumberBox.vue'
@ -189,7 +190,8 @@
state:"3",
}
this.$fetch('addLogShareInfo', params)
// todo: get times and check is unlocked
shareLog.insert(this.id)
this.isLocked = false


+ 3
- 0
pages_order/record/groupSharing.vue View File

@ -134,6 +134,7 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import formInput from '../components/formInput.vue'
import formNumberBox from '../components/formNumberBox.vue'
@ -249,6 +250,8 @@
}
this.$fetch('addLogShareInfo', params)
shareLog.insert(this.id)
this.isLocked = false
return o


+ 3
- 0
pages_order/record/personalSharing.vue View File

@ -127,6 +127,7 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import formInput from '../components/formInput.vue'
import formNumberBox from '../components/formNumberBox.vue'
@ -235,6 +236,8 @@
}
this.$fetch('addLogShareInfo', params)
shareLog.insert(this.id)
this.isLocked = false
return o


+ 3
- 0
pages_order/record/videoSharing.vue View File

@ -123,6 +123,7 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import formUpload from '../components/formUpload.vue'
import formInput from '../components/formInput.vue'
@ -241,6 +242,8 @@
this.$fetch('addLogShareInfo', params)
// todo: get times and check is unlocked
shareLog.insert(this.id)
this.isLocked = false
return o


+ 19
- 10
pages_order/sharing/article.vue View File

@ -27,6 +27,8 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import popupUnlock from '../components/popupUnlock.vue'
import popupQrCode from '../components/popupQrCode.vue'
@ -54,8 +56,12 @@
...mapState(['userInfo']),
},
onShow() {
if (this.id && uni.getStorageSync('token')) {
this.detail.id ? this.refreshLockStatus() : this.initData()
// if (this.id && uni.getStorageSync('token')) {
// this.detail.id ? this.refreshLockStatus() : this.initData()
// }
if (this.detail.id) { //
this.refreshLockStatus()
}
},
async onLoad(option) {
@ -75,14 +81,15 @@
this.id = id
if (uni.getStorageSync('token')) {
this.initData()
} else {
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
}
// if (uni.getStorageSync('token')) {
// this.initData()
// } else {
// uni.navigateTo({
// url: '/pages_order/auth/wxLogin'
// })
// }
this.initData()
},
onShareAppMessage(res) {
const {
@ -103,6 +110,8 @@
}
this.$fetch('addLogShareInfo', params)
shareLog.insert(this.id)
return o
},
methods: {
@ -135,7 +144,7 @@
},
async fetchCheckShare() {
try {
return await this.$fetch('checkArticleShare', { id: this.id })
return shareLog.check(this.id, this.detail.num)
} catch (err) {
return {}
}


+ 21
- 10
pages_order/sharing/group.vue View File

@ -22,6 +22,8 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import popupUnlock from '../components/popupUnlock.vue'
export default {
@ -47,8 +49,12 @@
...mapState(['userInfo']),
},
onShow() {
if (this.id && uni.getStorageSync('token')) {
this.detail.id ? this.refreshLockStatus() : this.fetchDetails()
// if (this.id && uni.getStorageSync('token')) {
// this.detail.id ? this.refreshLockStatus() : this.fetchDetails()
// }
if (this.detail.id) { //
this.refreshLockStatus()
}
},
onLoad(option) {
@ -68,13 +74,16 @@
this.id = id
if (uni.getStorageSync('token')) {
this.fetchDetails()
} else {
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
}
// if (uni.getStorageSync('token')) {
// this.fetchDetails()
// } else {
// uni.navigateTo({
// url: '/pages_order/auth/wxLogin'
// })
// }
this.fetchDetails()
},
onShareAppMessage(res) {
const {
@ -95,6 +104,8 @@
}
this.$fetch('addLogShareInfo', params)
shareLog.insert(this.id)
return o
},
methods: {
@ -107,7 +118,7 @@
},
async fetchCheckShare() {
try {
return await this.$fetch('checkGroupShare', { id: this.id })
return await shareLog.check(this.id, this.detail.num)
} catch (err) {
return {}
}


+ 19
- 10
pages_order/sharing/personal.vue View File

@ -22,6 +22,8 @@
<script>
import { mapState } from 'vuex'
import shareLog from '@/utils/shareLog'
import popupUnlock from '../components/popupUnlock.vue'
export default {
@ -48,8 +50,12 @@
...mapState(['userInfo']),
},
onShow() {
if (this.id && uni.getStorageSync('token')) {
this.detail.id ? this.refreshLockStatus() : this.fetchDetails()
// if (this.id && uni.getStorageSync('token')) {
// this.detail.id ? this.refreshLockStatus() : this.fetchDetails()
// }
if (this.detail.id) { //
this.refreshLockStatus()
}
},
onLoad(option) {
@ -69,13 +75,14 @@
this.id = id
if (uni.getStorageSync('token')) {
this.fetchDetails()
} else {
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
}
// if (uni.getStorageSync('token')) {
// this.fetchDetails()
// } else {
// uni.navigateTo({
// url: '/pages_order/auth/wxLogin'
// })
// }
this.fetchDetails()
},
onShareAppMessage(res) {
const {
@ -96,6 +103,8 @@
}
this.$fetch('addLogShareInfo', params)
shareLog.insert(this.id)
return o
},
methods: {
@ -108,7 +117,7 @@
},
async fetchCheckShare() {
try {
return await this.$fetch('checkShare', { id: this.id })
return await shareLog.check(this.id, this.detail.num)
} catch (err) {
return {}
}


+ 16
- 16
pages_order/sharing/video.vue View File

@ -31,6 +31,7 @@
<script>
import { mapState } from 'vuex'
import popupUnlock from '../components/popupUnlock.vue'
import popupQrCode from '../components/popupQrCode.vue'
@ -61,8 +62,12 @@
...mapState(['userInfo']),
},
onShow() {
if (this.id && uni.getStorageSync('token')) {
this.detail.id ? this.refreshLockStatus() : this.initData()
// if (this.id && uni.getStorageSync('token')) {
// this.detail.id ? this.refreshLockStatus() : this.initData()
// }
if (this.detail.id) { //
this.refreshLockStatus()
}
},
async onLoad(option) {
@ -82,13 +87,15 @@
this.id = id
if(uni.getStorageSync('token')){
this.initData()
}else{
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
}
// if(uni.getStorageSync('token')){
// this.initData()
// }else{
// uni.navigateTo({
// url: '/pages_order/auth/wxLogin'
// })
// }
this.initData()
},
onShareAppMessage(res) {
@ -126,13 +133,6 @@
this.videoContext = uni.createVideoContext('video');
},
async fetchCheckShare() {
try {
return await this.$fetch('checkVideoShare', { id: this.id })
} catch (err) {
return {}
}
},
refreshLockStatus() {
this.isLocked = false
this.timeIsUp = false


+ 41
- 0
utils/shareLog.js View File

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

Loading…
Cancel
Save