Browse Source

✨ feat: 增加乐跑次数赠送功能

Pchen. 10 months ago
parent
commit
fe8fc55be4

+ 9 - 0
src/api/goods.js

@@ -4,6 +4,7 @@ const api = {
   Goods: '/Goods',
   GoodsList: '/Goods/List',
   GetCount: '/Goods/GetCount',
+  SendCount: '/Goods/SendCount',
   AdminGoods: '/Admin/Goods',
   AdminGoodsList: '/Admin/Goods/List'
 }
@@ -24,6 +25,14 @@ export function addGoods (parameter) {
   })
 }
 
+export function sendCount (parameter) {
+  return request({
+    url: api.SendCount,
+    method: 'post',
+    data: parameter
+  })
+}
+
 export function adminGetGoods (parameter) {
   return request({
     url: api.AdminGoods,

+ 10 - 0
src/components/Navbar/index.vue

@@ -20,6 +20,16 @@
         </a-tooltip>
       </li>
 
+      <li v-if="!isElectron()">
+        <a-tooltip content="售后服务">
+          <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/service/createOrder')">
+            <template #icon>
+              <icon-customer-service />
+            </template>
+          </a-button>
+        </a-tooltip>
+      </li>
+
       <li v-if="!isElectron()">
         <a-tooltip content="下载专区">
           <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/download/down')">

+ 2 - 1
src/pages/Login/uniLogin/uniLogin.vue

@@ -185,7 +185,8 @@ onMounted(() => {
 }
 
 .forgetpass {
-    width: 70px;
+    width: 100px;
     margin-top: -10px;
+    margin-left: -15px;
 }
 </style>

+ 4 - 2
src/pages/lepao/accountList/components/userCard.vue

@@ -1,8 +1,10 @@
 <template>
   <a-card class="card">
     <a-space size="large">
-      <a-statistic title="剩余乐跑次数" :value="userCount?.lepao_count" show-group-separator />
-      <a-button type="primary" size="large" @click="$router.push('/store/goodsList')" style="margin-left: 20px;"><icon-gift /> 去购买</a-button>
+      <a-statistic title="剩余乐跑次数" :value="userCount?.lepao_count" animation show-group-separator />
+      <a-button type="primary" size="large" @click="$router.push('/store/goodsList')" style="margin-left: 20px;">
+        <span><icon-fire /> 去购买</span>
+      </a-button>
     </a-space>
   </a-card>
 </template>

+ 1 - 1
src/pages/store/goodsDetail/index.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="container">
-        <Breadcrumb :items="['Forge商城', '商品详情', data?.name]" />
+        <Breadcrumb :items="['商城', '商品详情', data?.name]" />
         <a-card class="goodsdetail">
             <div class="title">
                 {{ data?.name }} <a-tag v-if="data?.limit > 0" color="orange" size="large">限购{{ data?.limit }}件</a-tag>

+ 74 - 5
src/pages/store/goodsList/index.vue

@@ -1,9 +1,13 @@
 <template>
     <div class="container">
-        <Breadcrumb :items="['Forge商城', '商品列表']" />
+        <Breadcrumb :items="['商城', '商品列表']" />
         <a-card>
             <a-space size="large">
-                <a-statistic title="剩余乐跑次数" :value="userCount?.lepao_count" show-group-separator />
+                <a-statistic title="剩余乐跑次数" :value="userCount?.lepao_count" :loading="loading" animation
+                    show-group-separator />
+                <a-button type="primary" size="large" @click="SendCount()" style="margin-left: 20px;">
+                    <span><icon-gift /> 赠送次数</span>
+                </a-button>
             </a-space>
         </a-card>
         <a-card title="商品列表" style="margin-top: 20px;">
@@ -31,17 +35,82 @@
             </a-list>
         </a-card>
     </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="sendform">
+            <a-form-item field="username" label="接收人">
+                <a-input v-model="sendform.username" placeholder="请填写接收人用户名,如:用户adfg45g" :max-length="20"/>
+            </a-form-item>
+            <a-form-item field="count" label="赠送次数">
+                <a-input-number v-model="sendform.count" placeholder="请填写要赠送的次数"  mode="button" />
+            </a-form-item>
+        </a-form>
+    </a-modal>
 </template>
 
 <script setup>
-import { ref } from 'vue'
-import { getGoodsList, getCount } from '@/api/goods'
-import { Notification } from '@arco-design/web-vue'
+import { reactive, ref } from 'vue'
+import { getGoodsList, getCount, sendCount } from '@/api/goods'
+import { Notification, Message } from '@arco-design/web-vue'
 
 const data = ref([])
 const userCount = ref({})
 const loading = ref(false)
 
+const visible = ref(false)
+const ok_loading = ref(false)
+const sendform = reactive({
+    username: '',
+    count: 1
+})
+
+const handleBeforeOk = async (done) => {
+    try {
+        ok_loading.value = true
+        if (!sendform.username) {
+            Message.error('请填写接收人用户名!')
+            return false
+        }
+
+        if (!sendform.count || sendform.count < 1 || sendform.count > 9999) {
+            Message.error('超出赠送的次数范围,请重新选择赠送次数!')
+            return false
+        }
+
+        const res = await sendCount({ username: sendform.username, count: sendform.count })
+        if (!res || res.code !== 0) {
+            Notification.error({
+                title: '赠送次数失败!',
+                content: res?.msg ?? '请稍后再试'
+            })
+            return false
+        }
+
+        Message.success('赠送成功!')
+        done()
+        GetCount()
+    } catch (error) {
+        Notification.error({
+            title: '赠送次数失败!',
+            content: error.message || '请稍后再试'
+        })
+        return false
+    } finally {
+        ok_loading.value = false
+    }
+}
+
+const handleCancel = () => {
+    visible.value = false
+}
+
+const SendCount = async () => {
+    sendform.username = ''
+    sendform.count = 1
+    visible.value = true
+}
+
 const getGoods = async () => {
     try {
         loading.value = true