<template>
|
<view class="store-info-page">
|
<view class="top-gradient"></view>
|
<view class="form-card">
|
<text class="page-title">门店信息</text>
|
<view class="form-group">
|
<text class="label">门店名称</text>
|
<text class="text-input align-left" style="font-weight: 600;margin-left: 30rpx;">{{info.name}}</text>
|
</view>
|
<view class="form-group">
|
<text class="label">门店头像<text class="required">*</text></text>
|
<view class="upload-row" style="margin-top: 20rpx;">
|
<view class="upload-box" @click="chooseAndUploadImage(1)">
|
<view class="upload-plus">+</view>
|
<text class="upload-text">上传照片</text>
|
</view>
|
<view :key="index" class="photo-box" v-if="form.coverImgUrl">
|
<image class="photo-image" :src="form.coverImgUrl" mode="aspectFill"></image>
|
</view>
|
</view>
|
</view>
|
<view class="divider"></view>
|
<view class="form-group textarea-group">
|
<text class="label">门店介绍</text>
|
<textarea v-model="form.content" maxlength="200" placeholder="请输入门店介绍" class="text-area charge-area" placeholder-style="color: #B2B2B2;" auto-height></textarea>
|
</view>
|
<view class="divider"></view>
|
<view class="form-group switch-group">
|
<view class="label-row">
|
<text class="label">是否全天营业</text>
|
<text class="required">*</text>
|
</view>
|
<view class="switch-row">
|
<view class="switch-pill" :class="{ active: form.businessType ===1 }" @tap="form.businessType = 1">是</view>
|
<view class="switch-pill" :class="{ active: form.businessType===0 }" @tap="form.businessType = 0">否</view>
|
</view>
|
</view>
|
<view class="form-group">
|
<view class="label-row">
|
<text class="label">营业时间</text>
|
<text class="required">*</text>
|
</view>
|
<textarea v-model="form.shopHours" maxlength="200" placeholder="必填,请输入门店营业时间" class="text-area charge-area" placeholder-style="color: #B2B2B2;" auto-height></textarea>
|
</view>
|
<view class="divider"></view>
|
<view class="form-group">
|
<text class="label">寄存类型</text>
|
<textarea v-model="form.depositTypes" maxlength="200" placeholder="请输入可寄存类型" class="text-area charge-area" placeholder-style="color: #B2B2B2;" auto-height></textarea>
|
</view>
|
<view class="divider"></view>
|
<view class="form-group">
|
<view class="label-row">
|
<text class="label">配送范围</text>
|
<text class="required">*</text>
|
</view>
|
<view class="input-with-unit">
|
<input v-model="form.deliveryArea" class="text-input" type="digit" placeholder="必填,请输入" placeholder-style="color: #B2B2B2;" />
|
<text class="unit-text" style="font-size: 28rpx;">公里</text>
|
</view>
|
</view>
|
|
<view class="divider"></view>
|
|
<view class="form-group textarea-group last-group">
|
<view class="label-row">
|
<text class="label">收费标准</text>
|
<text class="required">*</text>
|
</view>
|
<textarea v-model="form.feeStandard" placeholder="必填,请输入门店收费标准" class="text-area charge-area" placeholder-style="color: #B2B2B2;" auto-height></textarea>
|
</view>
|
</view>
|
|
<view class="save-wrap">
|
<view class="save-btn" @click="maintainShop">保存</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import { mapState } from 'vuex'
|
export default {
|
computed: {
|
...mapState(['navHeight', 'statusbarHeight','shopInfo','shopToken'])
|
},
|
data() {
|
return {
|
info:{},
|
form:{
|
coverImgUrl:"",
|
businessType: 0,
|
content: "",
|
coverImg: "",
|
deliveryArea: 0,
|
depositTypes:"" ,
|
feeStandard:"" ,
|
shopHours: ""
|
}
|
}
|
},
|
onShow() {
|
},
|
onLoad() {
|
this.info ={}
|
this.getMyShop()
|
},
|
methods:{
|
previewImage(images,index = 0) {
|
uni.previewImage({
|
current: index,
|
urls: images
|
});
|
},
|
async getMyShop(index){
|
var that =this
|
let res1 = await that.$u.api.getShopInfoDetail()
|
if (res1.code === 200) {
|
this.info = res1.data
|
}
|
let res = await that.$u.api.maintainInfo()
|
if (res.code === 200) {
|
if(res.data){
|
this.form ={
|
coverImgUrl:res.data.coverImgUrl || '',
|
businessType: res.data.businessType || 0,
|
content: res.data.content || '',
|
coverImg: res.data.coverImg || '',
|
deliveryArea: res.data.deliveryArea || 0,
|
depositTypes: res.data.depositTypes || '',
|
feeStandard:res.data.feeStandard || '',
|
shopHours: res.data.shopHours || '',
|
}
|
}
|
}
|
},
|
maintainShop(index){
|
if(this.loading){
|
return;
|
}
|
if(!this.form.coverImg){
|
uni.showToast({
|
title:"请上传门店头像",
|
icon:'none'
|
})
|
return
|
}
|
if(!this.form.shopHours){
|
uni.showToast({
|
title:"请填写营业时间",
|
icon:'none'
|
})
|
return
|
}
|
if(!this.form.deliveryArea){
|
uni.showToast({
|
title:"请填写配送范围",
|
icon:'none'
|
})
|
return
|
}
|
if(!this.form.feeStandard){
|
uni.showToast({
|
title:"请填写收费标准",
|
icon:'none'
|
})
|
return
|
}
|
this.loading = true
|
try{
|
var that =this
|
that.$u.api.maintainShopInfo(this.form).then(res=>{
|
if (res.code === 200) {
|
uni.showToast({
|
title:"信息保存成功",
|
icon:'success'
|
})
|
}
|
this.loading =false
|
})
|
}catch(e){
|
this.loading =false
|
}
|
},
|
async uploadFiles(filePaths, maxCount =1) {
|
console.log("==================================1")
|
if (!filePaths || !filePaths.length) {
|
return null
|
}
|
|
console.log("==================================3")
|
const uploadTasks = filePaths.map(filePath => {
|
return new Promise((resolve, reject) => {
|
uni.uploadFile({
|
url: this.$baseUrl + '/web/public/upload',
|
filePath: filePath,
|
name: 'file',
|
formData: {
|
folder: 'shop'
|
},
|
success: (res) => {
|
if (res.statusCode === 200) {
|
const data = JSON.parse(res.data)
|
if (data.code === 200) {
|
resolve(data.data)
|
} else {
|
|
console.log("==================================6")
|
reject(new Error(data.msg || '上传失败'))
|
}
|
} else {
|
|
console.log("==================================4")
|
reject(new Error('上传失败'))
|
}
|
},
|
fail: (err) => {
|
|
console.log("==================================5",err)
|
reject(err)
|
}
|
})
|
})
|
})
|
try {
|
const results = await Promise.all(uploadTasks)
|
return results
|
} catch (error) {
|
uni.showToast({
|
title: '上传失败',
|
icon: 'none'
|
})
|
throw error
|
}
|
},
|
async chooseAndUploadImage(maxCount = 1) {
|
var that = this
|
uni.chooseImage({
|
count: 1,
|
sizeType: ['compressed'],
|
sourceType: ['album', 'camera'],
|
success: async (res) => {
|
const tempFilePaths = res.tempFilePaths
|
uni.showLoading({
|
title: '上传中...',
|
mask: true
|
})
|
try {
|
const uploadResults = await that.uploadFiles(tempFilePaths, maxCount)
|
|
that.form.coverImgUrl = uploadResults.map(item => item.url || item.path || item)[0]
|
that.form.coverImg = uploadResults.map(item => item.imgaddr)[0]
|
console.log(that.form,"=====================================01")
|
uni.hideLoading()
|
uni.showToast({
|
title: '上传成功',
|
icon: 'success'
|
})
|
} catch (error) {
|
uni.hideLoading()
|
}
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.upload-row {
|
display: flex;
|
align-items: flex-start;
|
gap: 10rpx;
|
margin-bottom: 22rpx;
|
}
|
|
.upload-box,
|
.photo-box {
|
width: 122rpx;
|
height: 122rpx;
|
border-radius: 0;
|
overflow: hidden;
|
position: relative;
|
box-sizing: border-box;
|
}
|
|
.upload-box {
|
border: 1rpx dashed #c8ccd4;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.upload-plus {
|
font-size: 54rpx;
|
line-height: 1;
|
color: #999999;
|
}
|
|
.upload-text {
|
margin-top: 8rpx;
|
font-size: 24rpx;
|
color: #999999;
|
}
|
|
.photo-image {
|
width: 100%;
|
height: 100%;
|
}
|
.store-info-page {
|
position: relative;
|
height: 482rpx;
|
background: #f2fbff;
|
padding: 20rpx 30rpx;
|
box-sizing: border-box;
|
}
|
|
.top-gradient {
|
position: absolute;
|
left: 0;
|
top: 0;
|
width: 100%;
|
height: 220rpx;
|
background: linear-gradient(180deg, #bfeefe 0%, #ebfaff 58%, #f2fbff 100%);
|
z-index: 0;
|
}
|
|
.form-card {
|
position: relative;
|
z-index: 1;
|
background: #ffffff;
|
border-radius: 20rpx;
|
padding: 30rpx;
|
box-sizing: border-box;
|
box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0,0,0,0.08);
|
}
|
|
.page-title {
|
display: block;
|
font-weight: 600;
|
font-size: 36rpx;
|
color: #222222;
|
}
|
|
.form-group {
|
padding: 30rpx 0;
|
box-sizing: border-box;
|
}
|
|
.form-group.textarea-group {
|
padding-bottom: 10rpx;
|
}
|
|
.last-group {
|
padding-bottom: 22rpx;
|
}
|
|
.label,
|
.required,
|
.unit-text {
|
font-size: 30rpx;
|
}
|
|
.label {
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #222222;
|
}
|
|
.label-row {
|
display: flex;
|
align-items: center;
|
}
|
|
.required {
|
margin-left: 2rpx;
|
color: #ff4d4f;
|
line-height: 1;
|
}
|
|
.text-input {
|
width: 100%;
|
height: 48rpx;
|
margin-top: 14rpx;
|
font-weight: 400;
|
font-size: 30rpx;
|
color: #111111;
|
background: transparent;
|
}
|
|
.text-input.align-left {
|
text-align: left;
|
}
|
|
.placeholder {
|
font-size: 28rpx;
|
color: #c4c9d1;
|
}
|
|
.text-area {
|
width: 100%;
|
min-height: 56rpx;
|
margin-top: 14rpx;
|
font-size: 28rpx;
|
line-height: 1.5;
|
color: #666666;
|
background: transparent;
|
}
|
|
.charge-area {
|
min-height: 140rpx;
|
}
|
|
.divider {
|
height: 1rpx;
|
background: #f0f1f4;
|
}
|
|
.switch-group {
|
padding-bottom: 18rpx;
|
}
|
|
.switch-row {
|
margin-top: 30rpx;
|
display: flex;
|
gap: 18rpx;
|
}
|
|
.switch-pill {
|
width: 208rpx;
|
height: 72rpx;
|
border-radius: 36rpx;
|
background: #eeeeee;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-weight: 400;
|
font-size: 30rpx;
|
color: #333333;
|
}
|
|
.switch-pill.active {
|
background: #10B2FA;
|
color: #ffffff;
|
}
|
|
.input-with-unit {
|
margin-top: 14rpx;
|
display: flex;
|
align-items: center;
|
}
|
|
.input-with-unit .text-input {
|
margin-top: 0;
|
flex: 1;
|
}
|
|
.unit-text {
|
margin-left: 12rpx;
|
color: #666666;
|
flex-shrink: 0;
|
}
|
|
.save-wrap {
|
margin-top: 30rpx;
|
padding-bottom: calc(env(safe-area-inset-bottom) + 30rpx);
|
}
|
|
.save-btn {
|
height: 88rpx;
|
background: #10B2FA;
|
border-radius: 44rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-weight: 500;
|
font-size: 32rpx;
|
color: #FFFFFF;
|
}
|
</style>
|