panhui 2 سال پیش
والد
کامیت
45aa0b3888
7فایلهای تغییر یافته به همراه85 افزوده شده و 40 حذف شده
  1. 0 1
      src/components/VideoPlayer.vue
  2. 17 2
      src/locales/zh-tw.json
  3. 3 7
      src/views/LoginPage.vue
  4. 21 6
      src/views/MinePage.vue
  5. 31 19
      src/views/VideoPage.vue
  6. 7 4
      src/views/WalletPage.vue
  7. 6 1
      src/views/WatchingPage.vue

+ 0 - 1
src/components/VideoPlayer.vue

@@ -156,7 +156,6 @@ function onTouchMove(event) {
         lockClick.value = true
         state.dragging = true
         state.offset = clamp(deltaY.value + startOffset.value, -getHeightByRef(boxRef) / 2, getHeightByRef(boxRef) / 2)
-        console.log(state.offset)
         if (state.offset < 0 && top.value == -54) {
             bottom.value = 0 - state.offset - 54 > 0 ? 0 : 0 - state.offset - 54
         }

+ 17 - 2
src/locales/zh-tw.json

@@ -11,7 +11,9 @@
     "nickname": "用戶昵稱",
     "id": "看官ID",
     "mine": "我的",
-    "notLogin": "未登录"
+    "notLogin": "未登录",
+    "signSuc": "签到成功",
+    "signed": "今日已簽到"
   },
   "zouma": "走馬短劇",
   "home": {
@@ -52,5 +54,18 @@
   "user": {
     "notLogin": "登录查看更多精彩"
   },
-  "loadingFinished": "加载完成"
+  "loadingFinished": "加载完成",
+  "cancelSuc": "取消成功",
+  "collectSuc": "追剧成功",
+  "collect": "追剧",
+  "collected": "已追剧",
+  "video": {
+    "number": "第{num}集",
+    "choose": "选集"
+  },
+  "empty": "暂无记录",
+  "wallet":{
+    "buySeries":"购买《{title}》",
+    "buyEpisode":"购买第{num}集"
+  }
 }

+ 3 - 7
src/views/LoginPage.vue

