pujiaming 2 år sedan
förälder
incheckning
df6ad6f3ca
6 ändrade filer med 120 tillägg och 1263 borttagningar
  1. 77 1254
      package-lock.json
  2. 1 0
      package.json
  3. 5 3
      src/components/vantList.vue
  4. 1 1
      src/views/ecoin.vue
  5. 35 5
      src/views/mine.vue
  6. 1 0
      src/vite-env.d.ts

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 77 - 1254
package-lock.json


+ 1 - 0
package.json

@@ -21,6 +21,7 @@
     "terser": "^5.19.2",
     "vant": "^4.6.5",
     "vue": "^3.3.4",
+    "vue-clipboard3": "^2.0.0",
     "vue-router": "^4.2.4"
   },
   "devDependencies": {

+ 5 - 3
src/components/vantList.vue

@@ -51,11 +51,13 @@ const onLoad = async(flag?:any, pa?:any) => {
 
   paramCopy.value = pa || { ...(props.param ? props.param : {}) }
   await props.request({ ...paramCopy.value, ...paginationCopy.value }).then((res:any) => {
-    // console.log('列表res', res.data)
-    if (!res.data.total) {
+    console.log('列表res', res.data)
+    if (res.data.data.total === 0) {
       finished.value = true
     }
-    total.value = res.data.total || 0
+    console.log(typeof res.data.data.total)
+
+    total.value = typeof res.data.data.total === 'number' ? res.data.data.total : res.data.data.total.total
     list.value = list.value.concat(res.data.data.lists ? res.data.data.lists : [])
     // list.value = [...list.value, ...(res.data.data ? res.data.data : [])]
     console.log('list', list.value)

+ 1 - 1
src/views/ecoin.vue

@@ -95,7 +95,7 @@ const addPage = () => {
 onMounted(async() => {
   getTableData()
   if (vanList.value) {
-    vanList.value.onLoad()
+    vanList.value.onLoad(1)
   }
 })
 

+ 35 - 5
src/views/mine.vue

@@ -43,6 +43,15 @@
             <el-form-item label="礼包内容:">{{ item.gift_content }}</el-form-item>
             <el-form-item label="使用方法:">{{ item.usage }}</el-form-item>
             <el-form-item label="有效期:">{{ item.start_at+'-'+item.end_at }}</el-form-item>
+            <el-form-item v-if="item.user_get_at !== ''" style="user-select:auto;" label="礼包码:">
+              {{ item.code }}
+              <el-button
+                icon="DocumentCopy"
+                size="small"
+                @click="doCopay(item.code)"
+                style="margin-left: .5rem;"
+              />
+            </el-form-item>
           </el-form>
         </el-collapse-item>
         <div style="width: 20%;">
@@ -58,7 +67,7 @@
     <van-collapse v-if="giftData.length" v-model="activeNames">
       <van-collapse-item v-for="(item, index) in giftData" :key="index" :title="item.gift_name" :name="item.id">
         <template #value>
-          <van-button size="small" :disabled="item.user_get_at !== ''" round type="primary" @click="receiveGift(item.id)">领取礼包</van-button>
+          <van-button size="small" :disabled="item.user_get_at !== ''" round type="primary" @click.stop="receiveGift(item.id)">领取礼包</van-button>
         </template>
         <van-cell-group>
           <van-cell value-class="value-length" center size="large" title="礼包内容:" :value="item.gift_content">
@@ -82,6 +91,7 @@
               </div>
             </template>
           </van-cell>
+          <van-cell v-if="item.user_get_at !== ''" value-class="value-length" style="user-select:auto;" center size="large" title="礼包码:" :value="item.code"/>
         </van-cell-group>
       </van-collapse-item>
 
@@ -99,6 +109,7 @@ import Message from '@/utils/Message'
 import local from '@/utils/local'
 import { bytesChange } from '@/utils/bytesFormatter'
 import { Download } from '@element-plus/icons-vue'
+import useClipboard from 'vue-clipboard3'
 
 const { user } = useStore()
 const router = useRouter()
@@ -149,7 +160,15 @@ const getMyGame = async(params:Params) => {
     Message.error(err.data.msg)
   })
 }
-
+const { toClipboard } = useClipboard()
+const doCopay = async(code:any) => {
+  try {
+    await toClipboard(code)
+    Message.success('已复制到剪贴板')
+  } catch (e) {
+    Message.error('复制失败')
+  }
+}
 // 加载更多
 const loadMore = () => {
   params.page += 1
@@ -176,8 +195,10 @@ const goLogin = () => {
   local.remove('headerPath')
 }
 const giftData = ref<any[]>([])
+const gameId = ref<number>(0)
 const showGifts = async(row:any) => {
 //    console.log(row);
+  gameId.value = row.game_id
   await getGiftHttp({ game_id: row.game_id }).then((res) => {
     // console.log(res.data.data)
     giftData.value = res.data.data || []
@@ -188,6 +209,7 @@ const showGifts = async(row:any) => {
 }
 const showGifts2 = async(row:any) => {
 //    console.log(row);
+  gameId.value = row.game_id
   await getGiftHttp({ game_id: row.game_id }).then((res) => {
     // console.log(res.data.data)
     giftData.value = res.data.data || []
@@ -197,10 +219,18 @@ const showGifts2 = async(row:any) => {
   })
 }
 const receiveGift = async(id:number) => {
-  await receiveGiftHttp({ id }).then((res) => {
-    console.log(res)
+  await receiveGiftHttp({ id }).then(async(res) => {
     Message.success(res.data.msg)
-    dialogVisible.value = false
+    await getGiftHttp({ game_id: gameId.value }).then((res) => {
+    // console.log(res.data.data)
+      giftData.value = res.data.data || []
+      // if (platform.value.mobile) {
+      //   dialogVisible2.value = true
+      // }
+    }).catch((error) => {
+      console.log(error)
+    })
+    // dialogVisible.value = false
   }).catch((error) => {
     console.log(error)
     Message.error(error.data.msg)

+ 1 - 0
src/vite-env.d.ts

@@ -24,3 +24,4 @@ interface ImportMeta {
 
 declare module 'element-plus/dist/locale/zh-cn.mjs'
 
+declare module 'vue-clipboard3'