|
|
|
@ -105,7 +105,6 @@ const rules = reactive({ |
|
|
|
}); |
|
|
|
// 查询商品的表单 |
|
|
|
const goods = ref([]) |
|
|
|
const allGoods = ref([]) |
|
|
|
|
|
|
|
// 输入验证函数 |
|
|
|
function validateInput() { |
|
|
|
@ -300,7 +299,7 @@ const add = async function () { |
|
|
|
freeGold: addConsume.value.freeGold * 100, |
|
|
|
taskGold: addConsume.value.taskGold * 100, |
|
|
|
permanentGold: addConsume.value.permanentGold * 100, |
|
|
|
goodsName: addConsume.value.goodsName, |
|
|
|
goodsName: addConsume.value.goodsName?.value || addConsume.value.goodsName, |
|
|
|
remark: addConsume.value.remark, |
|
|
|
adminName: adminData.value.adminName, |
|
|
|
redMoney: Number(addConsume.value.redMoney), // 1-使用红包,0-不使用红包 |
|
|
|
@ -324,11 +323,13 @@ const add = async function () { |
|
|
|
function handleResponse(result) { |
|
|
|
console.log("响应结果", result) |
|
|
|
if (result.code === 200) { |
|
|
|
WriteCookies.value = `coinConsume-${addConsume.value.jwcode}-${addConsume.value.goodsName}` |
|
|
|
const goodsNameStr = addConsume.value.goodsName?.value || addConsume.value.goodsName |
|
|
|
WriteCookies.value = `coinConsume-${addConsume.value.jwcode}-${goodsNameStr}` |
|
|
|
//value 为消耗时间 |
|
|
|
console.log("goodsNameStr add", goodsNameStr) |
|
|
|
WriteCookiesVale.value = JSON.stringify({ |
|
|
|
payTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
|
|
|
orderCode: result.data |
|
|
|
payTime: moment(result.data.createTime).format("YYYY-MM-DD HH:mm:ss"), |
|
|
|
orderCode: result.data.orderCoder, |
|
|
|
}); |
|
|
|
Cookies.set(WriteCookies.value, WriteCookiesVale.value, {expires: 1, path: '/'}); |
|
|
|
ElMessage.success(t('elmessage.addSuccess')); |
|
|
|
@ -481,14 +482,14 @@ const addBefore = () => { |
|
|
|
if (!validateInput() || !validateRedLimit()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ReadCookies.value = `coinConsume-${addConsume.value.jwcode}-${addConsume.value.goodsName}` |
|
|
|
ReadCookies.value = `coinConsume-${addConsume.value.jwcode}-${addConsume.value.goodsName.value}` |
|
|
|
console.log('ReadCookies',ReadCookies.value); |
|
|
|
// 获取cookie |
|
|
|
const cookieValue = Cookies.get(ReadCookies.value); |
|
|
|
if (cookieValue) { |
|
|
|
// 解析为对象 |
|
|
|
const rechargeInfo = JSON.parse(cookieValue); |
|
|
|
console.log('充值时间:', rechargeInfo.payTime); |
|
|
|
console.log('提交时间:', rechargeInfo.payTime); |
|
|
|
console.log('订单号:', rechargeInfo.orderCode); |
|
|
|
ReadCookiesValue.value = { |
|
|
|
...rechargeInfo, |
|
|
|
@ -606,13 +607,12 @@ const getGoods = async function () { |
|
|
|
}); |
|
|
|
// 将响应结果存储到响应式数据中 |
|
|
|
console.log("请求成功", result); |
|
|
|
allGoods.value = result.data.map(item => ({ |
|
|
|
goods.value = result.data.map(item => ({ |
|
|
|
id: item.id, |
|
|
|
label: item.name, |
|
|
|
value: item.name, |
|
|
|
price: item.price |
|
|
|
})); |
|
|
|
goods.value = allGoods.value; |
|
|
|
} catch (error) { |
|
|
|
console.log("请求失败", error); |
|
|
|
// 在这里可以处理错误逻辑,比如显示错误提示等 |
|
|
|
@ -643,24 +643,14 @@ watch( |
|
|
|
|
|
|
|
// 监听商品选择,自动展示原价 |
|
|
|
const handleGoodsChange = (val) => { |
|
|
|
const selectedItem = goods.value.find(item => item.value === val); |
|
|
|
if (selectedItem) { |
|
|
|
addConsume.value.price = Number(selectedItem.price || 0) || null; |
|
|
|
// val 现在是整个对象 |
|
|
|
if (val) { |
|
|
|
addConsume.value.price = Number(val.price || 0) || null; |
|
|
|
} else { |
|
|
|
addConsume.value.price = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 自定义搜索方法 |
|
|
|
const handleFilter = (query) => { |
|
|
|
if (query) { |
|
|
|
goods.value = allGoods.value.filter(item => { |
|
|
|
return item.label.toLowerCase().includes(query.toLowerCase()) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
goods.value = allGoods.value |
|
|
|
} |
|
|
|
} |
|
|
|
// 监听商品选择,自动展示原价 |
|
|
|
// watch( |
|
|
|
// () => addConsume.value.goodsName, |
|
|
|
@ -800,8 +790,8 @@ onMounted(async function () { |
|
|
|
|
|
|
|
<el-form-item prop="goodsName" :label="t('common_add.goodsName')"> |
|
|
|
<el-select v-model="addConsume.goodsName" :placeholder="t('common_add.goodsNamePlaceholder')" |
|
|
|
style="width: 200px" clearable filterable :filter-method="handleFilter" @change="handleGoodsChange"> |
|
|
|
<el-option v-for="(item, index) in goods" :key="item.id" :label="item.label" :value="item.value" /> |
|
|
|
style="width: 200px" clearable filterable @change="handleGoodsChange" value-key="id"> |
|
|
|
<el-option v-for="(item, index) in goods" :key="item.id" :label="item.label" :value="item" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="price" :label="t('common_add.price')"> |
|
|
|
@ -969,7 +959,7 @@ onMounted(async function () { |
|
|
|
<!-- 商品名称 --> |
|
|
|
<div class="field"> |
|
|
|
<div class="field-label">{{ $t('common_add.goodsName') }}</div> |
|
|
|
<el-input v-model="addConsume.goodsName" disabled /> |
|
|
|
<el-input v-model="addConsume.goodsName.value" disabled /> |
|
|
|
</div> |
|
|
|
<!--金币总数 --> |
|
|
|
<div class="field"> |
|
|
|
@ -1027,7 +1017,7 @@ onMounted(async function () { |
|
|
|
<!-- 商品名称 --> |
|
|
|
<div class="field"> |
|
|
|
<div class="field-label">{{ $t('common_add.goodsName') }}</div> |
|
|
|
<el-input v-model="addConsume.goodsName" disabled /> |
|
|
|
<el-input v-model="addConsume.goodsName.value" disabled /> |
|
|
|
</div> |
|
|
|
<!--金币总数 --> |
|
|
|
<div class="field"> |
|
|
|
@ -1067,7 +1057,7 @@ onMounted(async function () { |
|
|
|
<div> |
|
|
|
<el-divider border-style="dashed" /> |
|
|
|
<p>{{ $t('common_add.similarCosumeRecords') }}</p> |
|
|
|
· {{ ReadCookiesValue.payTime }} {{ $t('common_add.buy') }} 【{{ addConsume.goodsName }}】【{{ $t('common_add.orderStatus') }}: {{ orderStatus }}】({{ |
|
|
|
· {{ ReadCookiesValue.payTime }} {{ $t('common_add.buy') }} 【{{ addConsume.goodsName.value }}】【{{ $t('common_add.orderStatus') }}: {{ orderStatus }}】({{ |
|
|
|
$t('common_add.operator') }}: {{ adminData.adminName }}) |
|
|
|
</div> |
|
|
|
<div style="margin-top: 10px"> |
|
|
|
|