|
@@ -1,15 +1,9 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="container">
|
|
<div class="container">
|
|
|
<Breadcrumb :items="['云商城', '商品列表']" />
|
|
<Breadcrumb :items="['云商城', '商品列表']" />
|
|
|
- <a-card>
|
|
|
|
|
- <a-space size="large">
|
|
|
|
|
- <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>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <userCard type="goods"/>
|
|
|
|
|
+
|
|
|
<a-card title="商品列表" style="margin-top: 20px;">
|
|
<a-card title="商品列表" style="margin-top: 20px;">
|
|
|
<a-list hoverable :loading="loading">
|
|
<a-list hoverable :loading="loading">
|
|
|
<a-list-item v-for="(item, index) in data" :key="index">
|
|
<a-list-item v-for="(item, index) in data" :key="index">
|
|
@@ -35,82 +29,17 @@
|
|
|
</a-list>
|
|
</a-list>
|
|
|
</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="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>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { reactive, ref } from 'vue'
|
|
|
|
|
-import { getGoodsList, getCount, sendCount } from '@/api/goods'
|
|
|
|
|
-import { Notification, Message } from '@arco-design/web-vue'
|
|
|
|
|
|
|
+import { ref } from 'vue'
|
|
|
|
|
+import { getGoodsList } from '@/api/goods'
|
|
|
|
|
+import { Notification } from '@arco-design/web-vue'
|
|
|
|
|
+import userCard from '@/components/userCard/userCard.vue'
|
|
|
|
|
|
|
|
const data = ref([])
|
|
const data = ref([])
|
|
|
-const userCount = ref({})
|
|
|
|
|
const loading = ref(false)
|
|
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 () => {
|
|
const getGoods = async () => {
|
|
|
try {
|
|
try {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
@@ -131,28 +60,7 @@ const getGoods = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const GetCount = async () => {
|
|
|
|
|
- try {
|
|
|
|
|
- loading.value = true
|
|
|
|
|
- const res = await getCount()
|
|
|
|
|
- if (!res || res.code !== 0)
|
|
|
|
|
- return Notification.error({
|
|
|
|
|
- title: '获取用户数据失败!',
|
|
|
|
|
- content: res?.msg ?? '请稍后再试'
|
|
|
|
|
- })
|
|
|
|
|
- userCount.value = res.data
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- Notification.error({
|
|
|
|
|
- title: '获取用户数据失败!',
|
|
|
|
|
- content: error.message || '请稍后再试'
|
|
|
|
|
- })
|
|
|
|
|
- } finally {
|
|
|
|
|
- loading.value = false
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
getGoods()
|
|
getGoods()
|
|
|
-GetCount()
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|