|
|
|
@ -264,11 +264,12 @@ function calculateCoins(sumGold) { |
|
|
|
// 用来写的 cookie 的 key |
|
|
|
const WriteCookies = ref(null) |
|
|
|
// 用来写的 cookie 的 value |
|
|
|
const WriteCookiesTime = ref(null) |
|
|
|
const WriteCookiesVale = ref({}) |
|
|
|
// 用来读的 cookie 的 key |
|
|
|
const ReadCookies = ref(null) |
|
|
|
// 用来读的 cookie 的 value |
|
|
|
const ReadCookiesTime = ref(null) |
|
|
|
const ReadCookiesValue = ref({}) |
|
|
|
const orderStatus = ref('') |
|
|
|
|
|
|
|
|
|
|
|
// 这是添加消费信息的接口 |
|
|
|
@ -298,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.value, |
|
|
|
goodsName: addConsume.value.goodsName?.value || addConsume.value.goodsName, |
|
|
|
remark: addConsume.value.remark, |
|
|
|
adminName: adminData.value.adminName, |
|
|
|
redMoney: Number(addConsume.value.redMoney), // 1-使用红包,0-不使用红包 |
|
|
|
@ -322,16 +323,15 @@ const add = async function () { |
|
|
|
function handleResponse(result) { |
|
|
|
console.log("响应结果", result) |
|
|
|
if (result.code === 200) { |
|
|
|
//存一下 用户的jwcode |
|
|
|
// 拼接 jwcode:permanentGold:freeGold |
|
|
|
WriteCookies.value = `coinConsume:${addConsume.value.jwcode}:${addConsume.value.goodsName.value}` |
|
|
|
//value 为当前消耗时间 |
|
|
|
WriteCookiesTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss"); |
|
|
|
// 设置cookies,用户jwcode为key,value也是jwcode,过期时间为1天 |
|
|
|
Cookies.set(WriteCookies.value, WriteCookiesTime.value, { |
|
|
|
expires: |
|
|
|
1, path: '/' |
|
|
|
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: 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')); |
|
|
|
console.log("请求成功", result); |
|
|
|
} else { |
|
|
|
@ -448,6 +448,26 @@ const FirstConsumeDialogVisibleCancel = () => { |
|
|
|
// }); |
|
|
|
// }; |
|
|
|
|
|
|
|
|
|
|
|
const historyOrder = ref({}) |
|
|
|
// 查询订单号对应的状态 |
|
|
|
const selectByOrderCode = async function (data) { |
|
|
|
try { |
|
|
|
const result = await request({ |
|
|
|
url: '/recharge/selectByOrderCode', |
|
|
|
data: data, |
|
|
|
headers: { |
|
|
|
'Content-Type': 'text/plain;charset=utf-8' |
|
|
|
}, |
|
|
|
}) |
|
|
|
if(result.code == 200){ |
|
|
|
historyOrder.value = result.data |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.log('请求失败', error) |
|
|
|
// 在这里可以处理错误逻辑,比如显示错误提示等 |
|
|
|
} |
|
|
|
} |
|
|
|
// 添加前验证 |
|
|
|
const addBefore = () => { |
|
|
|
Ref.value.validate(async (valid) => { |
|
|
|
@ -462,14 +482,26 @@ const addBefore = () => { |
|
|
|
if (!validateInput() || !validateRedLimit()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ReadCookies.value = `coinConsume:${addConsume.value.jwcode}:${addConsume.value.goodsName.value}` |
|
|
|
ReadCookies.value = `coinConsume-${addConsume.value.jwcode}-${addConsume.value.goodsName.value}` |
|
|
|
console.log('ReadCookies',ReadCookies.value); |
|
|
|
// 获取cookie |
|
|
|
const cookie = Cookies.get(ReadCookies.value) |
|
|
|
console.log("time", WriteCookiesTime.value) |
|
|
|
// 格式化时间 |
|
|
|
ReadCookiesTime.value = moment(cookie).format('YYYY-MM-DD HH:mm:ss') |
|
|
|
console.log("cookie========", cookie) |
|
|
|
if (cookie) { |
|
|
|
const cookieValue = Cookies.get(ReadCookies.value); |
|
|
|
if (cookieValue) { |
|
|
|
// 解析为对象 |
|
|
|
const rechargeInfo = JSON.parse(cookieValue); |
|
|
|
console.log('提交时间:', rechargeInfo.payTime); |
|
|
|
console.log('订单号:', rechargeInfo.orderCode); |
|
|
|
ReadCookiesValue.value = { |
|
|
|
...rechargeInfo, |
|
|
|
} |
|
|
|
}else{ |
|
|
|
ReadCookiesValue.value = {} |
|
|
|
} |
|
|
|
console.log('ReadCookies',ReadCookiesValue.value); |
|
|
|
if (Object.keys(ReadCookiesValue.value).length > 0) { |
|
|
|
await selectByOrderCode(ReadCookiesValue.value.orderCode) |
|
|
|
orderStatus.value = historyOrder.value.isRefundDesc |
|
|
|
ReadCookiesValue.value.goodsName = historyOrder.value.goodsName |
|
|
|
ConsumeDialogVisible.value = true; |
|
|
|
} else { |
|
|
|
FirstConsumeDialogVisible.value = true; |
|
|
|
@ -606,16 +638,26 @@ watch( |
|
|
|
); |
|
|
|
|
|
|
|
// 监听商品选择,自动展示原价 |
|
|
|
watch( |
|
|
|
() => addConsume.value.goodsName, |
|
|
|
(newGoods) => { |
|
|
|
if (newGoods && typeof newGoods === 'object') { |
|
|
|
addConsume.value.price = Number(newGoods.price || 0) || null; |
|
|
|
const handleGoodsChange = (val) => { |
|
|
|
// val 现在是整个对象 |
|
|
|
if (val) { |
|
|
|
addConsume.value.price = Number(val.price || 0) || null; |
|
|
|
} else { |
|
|
|
addConsume.value.price = null; |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 监听商品选择,自动展示原价 |
|
|
|
// watch( |
|
|
|
// () => addConsume.value.goodsName, |
|
|
|
// (newGoods) => { |
|
|
|
// if (newGoods && typeof newGoods === 'object') { |
|
|
|
// addConsume.value.price = Number(newGoods.price || 0) || null; |
|
|
|
// } else { |
|
|
|
// addConsume.value.price = null; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// ); |
|
|
|
|
|
|
|
/* |
|
|
|
====================红包逻辑================================= |
|
|
|
@ -744,9 +786,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> |
|
|
|
<el-option v-for="(item, index) in goods" :key="index" :label="item.label" :value="item" /> |
|
|
|
|
|
|
|
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')"> |
|
|
|
@ -1006,13 +1047,13 @@ onMounted(async function () { |
|
|
|
<el-icon :size="24" color="#FFD700"> |
|
|
|
<WarnTriangleFilled /> |
|
|
|
</el-icon> |
|
|
|
<p>{{ $t('common_add.prompt') }}</p> |
|
|
|
<p>{{ $t('common_add.promptConsume') }}</p> |
|
|
|
</div> |
|
|
|
<!-- 记录 + 虚线分隔 --> |
|
|
|
<div> |
|
|
|
<el-divider border-style="dashed" /> |
|
|
|
<p>{{ $t('common_add.similarRechargeRecords') }}</p> |
|
|
|
· {{ ReadCookiesTime }} {{ $t('common_add.buy') }} 【{{ addConsume.goodsName.value }}】({{ |
|
|
|
<p>{{ $t('common_add.similarCosumeRecords') }}</p> |
|
|
|
· {{ ReadCookiesValue.payTime }} {{ $t('common_add.buy') }} 【{{ ReadCookiesValue.goodsName }}】【{{ $t('common_add.orderStatus') }}: {{ orderStatus }}】({{ |
|
|
|
$t('common_add.operator') }}: {{ adminData.adminName }}) |
|
|
|
</div> |
|
|
|
<div style="margin-top: 10px"> |
|
|
|
|