plus-ui/src/views/set/integralSetting.vue

111 lines
3.0 KiB
Vue
Raw Normal View History

<template>
<div class="app-container">
<el-card>
2025-06-07 15:51:05 +08:00
<template v-slot:header>
<div class="clearfix">
<div class="flex-center">
<h2>积分获取规则</h2>
<el-button class="ml-auto" type="primary" @click="saveData">保存 </el-button>
</div>
</div>
2025-06-07 15:51:05 +08:00
</template>
<el-form :model="incomeVal" label-width="180px">
<el-form-item label="签到活动状态">
2025-06-07 15:51:05 +08:00
<el-switch v-model="incomeVal.signStatus" :active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="每日签到固定积分">
2025-06-07 15:51:05 +08:00
<el-input type="number" v-model="incomeVal.signCount" style="width: 200px" placeholder="每天签到获取的积分">
<template v-slot:append>
<span>积分</span>
</template>
</el-input>
</el-form-item>
<el-form-item label="消费获得积分">
<div class="flex-center">
<span class="mr5">每消费</span>
2025-06-07 15:51:05 +08:00
<el-input type="number" v-model="incomeVal.orderAmount" style="width: 200px" placeholder="每天签到获取的积分">
<template v-slot:append>
<span></span>
</template>
</el-input>
<span class="ml5 mr5">获得</span>
2025-06-07 15:51:05 +08:00
<el-input type="number" v-model="incomeVal.orderCount" style="width: 200px" placeholder="每天签到获取的积分">
<template v-slot:append>
<span>积分</span>
</template>
</el-input>
</div>
</el-form-item>
</el-form>
</el-card>
</div>
</template>
<script>
2025-06-07 15:51:05 +08:00
import { addOrUpdate, getConfigKey2 } from '@/api/system/config';
2025-06-07 15:51:05 +08:00
const key = 'activity-integral-income-set-key';
const defaultIncomeVal = {
signStatus: 1,
signCount: 1,
orderAmount: 1,
orderCount: 1
2025-06-07 15:51:05 +08:00
};
export default {
data() {
return {
incomeObj: {},
2025-06-07 15:51:05 +08:00
incomeVal: {}
};
},
methods: {
initData() {
2025-06-07 15:51:05 +08:00
getConfigKey2(key).then((res) => {
if (res.data) {
2025-06-07 15:51:05 +08:00
this.incomeObj = res.data;
this.incomeVal = JSON.parse(res.data.configValue);
} else {
2025-06-07 15:51:05 +08:00
this.incomeVal = { ...defaultIncomeVal };
this.incomeObj = {
configValue: JSON.stringify(this.incomeVal),
configKey: key,
configType: 'N',
configName: '积分获取规则',
configId: null
2025-06-07 15:51:05 +08:00
};
}
});
},
2025-06-07 15:51:05 +08:00
saveData() {
const self = this;
this.$modal
.confirm('是否确认要保存积分获取规则?')
.then(function () {
self.incomeObj.configValue = JSON.stringify(self.incomeVal);
return addOrUpdate(self.incomeObj);
})
.then(() => {
this.initData();
this.$modal.msgSuccess('保存成功');
})
.catch(() => {});
}
},
created() {
2025-06-07 15:51:05 +08:00
this.initData();
}
};
</script>
<style lang="scss" scoped>
.number-input {
width: 120px;
}
.jc {
justify-content: center;
}
</style>