| @ -1,121 +1,111 @@ | |||
| <template> | |||
| <uv-popup | |||
| ref="popup" | |||
| :overlayOpacity="0.8" | |||
| :customStyle="{ | |||
| backgroundColor: 'transparent', | |||
| }" | |||
| > | |||
| <view class="flex content"> | |||
| <template v-if="mode === 'activate'"> | |||
| <image class="popup-bg" src="@/pages_order/static/center/activate-code.png"></image> | |||
| <uv-popup ref="popup" :overlayOpacity="0.8" :customStyle="{ | |||
| backgroundColor: 'transparent', | |||
| }"> | |||
| <view class="flex content"> | |||
| <template v-if="mode === 'activate'"> | |||
| <image class="popup-bg" src="@/pages_order/static/center/activate-code.png"></image> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" @click="onConfirm"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/confirm.png"></image> | |||
| </button> | |||
| </view> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" @click="onConfirm"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/confirm.png"></image> | |||
| </button> | |||
| </view> | |||
| <uv-input | |||
| v-model="code" | |||
| :focus="true" | |||
| inputAlign="center" | |||
| color="#3DFEE0" | |||
| fontSize="45rpx" | |||
| border="none" | |||
| :customStyle="{ | |||
| backgroundColor: 'transparent', | |||
| width: '250rpx', | |||
| height: '63rpx', | |||
| position: 'absolute', | |||
| top: '216rpx', | |||
| left: '160rpx', | |||
| }" | |||
| ></uv-input> | |||
| </template> | |||
| <template v-else> | |||
| <image class="popup-bg" src="@/pages_order/static/center/not-agent.png"></image> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" @click="mode = 'activate'" > | |||
| <image class="popup-btn" src="@/pages_order/static/center/activate.png"></image> | |||
| </button> | |||
| <uv-input v-model="code" :focus="true" inputAlign="center" color="#3DFEE0" fontSize="45rpx" | |||
| border="none" :customStyle="{ | |||
| backgroundColor: 'transparent', | |||
| width: '250rpx', | |||
| height: '63rpx', | |||
| position: 'absolute', | |||
| top: '216rpx', | |||
| left: '160rpx', | |||
| }"></uv-input> | |||
| </template> | |||
| <template v-else> | |||
| <image class="popup-bg" src="@/pages_order/static/center/not-agent.png"></image> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" @click="mode = 'activate'"> | |||
| <image class="popup-btn" src="@/pages_order/static/center/activate.png"></image> | |||
| </button> | |||
| </view> | |||
| </template> | |||
| </view> | |||
| </template> | |||
| </view> | |||
| </uv-popup> | |||
| </uv-popup> | |||
| </template> | |||
| <script> | |||
| export default { | |||
| export default { | |||
| props: { | |||
| role: { | |||
| default: null | |||
| } | |||
| role: { | |||
| default: null | |||
| }, | |||
| }, | |||
| data() { | |||
| return { | |||
| mode: '', | |||
| code: '', | |||
| } | |||
| data() { | |||
| return { | |||
| mode: '', | |||
| code: '', | |||
| } | |||
| }, | |||
| methods: { | |||
| open(role) { | |||
| this.mode = role ? 'activate' : '' | |||
| this.$refs.popup.open(); | |||
| }, | |||
| close() { | |||
| this.$refs.popup.close(); | |||
| }, | |||
| async onConfirm() { | |||
| try { | |||
| open(role) { | |||
| this.mode = role ? 'activate' : '' | |||
| this.$refs.popup.open(); | |||
| }, | |||
| close() { | |||
| this.$refs.popup.close(); | |||
| }, | |||
| async onConfirm() { | |||
| await this.$fetch('openVip', { code: this.code }) | |||
| this.$store.commit('getUserInfo') | |||
| try { | |||
| uni.showToast({ | |||
| title: '激活成功', | |||
| icon: 'none' | |||
| }) | |||
| this.close() | |||
| } catch (err) { | |||
| await this.$fetch('openVip', { code: this.code }) | |||
| } | |||
| this.$store.commit('getUserInfo') | |||
| uni.showToast({ | |||
| title: '激活成功', | |||
| icon: 'none' | |||
| }) | |||
| } | |||
| this.close() | |||
| } catch (err) { | |||
| } | |||
| } | |||
| }, | |||
| } | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .content { | |||
| position: relative; | |||
| flex-direction: column; | |||
| width: 570rpx; | |||
| position: relative; | |||
| flex-direction: column; | |||
| width: 570rpx; | |||
| } | |||
| .popup { | |||
| &-bg { | |||
| width: 514rpx; height: 355rpx; | |||
| } | |||
| &-bg { | |||
| width: 514rpx; | |||
| height: 355rpx; | |||
| } | |||
| &-btns { | |||
| justify-content: space-between; | |||
| margin-top: 56rpx; | |||
| width: 100%; | |||
| } | |||
| &-btns { | |||
| justify-content: space-between; | |||
| margin-top: 56rpx; | |||
| width: 100%; | |||
| } | |||
| &-btn { | |||
| width: 265rpx; | |||
| height: 84rpx; | |||
| } | |||
| &-btn { | |||
| width: 265rpx; | |||
| height: 84rpx; | |||
| } | |||
| } | |||
| </style> | |||
| @ -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> | |||
| @ -1,287 +1,327 @@ | |||
| <template> | |||
| <view class="page"> | |||
| <navbar title="分享记录" /> | |||
| <view class="content"> | |||
| <view class="card" style="padding-left: 0; padding-right: 10rpx;"> | |||
| <uv-tabs | |||
| :list="tabs" | |||
| @click="clickTabs" | |||
| :inactiveStyle="{ | |||
| color: '#999999', | |||
| fontSize: '30rpx', | |||
| fontWeight: 500, | |||
| whiteSpace: 'nowrap', | |||
| }" | |||
| :activeStyle="{ | |||
| color: '#1B1B1B', | |||
| fontSize: '38rpx', | |||
| fontWeight: 900, | |||
| whiteSpace: 'nowrap', | |||
| }" | |||
| lineHeight="13rpx" | |||
| lineWidth="77rpx" | |||
| :lineColor="`url(${sliderBgUrl}) 100% 100%`" | |||
| :scrollable="false" | |||
| > | |||
| <template v-slot:right> | |||
| <suspendDropdown | |||
| v-model="status" | |||
| :options="auditStatusOptions" | |||
| @change="onAuditStatusChange" | |||
| ></suspendDropdown> | |||
| </template> | |||
| </uv-tabs> | |||
| </view> | |||
| <view v-if="list.length" class="card list"> | |||
| <view class="list-item" | |||
| v-for="item in list" | |||
| @click="toSharingDetail(item.id)" | |||
| :key="item.id" | |||
| > | |||
| <!-- todo: video? --> | |||
| <image class="left" :src="item.indexImage || item.headImage"></image> | |||
| <view class="right"> | |||
| <view class="title">{{ item.headTitle || '' }}</view> | |||
| <view class="desc">{{ item.textDetails || '' }}</view> | |||
| <view class="bottom"> | |||
| <text class="desc">{{ item.createTime || '' }}</text> | |||
| <button plain class="btn-simple btn-delete flex" @click.stop="onDelete(item.id)"> | |||
| <image src="../../static/image/record/delete.png" style="width: 24rpx; height: 24rpx;"></image> | |||
| <text style="margin-left: 10rpx;">删除</text> | |||
| </button> | |||
| </view> | |||
| <view class="mark"> | |||
| <image | |||
| :src="auditStatusImgMapping[item.status]" | |||
| style="width: 100rpx; height: 100rpx;" | |||
| ></image> | |||
| </view> | |||
| </view> | |||
| </view> | |||
| </view> | |||
| <!-- todo: empty --> | |||
| </view> | |||
| <popupActivate ref="popupActivate"></popupActivate> | |||
| <tabber select="record"/> | |||
| </view> | |||
| <view class="page"> | |||
| <navbar title="分享记录" /> | |||
| <view class="content"> | |||
| <view class="card" style="padding-left: 0; padding-right: 10rpx;"> | |||
| <uv-tabs :list="tabs" @click="clickTabs" :inactiveStyle="{ | |||
| color: '#999999', | |||
| fontSize: '30rpx', | |||
| fontWeight: 500, | |||
| whiteSpace: 'nowrap', | |||
| }" :activeStyle="{ | |||
| color: '#1B1B1B', | |||
| fontSize: '38rpx', | |||
| fontWeight: 900, | |||
| whiteSpace: 'nowrap', | |||
| }" lineHeight="13rpx" lineWidth="77rpx" :lineColor="`url(${sliderBgUrl}) 100% 100%`" :scrollable="false"> | |||
| <template v-slot:right> | |||
| <suspendDropdown v-model="status" :options="auditStatusOptions" @change="onAuditStatusChange"> | |||
| </suspendDropdown> | |||
| </template> | |||
| </uv-tabs> | |||
| </view> | |||
| <view v-if="!isLoggedIn" class="card login-tip"> | |||
| <view class="login-tip-text">登录后查看分享记录</view> | |||
| <button class="btn-login" @click="goToLogin">立即登录</button> | |||
| </view> | |||
| <view v-else-if="list.length" class="card list"> | |||
| <view class="list-item" v-for="item in list" @click="toSharingDetail(item.id)" :key="item.id"> | |||
| <!-- todo: video? --> | |||
| <image class="left" :src="item.indexImage || item.headImage"></image> | |||
| <view class="right"> | |||
| <view class="title">{{ item.headTitle || '' }}</view> | |||
| <view class="desc">{{ item.textDetails || '' }}</view> | |||
| <view class="bottom"> | |||
| <text class="desc">{{ item.createTime || '' }}</text> | |||
| <button plain class="btn-simple btn-delete flex" @click.stop="onDelete(item.id)"> | |||
| <image src="../../static/image/record/delete.png" style="width: 24rpx; height: 24rpx;"> | |||
| </image> | |||
| <text style="margin-left: 10rpx;">删除</text> | |||
| </button> | |||
| </view> | |||
| <view class="mark"> | |||
| <image :src="auditStatusImgMapping[item.status]" style="width: 100rpx; height: 100rpx;"> | |||
| </image> | |||
| </view> | |||
| </view> | |||
| </view> | |||
| </view> | |||
| <!-- todo: empty --> | |||
| </view> | |||
| <popupActivate ref="popupActivate"></popupActivate> | |||
| <tabber select="record" /> | |||
| </view> | |||
| </template> | |||
| <script> | |||
| import { mapGetters } from 'vuex' | |||
| import mixinsList from '@/mixins/list.js' | |||
| import tabber from '@/components/base/tabbar.vue' | |||
| import suspendDropdown from '@/components/base/suspendDropdown.vue' | |||
| import popupActivate from '@/components/center/popupActivate.vue' | |||
| const URL_MAPPING = { // state -> url | |||
| '0': '/pages_order/record/personalSharing', | |||
| '1': '/pages_order/record/videoSharing', | |||
| '2': '/pages_order/record/groupSharing', | |||
| '3': '/pages_order/record/articleSharing', | |||
| } | |||
| export default { | |||
| mixins : [mixinsList], | |||
| components : { | |||
| tabber, | |||
| suspendDropdown, | |||
| popupActivate, | |||
| }, | |||
| computed : { | |||
| ...mapGetters(['userShop']), | |||
| }, | |||
| data() { | |||
| return { | |||
| tabs: [{ | |||
| name: '个人分享' | |||
| }, | |||
| { | |||
| name: '视频分享' | |||
| }, | |||
| { | |||
| name: '群分享' | |||
| }, | |||
| { | |||
| name: '文章分享' | |||
| }, | |||
| ], | |||
| auditStatusOptions: [ | |||
| { | |||
| label: '审核中', | |||
| value: 0, | |||
| }, | |||
| { | |||
| label: '已通过', | |||
| value: 1, | |||
| }, | |||
| { | |||
| label: '未通过', | |||
| value: 2, | |||
| }, | |||
| ], | |||
| queryParams: { | |||
| pageNo: 1, | |||
| pageSize: 10, | |||
| state: 0, | |||
| }, | |||
| status: null, | |||
| recordList : { // 列表数据 | |||
| records : [], | |||
| total : 0, | |||
| }, | |||
| auditStatusImgMapping: { | |||
| 0: '../../static/image/record/audit.png', // 审核中 | |||
| 1: '../../static/image/record/pass.png', // 已通过 | |||
| 2: '../../static/image/record/fail.png', // 未通过 | |||
| }, | |||
| // todo | |||
| sliderBgUrl: '', | |||
| mixinsListApi : 'getSharePage', | |||
| } | |||
| }, | |||
| methods: { | |||
| //点击tab栏 | |||
| clickTabs(e) { | |||
| this.queryParams.state = e.index | |||
| this.queryParams.pageNo = 1 | |||
| this.queryParams.pageSize = 10 | |||
| this.getData() | |||
| }, | |||
| onAuditStatusChange(status) { | |||
| this.status = status | |||
| this.queryParams.pageNo = 1 | |||
| this.queryParams.pageSize = 10 | |||
| if (status === null) { | |||
| delete this.queryParams.status | |||
| } else { | |||
| this.queryParams.status = status | |||
| } | |||
| this.getData() | |||
| }, | |||
| //跳转分享详情页面 | |||
| toSharingDetail(id) { | |||
| if (!this.userInfo.isPay) { | |||
| this.$refs.popupActivate.open() | |||
| return | |||
| } | |||
| uni.navigateTo({ | |||
| url: `${URL_MAPPING[this.queryParams.state]}?id=${id}` | |||
| }) | |||
| }, | |||
| onDelete(id) { | |||
| uni.showModal({ | |||
| title: '确认删除该分享吗', | |||
| success: async (r) => { | |||
| if(r.confirm){ | |||
| await this.$fetch('deleteLog', { id, state: this.queryParams.state }) | |||
| this.getData() | |||
| } | |||
| } | |||
| }) | |||
| }, | |||
| } | |||
| } | |||
| import { mapGetters } from 'vuex' | |||
| import mixinsList from '@/mixins/list.js' | |||
| import tabber from '@/components/base/tabbar.vue' | |||
| import suspendDropdown from '@/components/base/suspendDropdown.vue' | |||
| import popupActivate from '@/components/center/popupActivate.vue' | |||
| const URL_MAPPING = { // state -> url | |||
| '0': '/pages_order/record/personalSharing', | |||
| '1': '/pages_order/record/videoSharing', | |||
| '2': '/pages_order/record/groupSharing', | |||
| '3': '/pages_order/record/articleSharing', | |||
| } | |||
| export default { | |||
| mixins: [mixinsList], | |||
| components: { | |||
| tabber, | |||
| suspendDropdown, | |||
| popupActivate, | |||
| }, | |||
| computed: { | |||
| ...mapGetters(['userShop']), | |||
| }, | |||
| data() { | |||
| return { | |||
| tabs: [{ | |||
| name: '个人分享' | |||
| }, | |||
| { | |||
| name: '视频分享' | |||
| }, | |||
| { | |||
| name: '群分享' | |||
| }, | |||
| { | |||
| name: '文章分享' | |||
| }, | |||
| ], | |||
| auditStatusOptions: [ | |||
| { | |||
| label: '审核中', | |||
| value: 0, | |||
| }, | |||
| { | |||
| label: '已通过', | |||
| value: 1, | |||
| }, | |||
| { | |||
| label: '未通过', | |||
| value: 2, | |||
| }, | |||
| ], | |||
| queryParams: { | |||
| pageNo: 1, | |||
| pageSize: 10, | |||
| state: 0, | |||
| }, | |||
| status: null, | |||
| recordList: { // 列表数据 | |||
| records: [], | |||
| total: 0, | |||
| }, | |||
| auditStatusImgMapping: { | |||
| 0: '../../static/image/record/audit.png', // 审核中 | |||
| 1: '../../static/image/record/pass.png', // 已通过 | |||
| 2: '../../static/image/record/fail.png', // 未通过 | |||
| }, | |||
| // todo | |||
| sliderBgUrl: '', | |||
| mixinsListApi: 'getSharePage', | |||
| authApi : true, | |||
| isLoggedIn : uni.getStorageSync('token'), | |||
| } | |||
| }, | |||
| onShow(){ | |||
| this.isLoggedIn = uni.getStorageSync('token') | |||
| }, | |||
| methods: { | |||
| //点击tab栏 | |||
| clickTabs(e) { | |||
| if (!this.isLoggedIn) { | |||
| this.goToLogin() | |||
| return | |||
| } | |||
| this.queryParams.state = e.index | |||
| this.queryParams.pageNo = 1 | |||
| this.queryParams.pageSize = 10 | |||
| this.getData() | |||
| }, | |||
| onAuditStatusChange(status) { | |||
| if (!this.isLoggedIn) { | |||
| this.goToLogin() | |||
| return | |||
| } | |||
| this.status = status | |||
| this.queryParams.pageNo = 1 | |||
| this.queryParams.pageSize = 10 | |||
| if (status === null) { | |||
| delete this.queryParams.status | |||
| } else { | |||
| this.queryParams.status = status | |||
| } | |||
| this.getData() | |||
| }, | |||
| //跳转分享详情页面 | |||
| toSharingDetail(id) { | |||
| if (!this.isLoggedIn) { | |||
| this.goToLogin() | |||
| return | |||
| } | |||
| if (!this.userInfo.isPay) { | |||
| this.$refs.popupActivate.open() | |||
| return | |||
| } | |||
| uni.navigateTo({ | |||
| url: `${URL_MAPPING[this.queryParams.state]}?id=${id}` | |||
| }) | |||
| }, | |||
| onDelete(id) { | |||
| if (!this.isLoggedIn) { | |||
| this.goToLogin() | |||
| return | |||
| } | |||
| uni.showModal({ | |||
| title: '确认删除该分享吗', | |||
| success: async (r) => { | |||
| if (r.confirm) { | |||
| await this.$fetch('deleteLog', { id, state: this.queryParams.state }) | |||
| this.getData() | |||
| } | |||
| } | |||
| }) | |||
| }, | |||
| goToLogin() { | |||
| uni.navigateTo({ | |||
| url: '/pages_order/auth/wxLogin' | |||
| }) | |||
| }, | |||
| } | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .page{ | |||
| } | |||
| .content { | |||
| padding: 20rpx; | |||
| } | |||
| .list { | |||
| margin-top: 20rpx; | |||
| padding: 40rpx 59rpx 40rpx 43rpx; | |||
| &-item { | |||
| font-size: 0; | |||
| display: flex; | |||
| & + & { | |||
| margin-top: 40rpx; | |||
| } | |||
| .left { | |||
| width: 220rpx; | |||
| height: 148rpx; | |||
| } | |||
| .right { | |||
| flex: 1; | |||
| width: calc(100% - 220rpx); | |||
| padding-left: 20rpx; | |||
| box-sizing: border-box; | |||
| position: relative; | |||
| } | |||
| } | |||
| .title { | |||
| color: #1B1B1B; | |||
| font-size: 28rpx; | |||
| } | |||
| .desc { | |||
| color: #999999; | |||
| font-size: 24rpx; | |||
| white-space: nowrap; | |||
| overflow: hidden; | |||
| text-overflow: ellipsis; | |||
| text-align: left; | |||
| } | |||
| .title + .desc { | |||
| margin-top: 18rpx; | |||
| } | |||
| .bottom { | |||
| position: absolute; | |||
| bottom: 0; | |||
| width: calc(100% - 20rpx); | |||
| } | |||
| .btn-delete { | |||
| float: right; | |||
| color: #05D9A2; | |||
| font-size: 20rpx; | |||
| } | |||
| .mark { | |||
| position: absolute; | |||
| top: 10rpx; | |||
| right: 5rpx; | |||
| } | |||
| } | |||
| .popup { | |||
| &-options { | |||
| box-shadow: 0 2px 12px 0 rgba(0,0,0,.1); | |||
| padding: 16rpx 40rpx; | |||
| } | |||
| &-option { | |||
| color: #999999; | |||
| font-size: 28rpx; | |||
| &.is-active { | |||
| color: #1B1B1B; | |||
| font-weight: 700; | |||
| } | |||
| & + & { | |||
| margin-top: 16rpx; | |||
| } | |||
| } | |||
| } | |||
| .page {} | |||
| .content { | |||
| padding: 20rpx; | |||
| } | |||
| .list { | |||
| margin-top: 20rpx; | |||
| padding: 40rpx 59rpx 40rpx 43rpx; | |||
| &-item { | |||
| font-size: 0; | |||
| display: flex; | |||
| &+& { | |||
| margin-top: 40rpx; | |||
| } | |||
| .left { | |||
| width: 220rpx; | |||
| height: 148rpx; | |||
| } | |||
| .right { | |||
| flex: 1; | |||
| width: calc(100% - 220rpx); | |||
| padding-left: 20rpx; | |||
| box-sizing: border-box; | |||
| position: relative; | |||
| } | |||
| } | |||
| .title { | |||
| color: #1B1B1B; | |||
| font-size: 28rpx; | |||
| overflow:hidden; //超出的文本隐藏 | |||
| text-overflow:ellipsis; //溢出用省略号显示 | |||
| white-space:nowrap; //溢出不换行 | |||
| } | |||
| .desc { | |||
| color: #999999; | |||
| font-size: 24rpx; | |||
| white-space: nowrap; | |||
| overflow: hidden; | |||
| text-overflow: ellipsis; | |||
| text-align: left; | |||
| } | |||
| .title+.desc { | |||
| margin-top: 18rpx; | |||
| } | |||
| .bottom { | |||
| position: absolute; | |||
| bottom: 0; | |||
| width: calc(100% - 20rpx); | |||
| } | |||
| .btn-delete { | |||
| float: right; | |||
| color: #05D9A2; | |||
| font-size: 20rpx; | |||
| } | |||
| .mark { | |||
| position: absolute; | |||
| top: 10rpx; | |||
| right: 5rpx; | |||
| } | |||
| } | |||
| .popup { | |||
| &-options { | |||
| box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1); | |||
| padding: 16rpx 40rpx; | |||
| } | |||
| &-option { | |||
| color: #999999; | |||
| font-size: 28rpx; | |||
| &.is-active { | |||
| color: #1B1B1B; | |||
| font-weight: 700; | |||
| } | |||
| &+& { | |||
| margin-top: 16rpx; | |||
| } | |||
| } | |||
| } | |||
| .login-tip { | |||
| margin-top: 20rpx; | |||
| padding: 40rpx; | |||
| text-align: center; | |||
| &-text { | |||
| color: #999999; | |||
| font-size: 28rpx; | |||
| margin-bottom: 20rpx; | |||
| } | |||
| } | |||
| .btn-login { | |||
| width: 240rpx; | |||
| height: 80rpx; | |||
| line-height: 80rpx; | |||
| background: #04D6A3; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| border-radius: 40rpx; | |||
| margin: 0 auto; | |||
| } | |||
| </style> | |||
| @ -1,63 +1,59 @@ | |||
| <template> | |||
| <uv-popup | |||
| ref="popup" | |||
| :overlayOpacity="0.8" | |||
| :customStyle="{ | |||
| <uv-popup ref="popup" :overlayOpacity="0.8" :customStyle="{ | |||
| backgroundColor: 'transparent', | |||
| }" | |||
| > | |||
| <view> | |||
| <image class="popup-bg" :src="src"></image> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="../static/sharing/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" open-type="share"> | |||
| <image class="popup-btn" src="../static/sharing/forward.png"></image> | |||
| </button> | |||
| </view> | |||
| </view> | |||
| </uv-popup> | |||
| }"> | |||
| <view> | |||
| <image class="popup-bg" :src="src"></image> | |||
| <view class="flex popup-btns"> | |||
| <button plain class="btn-simple" @click="close"> | |||
| <image class="popup-btn" src="../static/sharing/cancel.png"></image> | |||
| </button> | |||
| <button plain class="btn-simple" open-type="share"> | |||
| <image class="popup-btn" src="../static/sharing/forward.png"></image> | |||
| </button> | |||
| </view> | |||
| </view> | |||
| </uv-popup> | |||
| </template> | |||
| <script> | |||
| export default { | |||
| props: { | |||
| src: { | |||
| type: String, | |||
| default: null | |||
| } | |||
| }, | |||
| props: { | |||
| src: { | |||
| type: String, | |||
| default: null | |||
| } | |||
| }, | |||
| data() { | |||
| return { | |||
| } | |||
| }, | |||
| methods: { | |||
| open() { | |||
| this.$refs.popup.open(); | |||
| }, | |||
| close() { | |||
| console.log('--close popup') | |||
| this.$refs.popup.close(); | |||
| }, | |||
| }, | |||
| } | |||
| return {} | |||
| }, | |||
| methods: { | |||
| open() { | |||
| this.$refs.popup.open(); | |||
| }, | |||
| close() { | |||
| console.log('--close popup') | |||
| this.$refs.popup.close(); | |||
| }, | |||
| }, | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .popup { | |||
| &-bg { | |||
| width: 578rpx; height: 317rpx; | |||
| } | |||
| .popup { | |||
| &-bg { | |||
| width: 578rpx; | |||
| height: 317rpx; | |||
| } | |||
| &-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> | |||
| @ -1,237 +1,253 @@ | |||
| <template> | |||
| <view> | |||
| <view class="content"> | |||
| <view class="title">{{ detail.headTitle || '' }}</view> | |||
| <view class="desc">{{ detail.createTime ? `发布于${detail.createTime}` : '' }}</view> | |||
| <editor id="editor" class="editor" | |||
| :read-only="true" | |||
| @ready="onEditorReady" | |||
| ></editor> | |||
| </view> | |||
| <uv-overlay :show="true" :opacity="0" zIndex="998"> | |||
| <navbar leftClick @leftClick="$utils.navigateBack" /> | |||
| <button class="btn" type="success" @click="onJoin">查看更多</button> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-article.png"></popupUnlock> | |||
| <popupQrCode ref="popupQrCode" :src="detail.wxCodeImage"></popupQrCode> | |||
| </uv-overlay> | |||
| </view> | |||
| <view> | |||
| <view class="content"> | |||
| <view class="title">{{ detail.headTitle || '' }}</view> | |||
| <view class="desc">{{ detail.createTime ? `发布于${detail.createTime}` : '' }}</view> | |||
| <editor id="editor" class="editor" :read-only="true" @ready="onEditorReady"></editor> | |||
| </view> | |||
| <uv-overlay :show="true" :opacity="0" zIndex="998"> | |||
| <navbar leftClick @leftClick="$utils.navigateBack" /> | |||
| <button class="btn" type="success" @click="onJoin">查看更多</button> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-article.png"></popupUnlock> | |||
| <popupQrCode ref="popupQrCode" :src="detail.wxCodeImage"></popupQrCode> | |||
| </uv-overlay> | |||
| </view> | |||
| </template> | |||
| <script> | |||
| import { mapState } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import { | |||
| mapState | |||
| } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupQrCode from '../components/popupQrCode.vue' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupQrCode from '../components/popupQrCode.vue' | |||
| export default { | |||
| components: { | |||
| popupUnlock, | |||
| popupQrCode, | |||
| }, | |||
| components: { | |||
| popupUnlock, | |||
| popupQrCode, | |||
| }, | |||
| data() { | |||
| return { | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| userId: null, | |||
| headImage: null, | |||
| headTitle: null, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| userId: null, | |||
| headImage: null, | |||
| headTitle: null, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| computed: { | |||
| ...mapState(['userInfo']), | |||
| }, | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.initData() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| async onLoad(option) { | |||
| const { id, state, shareId } = option | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.initData() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| async onLoad(option) { | |||
| const { | |||
| id, | |||
| state, | |||
| shareId | |||
| } = option | |||
| if (shareId) { | |||
| uni.setStorageSync('shareId', shareId) | |||
| } | |||
| if (state) { | |||
| uni.setStorageSync('state', state) | |||
| } | |||
| if (id) { | |||
| uni.setStorageSync('id', id) | |||
| } | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.initData() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.initData() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| headTitle, | |||
| headImage, | |||
| } = this.detail | |||
| let o = { | |||
| title : headTitle, | |||
| imageUrl: headImage, | |||
| query: `id=${this.id}&state=3&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id:this.id, | |||
| state:"3", | |||
| } | |||
| this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| onEditorReady() { | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.initData() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.initData() | |||
| shareLog.clear() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| headTitle, | |||
| headImage, | |||
| } = this.detail | |||
| let o = { | |||
| title: headTitle, | |||
| imageUrl: headImage, | |||
| query: `id=${this.id}&state=3&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id: this.id, | |||
| state: "3", | |||
| } | |||
| // this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| onEditorReady() { | |||
| uni.createSelectorQuery().select('#editor').context((res) => { | |||
| this.editorCtx = res.context | |||
| }).exec() | |||
| }, | |||
| initEditor(html) { | |||
| if (!this.editorCtx) { | |||
| setTimeout(() => { | |||
| this.initEditor(html) | |||
| }, 200) | |||
| return | |||
| } | |||
| this.editorCtx.setContents({ html }) | |||
| }, | |||
| async fetchDetails(id) { | |||
| try { | |||
| this.detail = await this.$fetch('getArticleShareInfo', { id }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async initData() { | |||
| await this.fetchDetails(this.id) | |||
| this.initEditor(this.detail.textDetails) | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { title, open } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| this.$refs.popupQrCode.open() | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| async onJoin() { | |||
| if (!this.isLocked) { | |||
| this.$refs.popupQrCode.open() | |||
| return | |||
| } | |||
| const result = await this.fetchCheckShare() | |||
| const { open, need_num, num } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| this.$refs.popupQrCode.open() | |||
| } else { | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.$refs.popupUnlock.open(); | |||
| } | |||
| }, | |||
| } | |||
| } | |||
| initEditor(html) { | |||
| if (!this.editorCtx) { | |||
| setTimeout(() => { | |||
| this.initEditor(html) | |||
| }, 200) | |||
| return | |||
| } | |||
| this.editorCtx.setContents({ | |||
| html | |||
| }) | |||
| }, | |||
| async fetchDetails(id) { | |||
| try { | |||
| this.detail = await this.$fetch('getArticleShareInfo', { | |||
| id | |||
| }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async initData() { | |||
| await this.fetchDetails(this.id) | |||
| this.initEditor(this.detail.textDetails) | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| title, | |||
| open | |||
| } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| this.$refs.popupQrCode.open() | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| async onJoin() { | |||
| if (!this.isLocked) { | |||
| this.$refs.popupQrCode.open() | |||
| return | |||
| } | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| open, | |||
| need_num, | |||
| num | |||
| } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| this.$refs.popupQrCode.open() | |||
| } else { | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.$refs.popupUnlock.open(); | |||
| } | |||
| }, | |||
| } | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .content { | |||
| padding: 40rpx 20rpx; | |||
| padding-top: calc(#{$navbar-height} + var(--status-bar-height) + 20rpx + 40rpx); | |||
| } | |||
| .title { | |||
| color: #474747; | |||
| font-size: 36rpx; | |||
| font-weight: 700; | |||
| } | |||
| .desc { | |||
| color: #A2A2A2; | |||
| font-size: 24rpx; | |||
| margin-top: 6rpx; | |||
| } | |||
| .editor { | |||
| margin-top: 22rpx; | |||
| height: 40vh; | |||
| } | |||
| .btn { | |||
| position: absolute; | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| .content { | |||
| padding: 40rpx 20rpx; | |||
| padding-top: calc(#{$navbar-height} + var(--status-bar-height) + 20rpx + 40rpx); | |||
| } | |||
| .title { | |||
| color: #474747; | |||
| font-size: 36rpx; | |||
| font-weight: 700; | |||
| } | |||
| .desc { | |||
| color: #A2A2A2; | |||
| font-size: 24rpx; | |||
| margin-top: 6rpx; | |||
| } | |||
| .editor { | |||
| margin-top: 22rpx; | |||
| height: 40vh; | |||
| } | |||
| .btn { | |||
| position: absolute; | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| </style> | |||
| @ -1,234 +1,252 @@ | |||
| <template> | |||
| <view class="page"> | |||
| <view class="page"> | |||
| <navbar leftClick @leftClick="$utils.navigateBack" /> | |||
| <view class="content"> | |||
| <image class="avatar" :src="detail.headImage"></image> | |||
| <text class="nick-name">{{ `${detail.headTitle || ''}(${detail.memberNum || 0})` }}</text> | |||
| <view class="content"> | |||
| <image class="avatar" :src="detail.headImage"></image> | |||
| <text class="nick-name">{{ `${detail.headTitle || ''}(${detail.memberNum || 0})` }}</text> | |||
| <template v-if="isLocked"> | |||
| <button class="btn" type="success" @click="onAdd">加入</button> | |||
| </template> | |||
| <view v-else class="group-info flex"> | |||
| <text>扫一扫,加群主审核进群</text> | |||
| <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image> | |||
| </view> | |||
| </view> | |||
| <template v-if="isLocked"> | |||
| <button class="btn" type="success" @click="onAdd">加入</button> | |||
| </template> | |||
| <view v-else class="group-info flex"> | |||
| <text>扫一扫,加群主审核进群</text> | |||
| <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image> | |||
| </view> | |||
| </view> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-group.png"></popupUnlock> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-group.png"></popupUnlock> | |||
| </view> | |||
| </view> | |||
| </template> | |||
| <script> | |||
| import { mapState } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import { | |||
| mapState | |||
| } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| export default { | |||
| components: { | |||
| popupUnlock, | |||
| }, | |||
| components: { | |||
| popupUnlock, | |||
| }, | |||
| data() { | |||
| return { | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| avatarUrl: null, | |||
| nickName: null, | |||
| imageUrl: null, | |||
| times: 0, | |||
| qrCode: null, | |||
| description: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| avatarUrl: null, | |||
| nickName: null, | |||
| imageUrl: null, | |||
| times: 0, | |||
| qrCode: null, | |||
| description: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| computed: { | |||
| ...mapState(['userInfo']), | |||
| }, | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.fetchDetails() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| onLoad(option) { | |||
| const { id, state, shareId } = option | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.fetchDetails() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| onLoad(option) { | |||
| const { | |||
| id, | |||
| state, | |||
| shareId | |||
| } = option | |||
| if (shareId) { | |||
| uni.setStorageSync('shareId', shareId) | |||
| } | |||
| if (state) { | |||
| uni.setStorageSync('state', state) | |||
| } | |||
| if (id) { | |||
| uni.setStorageSync('id', id) | |||
| } | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.fetchDetails() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.fetchDetails() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| textDetails, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title : textDetails, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id:this.id, | |||
| state:"2", | |||
| } | |||
| this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails() { | |||
| try { | |||
| this.detail = await this.$fetch('getGroupShareInfo', { id: this.id }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return await shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { title, open } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| openPopup() { | |||
| this.$refs.popupUnlock.open(); | |||
| }, | |||
| async onAdd() { | |||
| const result = await this.fetchCheckShare() | |||
| const { open, need_num, num } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.openPopup() | |||
| } | |||
| }, | |||
| } | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.fetchDetails() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.fetchDetails() | |||
| shareLog.clear() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| textDetails, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title: textDetails, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=2&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id: this.id, | |||
| state: "2", | |||
| } | |||
| // this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails() { | |||
| try { | |||
| this.detail = await this.$fetch('getGroupShareInfo', { | |||
| id: this.id | |||
| }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return await shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| title, | |||
| open | |||
| } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| openPopup() { | |||
| this.$refs.popupUnlock.open(); | |||
| }, | |||
| async onAdd() { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| open, | |||
| need_num, | |||
| num | |||
| } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.openPopup() | |||
| } | |||
| }, | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .page { | |||
| position: relative; | |||
| height: 100vh; | |||
| } | |||
| .content { | |||
| display: flex; | |||
| flex-direction: column; | |||
| align-items: center; | |||
| } | |||
| .avatar { | |||
| width: 180rpx; | |||
| height: 180rpx; | |||
| margin-top: 127rpx; | |||
| } | |||
| .nick-name { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| margin-top: 30rpx; | |||
| } | |||
| .desc { | |||
| margin-top: 30rpx; | |||
| } | |||
| .btn, .group-info { | |||
| position: absolute; | |||
| } | |||
| .btn { | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| .group-info { | |||
| bottom: 269rpx; | |||
| flex-direction: column; | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| } | |||
| .qr { | |||
| margin-top: 40rpx; | |||
| width: 350rpx; | |||
| height: 350rpx; | |||
| } | |||
| .page { | |||
| position: relative; | |||
| height: 100vh; | |||
| } | |||
| .content { | |||
| display: flex; | |||
| flex-direction: column; | |||
| align-items: center; | |||
| } | |||
| .avatar { | |||
| width: 180rpx; | |||
| height: 180rpx; | |||
| margin-top: 127rpx; | |||
| } | |||
| .nick-name { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| margin-top: 30rpx; | |||
| } | |||
| .desc { | |||
| margin-top: 30rpx; | |||
| } | |||
| .btn, | |||
| .group-info { | |||
| position: absolute; | |||
| } | |||
| .btn { | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| .group-info { | |||
| bottom: 269rpx; | |||
| flex-direction: column; | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| } | |||
| .qr { | |||
| margin-top: 40rpx; | |||
| width: 350rpx; | |||
| height: 350rpx; | |||
| } | |||
| </style> | |||
| @ -1,228 +1,246 @@ | |||
| <template> | |||
| <view class="page"> | |||
| <view class="page"> | |||
| <navbar leftClick @leftClick="$utils.navigateBack" /> | |||
| <view class="content"> | |||
| <image class="avatar" :src="detail.headImage"></image> | |||
| <text class="nick-name">{{ detail.headTitle || '' }}</text> | |||
| <view class="content"> | |||
| <image class="avatar" :src="detail.headImage"></image> | |||
| <text class="nick-name">{{ detail.headTitle || '' }}</text> | |||
| <template v-if="isLocked"> | |||
| <button class="btn" type="success" @click="onAdd">添加</button> | |||
| </template> | |||
| <view v-else class="flex flex-column qr-popup"> | |||
| <text class="tips">长按识别二维码,了解更多内容!</text> | |||
| <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image> | |||
| </view> | |||
| </view> | |||
| <template v-if="isLocked"> | |||
| <button class="btn" type="success" @click="onAdd">添加</button> | |||
| </template> | |||
| <view v-else class="flex flex-column qr-popup"> | |||
| <text class="tips">长按识别二维码,了解更多内容!</text> | |||
| <image class="qr" :src="detail.wxCodeImage" :show-menu-by-longpress="true"></image> | |||
| </view> | |||
| </view> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-user.png"></popupUnlock> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-user.png"></popupUnlock> | |||
| </view> | |||
| </view> | |||
| </template> | |||
| <script> | |||
| import { mapState } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import { | |||
| mapState | |||
| } from 'vuex' | |||
| import shareLog from '@/utils/shareLog' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| export default { | |||
| components: { | |||
| popupUnlock, | |||
| }, | |||
| components: { | |||
| popupUnlock, | |||
| }, | |||
| data() { | |||
| return { | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| userId: null, | |||
| headImage: null, | |||
| headTitle: null, | |||
| indexImage: null, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| userId: null, | |||
| headImage: null, | |||
| headTitle: null, | |||
| indexImage: null, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| isLocked: true, | |||
| } | |||
| }, | |||
| computed: { | |||
| ...mapState(['userInfo']), | |||
| }, | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.fetchDetails() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| onLoad(option) { | |||
| const { id, state, shareId } = option | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.fetchDetails() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| onLoad(option) { | |||
| const { | |||
| id, | |||
| state, | |||
| shareId | |||
| } = option | |||
| if (shareId) { | |||
| uni.setStorageSync('shareId', shareId) | |||
| } | |||
| if (state) { | |||
| uni.setStorageSync('state', state) | |||
| } | |||
| if (id) { | |||
| uni.setStorageSync('id', id) | |||
| } | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.fetchDetails() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.fetchDetails() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| textDetails, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title : textDetails, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=0&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id:this.id, | |||
| state:"0", | |||
| } | |||
| this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails() { | |||
| try { | |||
| this.detail = await this.$fetch('getShareInfo', { id: this.id }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return await shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { title, open } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| openPopup() { | |||
| this.$refs.popupUnlock.open(); | |||
| }, | |||
| async onAdd() { | |||
| const result = await this.fetchCheckShare() | |||
| const { open, need_num, num } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.openPopup() | |||
| } | |||
| }, | |||
| } | |||
| this.id = id | |||
| // if (uni.getStorageSync('token')) { | |||
| // this.fetchDetails() | |||
| // } else { | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.fetchDetails() | |||
| shareLog.clear() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| textDetails, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title: textDetails, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=0&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id: this.id, | |||
| state: "0", | |||
| } | |||
| // this.$fetch('addLogShareInfo', params) | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails() { | |||
| try { | |||
| this.detail = await this.$fetch('getShareInfo', { | |||
| id: this.id | |||
| }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| return await shareLog.check(this.id, this.detail.num) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async refreshLockStatus() { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| title, | |||
| open | |||
| } = result | |||
| console.log('--open', open) | |||
| this.$refs.popupUnlock.close(); | |||
| if (open) { | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| title && uni.showToast({ | |||
| title, | |||
| icon: 'none', | |||
| duration: 3000 | |||
| }) | |||
| }, | |||
| openPopup() { | |||
| this.$refs.popupUnlock.open(); | |||
| }, | |||
| async onAdd() { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| open, | |||
| need_num, | |||
| num | |||
| } = result | |||
| console.log('--open', open) | |||
| if (open) { // 转发已达标 | |||
| this.isLocked = false | |||
| return | |||
| } | |||
| uni.showToast({ | |||
| title: `还需转发${need_num - num}次`, | |||
| icon: 'none', | |||
| }) | |||
| this.openPopup() | |||
| } | |||
| }, | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .page { | |||
| position: relative; | |||
| height: 100vh; | |||
| } | |||
| .content { | |||
| display: flex; | |||
| flex-direction: column; | |||
| align-items: center; | |||
| } | |||
| .avatar { | |||
| width: 180rpx; | |||
| height: 180rpx; | |||
| margin-top: 127rpx; | |||
| } | |||
| .nick-name { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| margin-top: 30rpx; | |||
| } | |||
| .btn, .qr-popup { | |||
| position: absolute; | |||
| } | |||
| .btn { | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| .qr-popup { | |||
| width: 100vw; | |||
| bottom: 269rpx; | |||
| .tips { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| } | |||
| } | |||
| .qr { | |||
| margin-top: 40rpx; | |||
| width: 350rpx; | |||
| height: 350rpx; | |||
| } | |||
| .page { | |||
| position: relative; | |||
| height: 100vh; | |||
| } | |||
| .content { | |||
| display: flex; | |||
| flex-direction: column; | |||
| align-items: center; | |||
| } | |||
| .avatar { | |||
| width: 180rpx; | |||
| height: 180rpx; | |||
| margin-top: 127rpx; | |||
| } | |||
| .nick-name { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| margin-top: 30rpx; | |||
| } | |||
| .btn, | |||
| .qr-popup { | |||
| position: absolute; | |||
| } | |||
| .btn { | |||
| width: calc(100% - 60rpx*2); | |||
| height: auto; | |||
| left: 60rpx; | |||
| bottom: 292rpx; | |||
| background-color: #07C160; | |||
| border: none; | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| line-height: 1; | |||
| border-radius: 45rpx; | |||
| padding: 25rpx 0; | |||
| box-sizing: border-box; | |||
| } | |||
| .qr-popup { | |||
| width: 100vw; | |||
| bottom: 269rpx; | |||
| .tips { | |||
| color: #1B1B1B; | |||
| font-size: 32rpx; | |||
| } | |||
| } | |||
| .qr { | |||
| margin-top: 40rpx; | |||
| width: 350rpx; | |||
| height: 350rpx; | |||
| } | |||
| </style> | |||
| @ -1,189 +1,247 @@ | |||
| <template> | |||
| <view class="page"> | |||
| <view class="page"> | |||
| <navbar leftClick @leftClick="$utils.navigateBack" /> | |||
| <view class="content"> | |||
| <video class="video" | |||
| id="video" | |||
| :src="detail.vio" | |||
| autoplay | |||
| play-btn-position="center" | |||
| :controls="!timeIsUp" | |||
| :show-fullscreen-btn="false" | |||
| :show-center-play-btn="true" | |||
| @timeupdate="onTimeupdate" | |||
| @ended="onTimeEnd" | |||
| ></video> | |||
| <view class="info"> | |||
| <view class="author">{{ detail.author || '' }}</view> | |||
| <view class="title">{{ detail.headTitle || '' }}</view> | |||
| <view class="desc">{{ detail.textDetails || '' }}</view> | |||
| </view> | |||
| </view> | |||
| <uv-overlay :show="timeIsUp" @click="onPlay" zIndex="998"> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-video.png"></popupUnlock> | |||
| </uv-overlay> | |||
| <popupQrCode ref="popupQrCode" :src="detail.wxCodeImage"></popupQrCode> | |||
| </view> | |||
| <view class="content"> | |||
| <video class="video" id="video" :src="detail.vio" autoplay play-btn-position="center" :controls="!timeIsUp" | |||
| :show-fullscreen-btn="false" :show-center-play-btn="true" @timeupdate="onTimeupdate" | |||
| @ended="onTimeEnd"></video> | |||
| <view class="info"> | |||
| <view class="author">{{ detail.author || '' }}</view> | |||
| <view class="title">{{ detail.headTitle || '' }}</view> | |||
| <view class="desc">{{ detail.textDetails || '' }}</view> | |||
| </view> | |||
| </view> | |||
| <uv-overlay :show="timeIsUp" @click="onPlay" zIndex="998"> | |||
| <popupUnlock ref="popupUnlock" src="../static/sharing/unlock-video.png"></popupUnlock> | |||
| </uv-overlay> | |||
| <popupQrCode ref="popupQrCode" :src="detail.wxCodeImage"></popupQrCode> | |||
| </view> | |||
| </template> | |||
| <script> | |||
| import { mapState } from 'vuex' | |||
| import { | |||
| mapState | |||
| } from 'vuex' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupQrCode from '../components/popupQrCode.vue' | |||
| import popupUnlock from '../components/popupUnlock.vue' | |||
| import popupQrCode from '../components/popupQrCode.vue' | |||
| import shareLog from '@/utils/shareLog' | |||
| export default { | |||
| components: { | |||
| popupUnlock, | |||
| popupQrCode, | |||
| }, | |||
| components: { | |||
| popupUnlock, | |||
| popupQrCode, | |||
| }, | |||
| data() { | |||
| return { | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| headTitle: null, | |||
| indexImage: null, | |||
| vio: null, | |||
| timeNum: 0, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| timeIsUp: false, | |||
| isLocked: true, | |||
| videoContext: null, | |||
| } | |||
| }, | |||
| id: null, | |||
| detail: { | |||
| id: null, | |||
| headTitle: null, | |||
| indexImage: null, | |||
| vio: null, | |||
| timeNum: 0, | |||
| num: 0, | |||
| wxCodeImage: null, | |||
| textDetails: null, | |||
| }, | |||
| timeIsUp: false, | |||
| isLocked: true, | |||
| videoContext: null, | |||
| } | |||
| }, | |||
| computed: { | |||
| ...mapState(['userInfo']), | |||
| }, | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.initData() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| async onLoad(option) { | |||
| const { id, state, shareId } = option | |||
| onShow() { | |||
| // if (this.id && uni.getStorageSync('token')) { | |||
| // this.detail.id ? this.refreshLockStatus() : this.initData() | |||
| // } | |||
| if (this.detail.id) { // 转发后返回页面的场景 | |||
| this.refreshLockStatus() | |||
| } | |||
| }, | |||
| async onLoad(option) { | |||
| const { | |||
| id, | |||
| state, | |||
| shareId | |||
| } = option | |||
| if (shareId) { | |||
| uni.setStorageSync('shareId', shareId) | |||
| } | |||
| if (state) { | |||
| uni.setStorageSync('state', state) | |||
| } | |||
| if (id) { | |||
| uni.setStorageSync('id', id) | |||
| } | |||
| this.id = id | |||
| // if(uni.getStorageSync('token')){ | |||
| // this.initData() | |||
| // }else{ | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| this.initData() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| headTitle, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title : headTitle, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=1&shareId=${this.userInfo.id}`, | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id:this.id, | |||
| state:"1", | |||
| } | |||
| this.$fetch('addLogShareInfo', params) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails(id) { | |||
| try { | |||
| this.detail = await this.$fetch('getVideoShareInfo', { id }) | |||
| } catch (err) { | |||
| } | |||
| }, | |||
| async initData() { | |||
| this.isLocked = true | |||
| await this.fetchDetails(this.id) | |||
| this.videoContext = uni.createVideoContext('video'); | |||
| }, | |||
| refreshLockStatus() { | |||
| this.isLocked = false | |||
| this.timeIsUp = false | |||
| setTimeout(() => { | |||
| this.videoContext.play() | |||
| console.log('--play') | |||
| }) | |||
| }, | |||
| async onPlay() { | |||
| if (!this.isLocked) { | |||
| return | |||
| } | |||
| this.videoContext.pause() | |||
| this.timeIsUp = true | |||
| this.$refs.popupUnlock.open(); | |||
| }, | |||
| async onTimeupdate(e) { | |||
| const { currentTime } = e.target | |||
| if (currentTime >= this.detail.timeNum && this.isLocked) { | |||
| this.videoContext.pause() | |||
| this.timeIsUp = true | |||
| this.onPlay() | |||
| } | |||
| }, | |||
| onTimeEnd() { | |||
| this.$refs.popupQrCode.open() | |||
| }, | |||
| }, | |||
| } | |||
| </script> | |||
| this.id = id | |||
| <style scoped lang="scss"> | |||
| .video { | |||
| width: 100%; | |||
| height: calc(100vh - #{$navbar-height} - var(--status-bar-height) - 20rpx); | |||
| } | |||
| // if(uni.getStorageSync('token')){ | |||
| // this.initData() | |||
| // }else{ | |||
| // uni.navigateTo({ | |||
| // url: '/pages_order/auth/wxLogin' | |||
| // }) | |||
| // } | |||
| .info { | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| this.initData() | |||
| shareLog.clear() | |||
| }, | |||
| onShareAppMessage(res) { | |||
| const { | |||
| headTitle, | |||
| indexImage, | |||
| } = this.detail | |||
| let o = { | |||
| title: headTitle, | |||
| imageUrl: indexImage, | |||
| query: `id=${this.id}&state=1&shareId=${this.userInfo.id}`, | |||
| } | |||
| position: fixed; | |||
| left: 40rpx; | |||
| bottom: 100rpx; | |||
| .title { | |||
| font-size: 32rpx; | |||
| margin: 5rpx 0; | |||
| } | |||
| } | |||
| //调用增加分享次数的方法 | |||
| const params = { | |||
| id: this.id, | |||
| state: "1", | |||
| } | |||
| // this.$fetch('addLogShareInfo', params) | |||
| // 将分享记录移到回调成功里面,避免分享取消也计数 | |||
| shareLog.insert(this.id) | |||
| return o | |||
| }, | |||
| methods: { | |||
| async fetchDetails(id) { | |||
| try { | |||
| 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) { | |||
| } | |||
| }, | |||
| 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() { | |||
| // 不要在这里设置timeIsUp = false,这会导致弹窗被关闭 | |||
| // this.timeIsUp = false | |||
| setTimeout(async () => { | |||
| const result = await this.fetchCheckShare() | |||
| const { | |||
| open, | |||
| need_num, | |||
| num | |||
| } = result | |||
| 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', | |||
| }) | |||
| }) | |||
| }, | |||
| async fetchCheckShare() { | |||
| try { | |||
| // 确保detail.num被转换为数字,因为API返回的是字符串类型 | |||
| const numValue = parseInt(this.detail.num) || 0; | |||
| return await shareLog.check(this.id, numValue) | |||
| } catch (err) { | |||
| return {} | |||
| } | |||
| }, | |||
| async onPlay() { | |||
| if (!this.isLocked) { | |||
| 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(); | |||
| }, | |||
| async onTimeupdate(e) { | |||
| const { | |||
| currentTime | |||
| } = e.target | |||
| if (currentTime >= this.detail.timeNum && this.isLocked) { | |||
| this.onPlay() | |||
| } | |||
| }, | |||
| onTimeEnd() { | |||
| this.$refs.popupQrCode.open() | |||
| }, | |||
| }, | |||
| } | |||
| </script> | |||
| <style scoped lang="scss"> | |||
| .video { | |||
| width: 100%; | |||
| height: calc(100vh - #{$navbar-height} - var(--status-bar-height) - 20rpx); | |||
| } | |||
| .info { | |||
| color: #FFFFFF; | |||
| font-size: 28rpx; | |||
| position: fixed; | |||
| left: 40rpx; | |||
| bottom: 100rpx; | |||
| .title { | |||
| font-size: 32rpx; | |||
| margin: 5rpx 0; | |||
| } | |||
| } | |||
| </style> | |||
| @ -1,41 +1,54 @@ | |||
| import fetch from '@/api/fetch.js' | |||
| let slog = {} | |||
| const get = () => { | |||
| try { | |||
| 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 = log[id] || 0 | |||
| const open = num >= need_num | |||
| return { open, need_num, 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, | |||
| } | |||