|
@@ -23,7 +23,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="wallet-val flex items-center">
|
|
<div class="wallet-val flex items-center">
|
|
|
- <div class="wallet-money">{{ amount }}</div>
|
|
|
|
|
|
|
+ <div class="wallet-money">{{ displayBalance }}</div>
|
|
|
<div @click="buy" class="wallet-btn">
|
|
<div @click="buy" class="wallet-btn">
|
|
|
<img src="@/assets/icon-anniu.png" alt="" />
|
|
<img src="@/assets/icon-anniu.png" alt="" />
|
|
|
<span>{{ $t('mine.buy') }}</span>
|
|
<span>{{ $t('mine.buy') }}</span>
|
|
@@ -100,7 +100,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <buy-page ref="buyPageRef"></buy-page>
|
|
|
|
|
|
|
+ <purchase-modal v-model:show="showPurchaseModal"></purchase-modal>
|
|
|
|
|
|
|
|
<connect-page ref="connectPageRef"></connect-page>
|
|
<connect-page ref="connectPageRef"></connect-page>
|
|
|
|
|
|
|
@@ -113,10 +113,10 @@
|
|
|
import { ConfigProvider as VantConfigProvider, showConfirmDialog } from 'vant'
|
|
import { ConfigProvider as VantConfigProvider, showConfirmDialog } from 'vant'
|
|
|
import defaultImg from '@/assets/png-touxiang.png'
|
|
import defaultImg from '@/assets/png-touxiang.png'
|
|
|
import SignInfo from '@/components/SignInfo.vue'
|
|
import SignInfo from '@/components/SignInfo.vue'
|
|
|
-import BuyPage from '@/components/BuyPage.vue'
|
|
|
|
|
|
|
+import PurchaseModal from '@/components/PurchaseModal.vue'
|
|
|
import ConnectPage from '@/components/ConnectPage.vue'
|
|
import ConnectPage from '@/components/ConnectPage.vue'
|
|
|
import PosterPage from '@/components/PosterPage.vue'
|
|
import PosterPage from '@/components/PosterPage.vue'
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted, computed } from 'vue'
|
|
|
import { useUserStore } from '../stores/user'
|
|
import { useUserStore } from '../stores/user'
|
|
|
import { http } from '@/plugins/http'
|
|
import { http } from '@/plugins/http'
|
|
|
import { showNotify } from 'vant'
|
|
import { showNotify } from 'vant'
|
|
@@ -125,41 +125,20 @@ import { isSameDay } from 'date-fns'
|
|
|
import toast from '@/utils/toast'
|
|
import toast from '@/utils/toast'
|
|
|
import { onIonViewWillEnter } from '@ionic/vue'
|
|
import { onIonViewWillEnter } from '@ionic/vue'
|
|
|
import { useIonRouter } from '@ionic/vue'
|
|
import { useIonRouter } from '@ionic/vue'
|
|
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
|
|
|
|
|
-const buyPageRef = ref(null)
|
|
|
|
|
|
|
+const showPurchaseModal = ref(false)
|
|
|
function buy() {
|
|
function buy() {
|
|
|
- // toast(t('wait'))
|
|
|
|
|
- // buyPageRef.value.changeShow(true)
|
|
|
|
|
- const { store, ProductType, Platform } = CdvPurchase
|
|
|
|
|
- store.verbosity = CdvPurchase.LogLevel.DEBUG
|
|
|
|
|
- store.register([
|
|
|
|
|
- {
|
|
|
|
|
- type: ProductType.CONSUMABLE,
|
|
|
|
|
- id: '50',
|
|
|
|
|
- platform: Platform.GOOGLE_PLAY
|
|
|
|
|
- }
|
|
|
|
|
- ])
|
|
|
|
|
- store
|
|
|
|
|
- .when()
|
|
|
|
|
- .productUpdated(() => {
|
|
|
|
|
- console.log('productUpdated')
|
|
|
|
|
- const p = store.get('50', Platform.GOOGLE_PLAY)
|
|
|
|
|
- console.log(p)
|
|
|
|
|
- p.getOffer().order()
|
|
|
|
|
- })
|
|
|
|
|
- .approved(() => {
|
|
|
|
|
- console.log('approved')
|
|
|
|
|
- })
|
|
|
|
|
- store.initialize([Platform.GOOGLE_PLAY])
|
|
|
|
|
|
|
+ showPurchaseModal.value = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const connectPageRef = ref(null)
|
|
const connectPageRef = ref(null)
|
|
|
function connect() {
|
|
function connect() {
|
|
|
connectPageRef.value.changeShow(true)
|
|
connectPageRef.value.changeShow(true)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-const { user, get: getUser, logout } = useUserStore()
|
|
|
|
|
-
|
|
|
|
|
|
|
+const userStore = useUserStore()
|
|
|
|
|
+const { user, logout, balance } = storeToRefs(userStore)
|
|
|
|
|
+const { getUser, getBalance } = userStore
|
|
|
// onMounted(async () => {
|
|
// onMounted(async () => {
|
|
|
// if (user) {
|
|
// if (user) {
|
|
|
// await getUser()
|
|
// await getUser()
|
|
@@ -172,7 +151,7 @@ onIonViewWillEnter(async () => {
|
|
|
if (user) {
|
|
if (user) {
|
|
|
await getUser()
|
|
await getUser()
|
|
|
getSign()
|
|
getSign()
|
|
|
- await getAmount()
|
|
|
|
|
|
|
+ getBalance()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -189,16 +168,9 @@ function getSign() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const amount = ref(0)
|
|
|
|
|
-function getAmount() {
|
|
|
|
|
- http.get('/api/userBalances/' + user.id).then(res => {
|
|
|
|
|
- if (Number(res.balance) > 10000) {
|
|
|
|
|
- amount.value = (Number(res.balance) / 10000).toFixed(2) + '万'
|
|
|
|
|
- } else {
|
|
|
|
|
- amount.value = res.balance
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const displayBalance = computed(() => {
|
|
|
|
|
+ return balance.value.toString()
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
const { t } = useI18n()
|
|
|
function sign() {
|
|
function sign() {
|