Browse Source

✨ feat: 增加用户乐跑次数管理

Pchen. 10 months ago
parent
commit
176284d649
3 changed files with 77 additions and 6 deletions
  1. 10 1
      src/api/user.js
  2. 67 5
      src/pages/admin/user/userList.vue
  3. 0 0
      src/pages/download/index.vue

+ 10 - 1
src/api/user.js

@@ -6,7 +6,8 @@ const api = {
   UserInfo: '/User/Info',
   UserInfo: '/User/Info',
   BindEmail: '/User/BindEmail',
   BindEmail: '/User/BindEmail',
   GetRepos: '/User/GetRepos',
   GetRepos: '/User/GetRepos',
-  AdminUserList: '/Admin/User/GetUserList'
+  AdminUserList: '/Admin/User/GetUserList',
+  AdminChangeLepaoCount: '/Admin/User/ChangeLepaoCount'
 }
 }
 
 
 export function ChangeUsername(parameter) {
 export function ChangeUsername(parameter) {
@@ -17,6 +18,14 @@ export function ChangeUsername(parameter) {
   })
   })
 }
 }
 
 
+export function adminChangeLepaoCount(parameter) {
+  return request({
+    url: api.AdminChangeLepaoCount,
+    method: 'post',
+    data: parameter
+  })
+}
+
 export function BindEmail(parameter) {
 export function BindEmail(parameter) {
   return request({
   return request({
     url: api.BindEmail,
     url: api.BindEmail,

+ 67 - 5
src/pages/admin/user/userList.vue

@@ -60,7 +60,7 @@
                     total: pagination.total
                     total: pagination.total
                 }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
                 }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
                 <template #username="{ record }">
                 <template #username="{ record }">
-                    <a-avatar>
+                    <a-avatar :size="35">
                         <IconUser v-if="!record.avatar" />
                         <IconUser v-if="!record.avatar" />
                         <img :alt="record.username ?? ''" :src="record.avatar" v-else />
                         <img :alt="record.username ?? ''" :src="record.avatar" v-else />
                     </a-avatar>
                     </a-avatar>
@@ -73,17 +73,36 @@
                     {{ stramptoTime(record.lastTime) }}
                     {{ stramptoTime(record.lastTime) }}
                 </template>
                 </template>
                 <template #optional="{ record }">
                 <template #optional="{ record }">
-                    <a-button @click="$router.push(`/path/detail/${record.id}`)">查看详情</a-button>
+                    <a-button @click="changeCount(record)">更改次数</a-button>
                 </template>
                 </template>
             </a-table>
             </a-table>
         </a-card>
         </a-card>
     </div>
     </div>
+
+    <a-modal v-model:visible="visible" title="编辑账号" @cancel="handleCancel" @before-ok="handleBeforeOk" draggable
+        :ok-loading="ok_loading" esc-to-close closable>
+        <a-form :model="change_lepao_count">
+            <a-form-item field="userid" label="用户UUID">
+                <a-input v-model="change_lepao_count.userid" disabled />
+            </a-form-item>
+            <a-form-item field="lepao_count" label="乐跑次数">
+                <a-input-number v-model="change_lepao_count.lepao_count" :step="1" />
+            </a-form-item>
+        </a-form>
+    </a-modal>
 </template>
 </template>
 
 
 <script setup>
 <script setup>
 import { ref, reactive, onMounted } from 'vue'
 import { ref, reactive, onMounted } from 'vue'
-import { adminGetUserList } from '@/api/user'
-import { Notification } from '@arco-design/web-vue'
+import { adminGetUserList, adminChangeLepaoCount } from '@/api/user'
+import { Notification, Message } from '@arco-design/web-vue'
+
+const visible = ref(false)
+const ok_loading = ref(false)
+const change_lepao_count = reactive({
+    userid: '',
+    lepao_count: 0
+})
 
 
 const queryData = reactive({
 const queryData = reactive({
     user_uuid: '',
     user_uuid: '',
@@ -101,7 +120,6 @@ const pagination = reactive({
 const loading = ref(false)
 const loading = ref(false)
 const data = ref([])
 const data = ref([])
 
 
-
 const columns = [
 const columns = [
 
 
     {
     {
@@ -174,6 +192,50 @@ const getUserList = async () => {
     }
     }
 }
 }
 
 
+const changeCount = (item) => {
+    if (item) {
+        change_lepao_count.userid = item.uuid
+        change_lepao_count.lepao_count = item.lepao_count
+    }
+    else return
+    visible.value = true
+}
+
+const handleBeforeOk = async (done) => {
+    try {
+        ok_loading.value = true
+
+        let data = {
+            ...change_lepao_count
+        }
+
+        const res = await adminChangeLepaoCount(data)
+        if (!res || res.code !== 0) {
+            Notification.error({
+                title: '保存乐跑账号失败!',
+                content: res?.msg ?? '请稍后再试'
+            })
+            return false
+        }
+
+        Message.success('保存成功!')
+        done()
+        getUserList()
+    } catch (error) {
+        Notification.error({
+            title: '保存乐跑账号失败!',
+            content: error.message || '请稍后再试'
+        })
+        return false
+    } finally {
+        ok_loading.value = false
+    }
+}
+
+const handleCancel = () => {
+    visible.value = false;
+}
+
 // 分页 - 页码变化
 // 分页 - 页码变化
 const handlePageChange = (page) => {
 const handlePageChange = (page) => {
     pagination.current = page
     pagination.current = page

File diff suppressed because it is too large
+ 0 - 0
src/pages/download/index.vue


Some files were not shown because too many files changed in this diff