Просмотр исходного кода

feat: 收藏及分享页多语言

liangan 1 неделя назад
Родитель
Сommit
bcde1f499e
5 измененных файлов с 47 добавлено и 20 удалено
  1. 9 1
      src/locale/en.json
  2. 8 0
      src/locale/zh-Hans.json
  3. 3 2
      src/pages.json
  4. 19 11
      src/pages/mine/myFavorite.vue
  5. 8 6
      src/pages/mine/share.vue

+ 9 - 1
src/locale/en.json

@@ -104,5 +104,13 @@
   "income.filter.yt": "YT",
   "income.filter.l7d": "L7D",
   "income.filter.mtd": "MTD",
-  "income.filter.ytd": "YTD"
+  "income.filter.ytd": "YTD",
+  "mine.pages.share.title": "Share",
+  "mine.pages.share.referrerCode": "My Referrer Code",
+  "mine.pages.share.qrCode": "QR Code",
+  "mine.pages.share.description": "Share your QR code with your friends, they can scan it with their camera to register as your downline.",
+  "mine.pages.share.copySuccess": "Copied to clipboard",
+  "mine.pages.share.shareTo": "Share to {0}",
+  "mine.pages.myFavorite.title": "My Favorite",
+  "mine.pages.myFavorite.empty": "No favorites yet"
 }

+ 8 - 0
src/locale/zh-Hans.json

@@ -100,6 +100,14 @@
   "income.filter.l7d": "近7天",
   "income.filter.mtd": "本月",
   "income.filter.ytd": "本年",
+  "mine.pages.share.title": "分享",
+  "mine.pages.share.referrerCode": "我的推荐码",
+  "mine.pages.share.qrCode": "二维码",
+  "mine.pages.share.description": "与您的朋友分享二维码,他们可以用相机扫描以注册成为您的下线。",
+  "mine.pages.share.copySuccess": "已复制到剪贴板",
+  "mine.pages.share.shareTo": "分享到{0}",
+  "mine.pages.myFavorite.title": "我的收藏",
+  "mine.pages.myFavorite.empty": "暂无收藏",
   "search.placeholder": "搜索",
   "search.filterPrice": "全部价格",
   "search.filterCategory": "全部分类",

+ 3 - 2
src/pages.json

@@ -120,7 +120,7 @@
       "type": "page",
       "layout": "default",
       "style": {
-        "navigationBarTitleText": "My Favorite",
+        "navigationBarTitleText": "%mine.pages.myFavorite.title%",
         "navigationBarBackgroundColor": "#fff"
       }
     },
@@ -147,7 +147,8 @@
       "type": "page",
       "layout": "default",
       "style": {
-        "navigationStyle": "custom"
+        "navigationStyle": "custom",
+        "navigationBarTitleText": "%mine.pages.share.title%"
       }
     },
     {

+ 19 - 11
src/pages/mine/myFavorite.vue

@@ -2,9 +2,9 @@
 {
   layout: 'default',
   style: {
-    navigationBarTitleText: 'My Favorite',
-    navigationBarBackgroundColor: '#fff',
-  },
+    navigationBarTitleText: '%mine.pages.myFavorite.title%',
+    navigationBarBackgroundColor: '#fff'
+  }
 }
 </route>
 
@@ -14,13 +14,12 @@
 import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
 import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
 import { getList } from '@/api/product'
+import { t } from '@/locale'
 
 defineOptions({
   name: 'MyFavorite', // 我的收藏
 })
-// 获取屏幕边界到安全区域距离
-const systemInfo = uni.getSystemInfoSync()
-const safeAreaInsets = systemInfo.safeAreaInsets
+
 // z-paging
 const paging = ref(null)
 // 类似mixins,如果是页面滚动务必要写这一行,并传入当前ref绑定的paging,注意此处是paging,而非paging.value
@@ -44,12 +43,21 @@ async function queryList(pageNo: number, pageSize: number) {
 </script>
 
 <template>
-  <z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList" @click="closeOutside">
-    <view class="px-24rpx py-24rpx">
-      <view class="grid grid-cols-2 gap-22rpx">
-        <product v-for="(item, index) in dataList" :key="index" :height="340" :item="item" />
+  <z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
+    <template v-if="dataList.length">
+      <view class="px-24rpx py-24rpx">
+        <view class="grid grid-cols-2 gap-22rpx">
+          <product v-for="(item, index) in dataList" :key="index" :height="340" :item="item" />
+        </view>
+      </view>
+    </template>
+    <template v-else>
+      <view class="h-[50vh] flex items-center justify-center">
+        <text class="text-28rpx text-#999">
+          {{ t('mine.pages.myFavorite.empty') }}
+        </text>
       </view>
-    </view>
+    </template>
   </z-paging>
 </template>
 

+ 8 - 6
src/pages/mine/share.vue

@@ -3,11 +3,13 @@
   layout: 'default',
   style: {
     navigationStyle: 'custom',
-  },
+    navigationBarTitleText: '%mine.pages.share.title%'
+  }
 }
 </route>
 
 <script setup lang="ts">
+import { t } from '@/locale'
 import { goBack } from '@/utils/page'
 
 // 获取屏幕边界到安全区域距离
@@ -49,7 +51,7 @@ function copyReferrerCode() {
     data: userInfo.value.userNo,
     success: () => {
       uni.showToast({
-        title: 'Copied to clipboard',
+        title: t('mine.pages.share.copySuccess'),
         icon: 'success',
       })
     },
@@ -66,7 +68,7 @@ function handleShare(platform: string) {
   }
 
   uni.showToast({
-    title: `Share to ${platformNames[platform]}`,
+    title: t('mine.pages.share.shareTo', [platformNames[platform]]),
     icon: 'none',
   })
 }
@@ -89,7 +91,7 @@ function handleShare(platform: string) {
       <!-- 推荐码标题 -->
       <view class="mb-10rpx mt-40rpx text-center">
         <text class="text-28rpx text-#333 font-medium">
-          My Referrer Code
+          {{ t('mine.pages.share.referrerCode') }}
         </text>
       </view>
 
@@ -113,7 +115,7 @@ function handleShare(platform: string) {
               📱
             </view>
             <text class="text-28rpx text-#999">
-              QR Code
+              {{ t('mine.pages.share.qrCode') }}
             </text>
           </view>
         </view>
@@ -122,7 +124,7 @@ function handleShare(platform: string) {
       <!-- 分享说明 -->
       <view class="mb-60rpx text-center">
         <text class="text-28rpx text-#797979 leading-relaxed">
-          Share your aR code with your friends, they can scan it with their camera to register as your downline.
+          {{ t('mine.pages.share.description') }}
         </text>
       </view>