init
This commit is contained in:
318
pages/config/store.vue
Normal file
318
pages/config/store.vue
Normal file
@@ -0,0 +1,318 @@
|
||||
<template>
|
||||
|
||||
<view class="page-content">
|
||||
<view style=" padding: 20rpx;">
|
||||
|
||||
<nut-cell-group>
|
||||
<nut-cell v-if="!form.address_info?.address_id" title="收货地址" is-link @click="chooseAddress"></nut-cell>
|
||||
<nut-cell v-else :title="form.address_info.user_name + ' ' + form.address_info.tel_number" is-link
|
||||
:sub-title="
|
||||
form.address_info.province_name +
|
||||
form.address_info.city_name +
|
||||
form.address_info.county_name +
|
||||
form.address_info.street_name +
|
||||
form.address_info.detail_info_new
|
||||
" @click="chooseAddress"></nut-cell>
|
||||
</nut-cell-group>
|
||||
|
||||
|
||||
<view class="wechat-img-inner">
|
||||
<nut-button type="primary" block @click="saveAddress()">
|
||||
保存收货地址
|
||||
</nut-button>
|
||||
</view>
|
||||
|
||||
<nut-form>
|
||||
<nut-form-item label="商城名称">
|
||||
<nut-input v-model="form.shop_name" class="nut-input-text" placeholder="请输入店铺名称" type="text" />
|
||||
</nut-form-item>
|
||||
<nut-form-item label="商城介绍">
|
||||
<nut-textarea v-model="form.shop_desc" autosize placeholder="请输入店铺介绍" type="text" />
|
||||
</nut-form-item>
|
||||
<nut-form-item label="手机号码">
|
||||
<nut-input v-model="form.shop_phone" class="nut-input-text" placeholder="请输入手机号码" type="text" />
|
||||
</nut-form-item>
|
||||
|
||||
|
||||
<nut-form-item label="首页公告">
|
||||
<nut-textarea v-model="form.bulletin_txt" autosize placeholder="请输入首页公告" type="text" />
|
||||
</nut-form-item>
|
||||
|
||||
<nut-form-item label="服务描述">
|
||||
<nut-textarea v-model="form.service_txt" autosize placeholder="请输入服务描述" type="text" />
|
||||
</nut-form-item>
|
||||
<nut-form-item label="是否审核模式">
|
||||
<nut-switch v-model="isAudit" @change="onIsAuditChange" />
|
||||
<!-- <nut-switch v-model:modelValue="isAudit" @change="onIsAuditChange" /> -->
|
||||
</nut-form-item>
|
||||
<nut-form-item v-if="isBucket">
|
||||
<template v-slot:label>收款二维码</template>
|
||||
<template v-slot:default>
|
||||
<shmily-drag-image v-model="form.pay_imgs" :number=9 :add-image="addPayImg"
|
||||
keyName="file_path"></shmily-drag-image></template>
|
||||
</nut-form-item>
|
||||
|
||||
<nut-form-item v-if="isBucket">
|
||||
<template v-slot:label>微信二维码</template>
|
||||
<template v-slot:default>
|
||||
<shmily-drag-image v-model="form.wechat_imgs" :number=9 :add-image="addWechatImg"
|
||||
keyName="file_path"></shmily-drag-image></template>
|
||||
</nut-form-item>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<view style="align-items: center;text-align: center; padding: 20rpx 80rpx;">
|
||||
<nut-button type="primary" block @click="onSubmit">
|
||||
保存配置
|
||||
</nut-button>
|
||||
</view>
|
||||
</nut-form>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onMounted,
|
||||
reactive,
|
||||
ref,
|
||||
toValue
|
||||
} from 'vue';
|
||||
import {
|
||||
fetchGetConfig,
|
||||
fetchSetConfig,
|
||||
} from '@/api/config';
|
||||
import {
|
||||
getUploadImageUrl
|
||||
} from '@/api/request';
|
||||
|
||||
import {
|
||||
houseFetchUpdateAddress
|
||||
} from '@/api/house_order';
|
||||
|
||||
|
||||
|
||||
const isBucket = ref(false);
|
||||
// 是否开启审核模式
|
||||
const isAudit = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
shop_name: '',
|
||||
shop_desc: '',
|
||||
shop_phone: '',
|
||||
is_audit: 0,
|
||||
bulletin_txt: '',
|
||||
service_txt: '',
|
||||
pay_imgs: [],
|
||||
wechat_imgs: [],
|
||||
address_info: {}
|
||||
})
|
||||
|
||||
|
||||
// 是否开启整仓调价
|
||||
const onIsAuditChange = (val) => {
|
||||
form.is_audit = Number(isAudit.value)
|
||||
console.log(form);
|
||||
}
|
||||
|
||||
|
||||
const chooseAddress = () => {
|
||||
uni.chooseAddress({
|
||||
success(res) {
|
||||
console.log(res);
|
||||
form.address_info = {
|
||||
address_id: res.addressID || 1,
|
||||
user_name: res.userName,
|
||||
tel_number: res.telNumber,
|
||||
city_name: res.cityName || '',
|
||||
county_name: res.countyName || '',
|
||||
detail_info: res.detailInfo || '',
|
||||
detail_info_new: res.detailInfoNew || '',
|
||||
national_code: res.nationalCode || '',
|
||||
national_code_full: res.nationalCodeFull || '',
|
||||
postal_code: res.postalCode || '',
|
||||
province_name: res.provinceName || '',
|
||||
street_name: res.streetName || '',
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取配置
|
||||
const getConfig = () => {
|
||||
fetchGetConfig().then(res => {
|
||||
console.log('res=====>', res)
|
||||
form.shop_name = res.appConfig.shop_name
|
||||
form.shop_desc = res.appConfig.shop_desc
|
||||
form.shop_phone = res.appConfig.shop_phone
|
||||
|
||||
form.bulletin_txt = res.appConfig.bulletin_txt
|
||||
form.service_txt = res.appConfig.service_txt
|
||||
|
||||
|
||||
form.address_info = res.appConfig.address_info
|
||||
|
||||
form.is_audit = res.appConfig.is_audit
|
||||
isAudit.value = res.appConfig.is_audit == 1
|
||||
|
||||
if (res.appConfig.bucket) {
|
||||
isBucket.value = true
|
||||
}
|
||||
let pay_imgs = JSON.parse(res.appConfig.pay_imgs)
|
||||
let wechat_imgs = JSON.parse(res.appConfig.wechat_imgs)
|
||||
pay_imgs.forEach(item => {
|
||||
form.pay_imgs.push({
|
||||
id: item.image_id,
|
||||
file_path: item.file_path,
|
||||
})
|
||||
})
|
||||
wechat_imgs.forEach(item => {
|
||||
form.wechat_imgs.push({
|
||||
id: item.image_id,
|
||||
file_path: item.file_path,
|
||||
})
|
||||
})
|
||||
console.log('form=====>', form)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const onSubmit = () => {
|
||||
fetchSetConfig(form).then(res => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '更新商城配置成功'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/config/store',
|
||||
success: res => {},
|
||||
fail: () => {},
|
||||
complete: () => {}
|
||||
});
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 保存收货地址
|
||||
const saveAddress = () => {
|
||||
houseFetchUpdateAddress({
|
||||
address: form.address_info,
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '保存收货地址成功'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/config/store',
|
||||
success: res => {},
|
||||
fail: () => {},
|
||||
complete: () => {}
|
||||
});
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getConfig()
|
||||
})
|
||||
|
||||
// 上传支付图片
|
||||
const addPayImg = () => {
|
||||
uni.chooseImage({
|
||||
count: 9 - (form.pay_imgs.length || 0),
|
||||
sourceType: ['album', 'camera'],
|
||||
success: res => {
|
||||
res.tempFiles.forEach(file => {
|
||||
uni.uploadFile({
|
||||
url: getUploadImageUrl(),
|
||||
filePath: file.path,
|
||||
name: 'iFile',
|
||||
formData: {
|
||||
group_id: 1,
|
||||
},
|
||||
success: (res) => {
|
||||
let data = JSON.parse(res.data).data
|
||||
form.pay_imgs.push({
|
||||
id: parseInt(data.file_id),
|
||||
file_path: data.file_path,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 上传微信图片
|
||||
const addWechatImg = () => {
|
||||
uni.chooseImage({
|
||||
count: 9 - (form.wechat_imgs.length || 0),
|
||||
sourceType: ['album', 'camera'],
|
||||
success: res => {
|
||||
res.tempFiles.forEach(file => {
|
||||
uni.uploadFile({
|
||||
url: getUploadImageUrl(),
|
||||
filePath: file.path,
|
||||
name: 'iFile',
|
||||
formData: {
|
||||
group_id: 1,
|
||||
},
|
||||
success: (res) => {
|
||||
let data = JSON.parse(res.data).data
|
||||
form.wechat_imgs.push({
|
||||
id: parseInt(data.file_id),
|
||||
file_path: data.file_path,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-content {
|
||||
min-height: 100vh;
|
||||
background-color: #f2f3f5;
|
||||
|
||||
}
|
||||
|
||||
.wechat-img-inner {
|
||||
// margin-top: 60rpx;
|
||||
padding: 0rpx 80rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
// gap: 5px;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
background: #ffffff;
|
||||
align-items: center;
|
||||
max-height: 300rpx;
|
||||
overflow-y: scroll;
|
||||
padding: 10px;
|
||||
|
||||
.list-item {
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 20rpx 10rpx;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user