You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
2.9 KiB
Vue

<template>
<view>
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
<wd-form ref="form" :model="formData" :rules="formRules">
<view class="p-3 bg-white rounded mb-2">
<div class="name mb-2 text-xs">开启自定义金额:</div>
<view class="bg-white px-3 py-2 rounded flex items-center">
<wd-switch v-model="formData.status" :active-value="1" :inactive-value="0" />
</view>
</view>
<div class="mb-2">
<!-- 广告图片 -->
<wd-cell-group class="flex py-2 w-full" title="广告图片">
<view class="ml-3">
<yUpload v-model="formData.adv_img" :size="1"></yUpload>
</view>
</wd-cell-group>
<!-- 充值说明图标 -->
<wd-cell-group class="flex py-2 w-full" title="充值说明图标">
<view class="ml-3">
<yUpload v-model="formData.icon" :size="1"></yUpload>
</view>
</wd-cell-group>
</div>
<!-- 基础信息 -->
<wd-cell-group title="基础信息" border>
<wd-input label="充值说明" v-model="formData.tip" />
</wd-cell-group>
<!-- 提交按钮 -->
<view class="mt-2 px-12 py-3 bg-slate-50">
<wd-button type="primary" size="large" @click="handleSubmit" block>
保存
</wd-button>
</view>
</wd-form>
</view>
</template>
<script>
import kevyloading from "@/components/kevy-loading/kevy-loading";
import utils from '@/utils/utils.js'
import rechargeApi from '@/api/store/recharge.js'
import yUpload from "@/components/yUpload/index.vue";
export default {
components: {
kevyloading, yUpload
},
data() {
return {
utils,
// 表单数据
formData: {
"adv_url": "", //
},
// 表单验证规则
formRules: {
// 在这里添加其他字段的验证规则
},
// 地区选择器的数据
addrList: [
// 在这里添加省市区的数据
],
classifyList: [],
loading: false
};
},
async onLoad(e) {
this.getData();
if (e.edit) {
this.formData = JSON.parse(e.edit)
}
},
methods: {
async getData() {
const res = await rechargeApi.rechargeSet.list({
...this.formData,
});
this.formData = res.data || {}
},
/**
* 处理表单提交
*/
async handleSubmit() {
console.log(this.formData);
try {
// 处理表单提交的逻辑
const res = await rechargeApi.rechargeSet.save({
...this.formData,
});
if (res.code == 0) {
setTimeout(() => {
uni.showToast({
title: '保存成功!',
icon: 'success'
});
}, 100);
// uni.navigateBack()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
} catch (error) {
console.log(error);
setTimeout(() => {
uni.showToast({
title: '请检查表单!',
icon: 'none'
});
}, 100);
}
},
},
};
</script>
<style>
/* 在这里添加样式,根据需要自定义表单样式 */
</style>