|
|
@ -6,14 +6,19 @@ import { Plus } from "@element-plus/icons-vue"; |
|
|
|
import axios from "axios"; |
|
|
|
import { ElMessageBox } from "element-plus"; |
|
|
|
|
|
|
|
// 这是添加充值信息的表单 |
|
|
|
const addConsume = ref({}); |
|
|
|
// 这是添加充值信息的接口 |
|
|
|
// 这是添加消费信息的表单 |
|
|
|
const addConsume = ref({ |
|
|
|
freeCoin: 0, |
|
|
|
rechargeCoin: 0, |
|
|
|
taskCoin: 0, |
|
|
|
updateType: "消费", |
|
|
|
}); |
|
|
|
// 这是添加消费信息的接口 |
|
|
|
const add = async function () { |
|
|
|
try { |
|
|
|
// 发送POST请求 |
|
|
|
const result = await axios.post( |
|
|
|
"http://192.168.8.93:10010/recharge/recharge/add", |
|
|
|
"http://192.168.8.147:10030/consume/add", |
|
|
|
addConsume.value |
|
|
|
); |
|
|
|
|
|
|
@ -59,7 +64,7 @@ const checkEndTime = function (rule, value, callback) { |
|
|
|
}; |
|
|
|
const rules = reactive({ |
|
|
|
jwcode: [{ required: true, message: "请输入精网号", trigger: "blur" }], |
|
|
|
refundGoods: [{ required: true, message: "请选择退款商品", trigger: "blur" }], |
|
|
|
goods: [{ required: true, message: "请选择消费商品", trigger: "blur" }], |
|
|
|
taskCoin: [{ required: true, message: "请输入任务金币", trigger: "blur" }], |
|
|
|
freeCoin: [{ required: true, message: "请输入免费金币", trigger: "blur" }], |
|
|
|
rechargeCoin: [ |
|
|
@ -94,97 +99,70 @@ const getUser = async function (jwcode) { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 这是查询活动的接口 |
|
|
|
const activity = ref([]); |
|
|
|
const getActivity = async function () { |
|
|
|
// 查询商品的接口 |
|
|
|
const goods = ref([]); |
|
|
|
const getGoods = async function () { |
|
|
|
try { |
|
|
|
// 发送POST请求 |
|
|
|
const result = await axios.post( |
|
|
|
"http://192.168.8.93:10010/recharge/activity/select", |
|
|
|
{} |
|
|
|
); |
|
|
|
|
|
|
|
const result = await axios.post("http://192.168.8.93:10020/product", {}); |
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("请求成功", result); |
|
|
|
// 存储表格数据 |
|
|
|
activity.value = result.data.data; |
|
|
|
console.log("活动信息", activity.value); |
|
|
|
// 存储全部数据 |
|
|
|
goods.value = result.data.data; |
|
|
|
console.log("allData", allData.value); |
|
|
|
console.log("地区", area.value); |
|
|
|
} catch (error) { |
|
|
|
console.log("请求失败", error); |
|
|
|
// 在这里可以处理错误逻辑,比如显示错误提示等 |
|
|
|
} |
|
|
|
}; |
|
|
|
getActivity(); |
|
|
|
getGoods(); |
|
|
|
|
|
|
|
// 这是查询货币的接口 |
|
|
|
const currency = ref([]); |
|
|
|
const getCurrency = async function () { |
|
|
|
//这是查询用户金币信息的接口 |
|
|
|
const userGold = ref({}); |
|
|
|
const getUserGold = async function (jwcode) { |
|
|
|
try { |
|
|
|
// 发送POST请求 |
|
|
|
const result = await axios.post( |
|
|
|
"http://192.168.8.174:10010/rates/search", |
|
|
|
{} |
|
|
|
"http://192.168.8.147:10070/statistics/getMess/" + jwcode |
|
|
|
); |
|
|
|
|
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("货币请求成功", result); |
|
|
|
// 存储表格数据 |
|
|
|
currency.value = result.data.data; |
|
|
|
console.log("tableData", currency.value); |
|
|
|
// 在这里可以根据需求进一步处理成功后的逻辑,比如更新UI显示成功消息等 |
|
|
|
console.log("请求成功", result); |
|
|
|
// 存储全部数据 |
|
|
|
userGold.value = result.data.data; |
|
|
|
console.log("userGold", userGold.value); |
|
|
|
} catch (error) { |
|
|
|
console.log("请求失败", error); |
|
|
|
// 在这里可以处理错误逻辑,比如显示错误提示等 |
|
|
|
} |
|
|
|
}; |
|
|
|
getCurrency(); |
|
|
|
|
|
|
|
// 这是添加上传图片的接口 |
|
|
|
const imageUrl = ref(""); |
|
|
|
function calculateCoins() { |
|
|
|
// 保存原始的allGold值 |
|
|
|
const originalAllGold = addConsume.value.allGold; |
|
|
|
|
|
|
|
// 上传图片成功的回调函数 |
|
|
|
const handleAvatarSuccess = (response, uploadFile) => { |
|
|
|
imageUrl.value = URL.createObjectURL(uploadFile.raw); |
|
|
|
console.log("图片上传成功", response, uploadFile); |
|
|
|
addConsume.value.rechargeVoucher = |
|
|
|
"http://192.168.8.93:10010/upload/" + response.data; |
|
|
|
console.log("图片名称", addConsume.value.rechargeVoucher); |
|
|
|
}; |
|
|
|
// 上传图片之前的校验函数 |
|
|
|
const beforeAvatarUpload = (rawFile) => { |
|
|
|
if (rawFile.type !== "image/jpeg") { |
|
|
|
ElMessage.error("Avatar picture must be JPG format!"); |
|
|
|
return false; |
|
|
|
} else if (rawFile.size / 1024 / 1024 > 2) { |
|
|
|
ElMessage.error("Avatar picture size can not exceed 2MB!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
}; |
|
|
|
// 确保todayTask和todayFree是有效的数字 |
|
|
|
const todayTask = |
|
|
|
typeof userGold.value.todayTask === "number" ? userGold.value.todayTask : 0; |
|
|
|
const todayFree = |
|
|
|
typeof userGold.value.todayFree === "number" ? userGold.value.todayFree : 0; |
|
|
|
|
|
|
|
//充值方式条目 |
|
|
|
const options = [ |
|
|
|
{ |
|
|
|
value: "现金充值", |
|
|
|
label: "现金充值", |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: "龙鳞卡", |
|
|
|
label: "龙鳞卡", |
|
|
|
}, |
|
|
|
{ |
|
|
|
value: "弘粉卡", |
|
|
|
label: "弘粉卡", |
|
|
|
}, |
|
|
|
]; |
|
|
|
// 根据用户输入的消费金币总数和已有的金币数量进行计算 |
|
|
|
addConsume.value.taskCoin = Math.min(originalAllGold, todayTask); |
|
|
|
let remainingGold = originalAllGold - addConsume.value.taskCoin; |
|
|
|
|
|
|
|
const calculatedFreeGold = computed(() => { |
|
|
|
return addConsume.value.paidGold * addConsume.value.activityId; |
|
|
|
}); |
|
|
|
addConsume.value.freeCoin = Math.min(remainingGold, todayFree); |
|
|
|
remainingGold -= addConsume.value.freeCoin; |
|
|
|
|
|
|
|
watch(calculatedFreeGold, (newVal) => { |
|
|
|
addConsume.value.freeGold = newVal; |
|
|
|
}); |
|
|
|
addConsume.value.rechargeCoin = remainingGold; // 剩余的都算作充值金币 |
|
|
|
|
|
|
|
// 恢复allGold的原始值 |
|
|
|
addConsume.value.allGold = originalAllGold; |
|
|
|
|
|
|
|
// 确保taskCoin, freeCoin, rechargeCoin不是NaN,如果是,则设置为0 |
|
|
|
if (isNaN(addConsume.value.taskCoin)) addConsume.value.taskCoin = 0; |
|
|
|
if (isNaN(addConsume.value.freeCoin)) addConsume.value.freeCoin = 0; |
|
|
|
if (isNaN(addConsume.value.rechargeCoin)) addConsume.value.rechargeCoin = 0; |
|
|
|
|
|
|
|
console.log("计算结果", addConsume.value); |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
@ -196,9 +174,14 @@ watch(calculatedFreeGold, (newVal) => { |
|
|
|
:rules="rules" |
|
|
|
label-width="auto" |
|
|
|
style="max-width: 750px" |
|
|
|
class="form-style" |
|
|
|
> |
|
|
|
<el-form-item prop="jwcode" label="精网号"> |
|
|
|
<el-input v-model="addConsume.jwcode" style="width: 220px" /> |
|
|
|
<el-input |
|
|
|
v-model="addConsume.jwcode" |
|
|
|
style="width: 220px" |
|
|
|
@change="getUserGold(addConsume.jwcode)" |
|
|
|
/> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
@click="getUser(addConsume.jwcode)" |
|
|
@ -208,53 +191,59 @@ watch(calculatedFreeGold, (newVal) => { |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="goods" label="商品名称"> |
|
|
|
<el-select |
|
|
|
v-model="addConsume.goods" |
|
|
|
v-model="addConsume.productId" |
|
|
|
placeholder="请选择" |
|
|
|
style="width: 300px" |
|
|
|
> |
|
|
|
<el-option |
|
|
|
v-for="item in activity" |
|
|
|
v-for="item in goods" |
|
|
|
:key="item.value" |
|
|
|
:label="item.activityName" |
|
|
|
:value="item.rechargeRatio" |
|
|
|
:label="item.name" |
|
|
|
:value="item.productId" |
|
|
|
/> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="allGold" label="消费金币总数"> |
|
|
|
<el-input v-model="addConsume.paidGold" style="width: 100px" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="taskCoin" label="任务金币" style="float: left"> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.taskCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
/> |
|
|
|
<p style="margin-right: 0px">个</p> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
prop="freeCoin" |
|
|
|
label="免费金币" |
|
|
|
style="float: left; margin-left: -10px; margin-right: -10px" |
|
|
|
> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.freeCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
/> |
|
|
|
<p style="margin-right: 0px">个</p> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
prop="rechargeCoin" |
|
|
|
label="充值金币" |
|
|
|
style="margin-left: -20px" |
|
|
|
> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.rechargeCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
v-model="addConsume.allGold" |
|
|
|
style="width: 100px" |
|
|
|
@change="calculateCoins()" |
|
|
|
/> |
|
|
|
<p style="margin-right: 20px">个</p> |
|
|
|
</el-form-item> |
|
|
|
<div style="display: flex; align-items: center"> |
|
|
|
<el-form-item prop="taskCoin" label="任务金币" style="float: left"> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.taskCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
/> |
|
|
|
<p style="margin-right: 0px">个</p> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
prop="freeCoin" |
|
|
|
label="免费金币" |
|
|
|
style="float: left; margin-left: -20px" |
|
|
|
> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.freeCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
/> |
|
|
|
<p style="margin-right: 0px">个</p> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item |
|
|
|
prop="rechargeCoin" |
|
|
|
label="充值金币" |
|
|
|
style="margin-left: -20px" |
|
|
|
> |
|
|
|
<el-input |
|
|
|
disabled |
|
|
|
v-model="addConsume.rechargeCoin" |
|
|
|
style="width: 100px; margin-left: -5px" |
|
|
|
/> |
|
|
|
<p style="margin-right: 20px">个</p> |
|
|
|
</el-form-item> |
|
|
|
</div> |
|
|
|
<el-form-item prop="remark" label="备注"> |
|
|
|
<el-input |
|
|
|
v-model="addConsume.remark" |
|
|
@ -273,17 +262,14 @@ watch(calculatedFreeGold, (newVal) => { |
|
|
|
placeholder="提交人姓名" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
<el-button @click="closeAddActivityVisible" style="margin-left: 280px" |
|
|
|
>取消</el-button |
|
|
|
> |
|
|
|
<el-button type="primary" @click="addBefore"> 提交 </el-button> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<el-button @click="closeAddActivityVisible" style="margin-left: 280px" |
|
|
|
>取消</el-button |
|
|
|
> |
|
|
|
<el-button type="primary" @click="addBefore"> 提交 </el-button> |
|
|
|
|
|
|
|
<!-- 客户信息栏 --> |
|
|
|
<el-card |
|
|
|
style="width: 700px; float: right; margin-top: -330px; margin-right: 100px" |
|
|
|
> |
|
|
|
<el-card style="width: 700px; float: right" class="form-style2"> |
|
|
|
<el-form |
|
|
|
:model="user" |
|
|
|
label-width="auto" |
|
|
@ -368,4 +354,12 @@ p { |
|
|
|
height: 50px; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
.form-style { |
|
|
|
margin-top: 50px; |
|
|
|
max-width: 50%; |
|
|
|
float: left; |
|
|
|
} |
|
|
|
.form-style2 { |
|
|
|
max-width: 50%; |
|
|
|
} |
|
|
|
</style> |