@@ -110,19 +110,15 @@ function goRegister() {
 const { t } = useI18n()
 const { login } = useUserStore()
 function onSubmit() {
-    showLoadingToast({
-        message: t('loading'),
-        forbidClick: true,
-        duration: -1
-    })
+    toast.loading(t('loading'))
     login(form.value.username, form.value.password)
         .then(res => {
-            closeToast()
+            toast.dismiss()
             toast.success(t('login.loginsucess'))
             router.back()
         })
         .catch(e => {
-            closeToast()
+            toast.dismiss()
             toast(e)
         })
 }

+ 21 - 6
src/views/MinePage.vue

@@ -41,7 +41,7 @@
                                     size="small"
                                     color="linear-gradient(180deg, #FF8D63 , #FF7459 )"
                                     v-if="todayInfo && todayInfo.isSigned"
-                                    >今日已簽到</van-button
+                                    >{{ $t('mine.signed') }}</van-button
                                 >
                                 <van-button
                                     round
@@ -117,6 +117,7 @@ import { showNotify } from 'vant'
 import { useI18n } from 'vue-i18n'
 import { isSameDay } from 'date-fns'
 import toast from '@/utils/toast'
+import { onIonViewWillEnter } from '@ionic/vue'
 
 const buyPageRef = ref(null)
 function buy() {
@@ -129,23 +130,34 @@ function connect() {
     connectPageRef.value.changeShow(true)
 }
 
-const { user } = useUserStore()
+const { user, get: getUser } = useUserStore()
 
-onMounted(() => {
+// onMounted(async () => {
+//     if (user) {
+//         await getUser()
+//         getSign()
+//         await getAmount()
+//     }
+// })
+
+onIonViewWillEnter(async () => {
     if (user) {
+        await getUser()
         getSign()
-        getAmount()
+        await getAmount()
     }
 })
 
 const signInfos = ref([])
 const todayInfo = ref({})
 function getSign() {
+    toast.loading(t('loading'))
     http.get('/api/signInRecords').then(res => {
         signInfos.value = res
         todayInfo.value = res.find(item => {
             return isSameDay(new Date(item.date), new Date())
         })
+        toast.dismiss()
     })
 }
 
@@ -162,10 +174,11 @@ function getAmount() {
 
 const { t } = useI18n()
 function sign() {
+    toast.loading(t('loading'))
     http.post('/api/signInRecords')
         .then(res => {
             getSign()
-            toast.success('签到成功')
+            toast.success(t('mine.signSuc'))
         })
         .catch(e => {
             if (e && e.message) {
@@ -242,7 +255,9 @@ function share() {
     .sign-box {
         height: 137px;
         background: linear-gradient(180deg, #fff3e3 0%, #ffe9cc 100%);
-        box-shadow: 0px 1px 2px 0px #e69301, inset 1px 2px 5px 0px #ffbb5e;
+        box-shadow:
+            0px 1px 2px 0px #e69301,
+            inset 1px 2px 5px 0px #ffbb5e;
         border-radius: 12px;
         border: 2px solid #ffefad;
         margin-top: 16px;

+ 31 - 19
src/views/VideoPage.vue

@@ -40,12 +40,14 @@
                         :src="isCollected ? collectActiveImg : collectImg"
                         alt=""
                     />
-                    <div>{{ isCollected ? '已追剧' : '追剧' }}</div>
+                    <div>{{ isCollected ? $t('collected') : $t('collect') }}</div>
                 </div>
             </div>
 
             <div class="view-bottom flex justify-between z-20 items-center van-safe-area-bottom px-[18px]">
-                <span class="text-base text-white">{{ seriesInfo.title }}-第{{ curEpInfo.episodeNum }}集</span>
+                <span class="text-base text-white"
+                    >{{ seriesInfo.title }}-{{ $t('video.number', { num: curEpInfo.episodeNum }) }}</span
+                >
                 <van-button
                     type="primary"
                     class="btn"
@@ -54,7 +56,7 @@
                     size="mini"
                     round
                     @click="showVideoHistory"
-                    >选集</van-button
+                    >{{ $t('video.choose') }}</van-button
                 >
             </div>
 
@@ -91,7 +93,9 @@ import resolveUrl from 'resolve-url'
 import { nextTick } from 'vue'
 import toast from '@/utils/toast'
 import VideoPlayer from '@/components/VideoPlayer.vue'
+import { useI18n } from 'vue-i18n'
 
+const { t } = useI18n()
 const poster = ref('')
 
 const router = useRouter()
@@ -150,21 +154,28 @@ async function getEpisodes(episodeNum = 1, duration = 0, episodeId = 0) {
 const buyEpInfo = ref({})
 const videoBuyRef = ref(null)
 async function play(curEpId = 0, duration = 0) {
-    await http.get('/api/episodes/' + curEpId).then(res => {
-        if (Number(res.price) > 0 && !res.playUrl) {
-            buyEpInfo.value = res
-            videoBuyRef.value.init()
-        } else {
-            curEpInfo.value = res
-            nextTick(() => {
-                videoRef.value.setCurrent(duration)
-                videoRef.value.play()
-                videoRef.value.changeMuted()
-            })
-        }
+    toast.loading(t('loading'))
+    await http
+        .get('/api/episodes/' + curEpId)
+        .then(res => {
+            toast.dismiss()
+            if (Number(res.price) > 0 && !res.playUrl) {
+                buyEpInfo.value = res
+                videoBuyRef.value.init()
+            } else {
+                curEpInfo.value = res
+                nextTick(() => {
+                    videoRef.value.setCurrent(duration)
+                    videoRef.value.play()
+                    videoRef.value.changeMuted()
+                })
+            }
 
-        // poster.value = resolveUrl(fileURL, res.cover)
-    })
+            // poster.value = resolveUrl(fileURL, res.cover)
+        })
+        .catch(e => {
+            toast.dismiss()
+        })
 }
 
 function videopause(pause = true) {
@@ -182,6 +193,7 @@ http.get('/api/collections/' + seriesId.value).then(res => {
 const isCollected = ref(false)
 const collectImgRef = ref(null)
 function collect() {
+    toast.loading(t('loading'))
     collectImgRef.value.className = collectImgRef.value.className + ' animate__pulse'
     setTimeout(() => {
         collectImgRef.value.className = collectImgRef.value.className.replace(/ animate__pulse/, '')
@@ -189,7 +201,7 @@ function collect() {
 
     if (isCollected.value) {
         http.delete('/api/collections/' + seriesId.value).then(res => {
-            toast.success('取消成功')
+            toast.success(t('cancelSuc'))
             isCollected.value = false
         })
     } else {
@@ -203,7 +215,7 @@ function collect() {
                 body: 'json'
             }
         ).then(res => {
-            toast.success('追剧成功')
+            toast.success(t('collectSuc'))
             isCollected.value = true
         })
     }

+ 7 - 4
src/views/WalletPage.vue

@@ -12,7 +12,7 @@
             <img src="@/assets/png-zhuiju-bg.png" class="top-bg !absolute w-full h-[200px] top-0 left-0 !z-0" alt="" />
             <div class="watching-content">
                 <div class="py-[14px] px-[18px]">
-                    <van-empty v-if="empty" :image="emptyImg" description="暂无记录" />
+                    <van-empty v-if="empty" :image="emptyImg" :description="$t('empty')" />
                     <van-list
                         class="list"
                         v-model:loading="loading"
@@ -50,6 +50,9 @@ import qiandaoImg from '@/assets/icon-qiandao.png'
 import yaoqingImg from '@/assets/icon-yaoqing.png'
 import useList from '../plugins/list'
 import emptyImg from '../assets/png-kong.png'
+import { useI18n } from 'vue-i18n'
+
+const { t } = useI18n()
 
 const router = useRouter()
 function back() {
@@ -93,13 +96,13 @@ function getIcon(type) {
 function getTitle(info) {
     let title = ''
     if (info.series) {
-        title = '购买《' + info.series.title + '》'
+        title = t('wallet.buySeries', { title: info.series.title })
 
         if (info.episode) {
-            title += '第' + info.episode.episodeNum + '集'
+            title += t('video.number', { num: info.episode.episodeNum })
         }
     } else if (info.episode) {
-        title = '购买第' + info.episode.episodeNum + '集'
+        title = t('wallet.buyEpisode', { num: info.episode.episodeNum })
     }
     if (info.description) {
         title = info.description

+ 6 - 1
src/views/WatchingPage.vue

@@ -55,18 +55,23 @@ import { http } from '@/plugins/http'
 import { ref } from 'vue'
 import { onIonViewWillEnter } from '@ionic/vue'
 import emptyImg from '../assets/png-kong.png'
+import toast from '@/utils/toast'
+import { useI18n } from 'vue-i18n'
+const { t } = useI18n()
 
 const histories = ref([])
 const loading = ref(true)
 
 function init() {
+    toast.loading(t('loading'))
     http.get('/api/playHistories').then(res => {
         histories.value = res.data
         loading.value = false
+        toast.dismiss()
     })
 }
 
-init()
+// init()
 onIonViewWillEnter(() => {
     init()
 })