|
@@ -0,0 +1,106 @@
|
|
|
+<template>
|
|
|
+ <div class="user-reward" v-show="wxVersionCheck">
|
|
|
+ <div class="user-reward-text">{{ rewardText }}</div>
|
|
|
+ <div class="user-reward-action">
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ class="user-reward-button clickable"
|
|
|
+ @click="toRewardPage(true)"
|
|
|
+ >
|
|
|
+ 打赏
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getRewardText } from '@/api/modules/'
|
|
|
+import { LINKS } from '@/data'
|
|
|
+import { openAppOrWxPage } from '@/utils/'
|
|
|
+export default {
|
|
|
+ name: 'Reward',
|
|
|
+ props: {
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ beforeLeavePage: Function
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ wxVersionCheck: true,
|
|
|
+ rewardText: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.calcWxVersion()
|
|
|
+ this.getRewardText()
|
|
|
+ this.checkRewardBack()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getRewardText() {
|
|
|
+ this.rewardText = await getRewardText()
|
|
|
+ },
|
|
|
+ checkRewardBack() {
|
|
|
+ if (sessionStorage.rewardStatus) {
|
|
|
+ this.$toast('剑鱼标讯感谢您的支持')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getWxVersion() {
|
|
|
+ const wxInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
|
|
|
+ if(!wxInfo) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ return wxInfo[1]
|
|
|
+ },
|
|
|
+ calcWxVersion() {
|
|
|
+ const wxInfo = this.getWxVersion()
|
|
|
+ if (wxInfo && wxInfo >= '5.0') {
|
|
|
+ this.wxVersionCheck = true
|
|
|
+ } else {
|
|
|
+ this.wxVersionCheck = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toRewardPage() {
|
|
|
+ if (this.beforeLeavePage) {
|
|
|
+ await this.beforeLeavePage()
|
|
|
+ }
|
|
|
+ openAppOrWxPage(LINKS.打赏页面, {
|
|
|
+ query: {
|
|
|
+ id: this.id,
|
|
|
+ source: 'm'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.user-reward {
|
|
|
+ padding: 20px 0;
|
|
|
+ text-align: center;
|
|
|
+ &-text {
|
|
|
+ margin-bottom: 16px;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #686868;
|
|
|
+ }
|
|
|
+ &-action {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
+ &-button {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ height: 32px;
|
|
|
+ padding: 0 22px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 15px;
|
|
|
+ background-color: #ffbb03;
|
|
|
+ border-radius: 15px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|