Files
xdd-uniapp-new/pagesInn/inn/innProfileEdit.vue
T
2023-09-20 21:49:33 +08:00

434 lines
11 KiB
Vue

<template>
<view class="container">
<view class="base-info-section" style="margin-bottom: 86rpx;margin-bottom: 86rpx;">
<!-- <text class="section-title">详细信息</text> -->
<view class="item is_required" @click="chooseLogoImg()">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">店铺LOGO</view>
<view class="">
<image style="width: 64rpx;height: 64rpx;"
:src="innApplyInfo.logo.length>0?innApplyInfo.logo:webUrl+'/20210228103411271415.png'"
mode=""></image>
</view>
</view>
<text class="iconfont icon-jiantou"></text>
</view>
<view class="item is_required">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">店铺类型</view>
<view class="cell-value">
<picker :value="typeIndex" @change="typePickerChange" :range="typeRange">
<view style="text-align: right;font-size:24rpx;color:#C2C5CC;" v-if="typeList.length>0">
{{ typeList[typeIndex].name }}
</view>
<view style="text-align: right;font-size:24rpx;color:#C2C5CC;" v-else>请选择店铺类型</view>
</picker>
</view>
</view>
<text class="iconfont icon-jiantou"></text>
</view>
<view class="item is_required" @click="chooseCoverImg()">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">封面照片</view>
<view class="">
<image style="width: 64rpx;height: 64rpx;"
:src="innApplyInfo.cover.length>0?innApplyInfo.cover:webUrl+'/20210228103411271415.png'"
mode=""></image>
</view>
</view>
<text class="iconfont icon-jiantou"></text>
</view>
<view class="item" @click="chooseQrcodeImg()">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">微信二维码</view>
<view class="">
<image style="width: 64rpx;height: 64rpx;"
:src="innApplyInfo.qrcode.length>0?innApplyInfo.qrcode:webUrl+'/20210228103411271415.png'"
mode=""></image>
</view>
</view>
<text class="iconfont icon-jiantou"></text>
</view>
<view class="item is_required">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">店主名字</view>
<view class="cell-value" style="text-align: right;">
<input type="text" v-model="innApplyInfo.ownerName" placeholder="请输入店主名字"
placeholder-style="font-size:24rpx;color:#C2C5CC;"/>
</view>
</view>
</view>
<!-- <view class="item is_required">-->
<!-- <view class="cell acea-row row-between row-middle">-->
<!-- <view class="cell-title">关键词</view>-->
<!-- <view class="cell-value" style="text-align: right;">-->
<!-- <input type="text" v-model="innApplyInfo.tips" placeholder="店主想对游客说的话" placeholder-style="font-size:24rpx;color:#C2C5CC;" />-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<view class="item is_required">
<view class="cell acea-row row-between row-middle">
<view class="cell-title">一句话介绍</view>
<view class="cell-value" style="text-align: right;">
<input type="text" v-model="innApplyInfo.content" placeholder="店铺风格一句话描述"
placeholder-style="font-size:24rpx;color:#C2C5CC;"/>
</view>
</view>
</view>
<view class="item is_required">
<view class="cell acea-row row-column">
<view class="cell-title">店铺简介</view>
<view class="">
<textarea style="height: 200rpx;color:#C2C5CC;" v-model="innApplyInfo.desc" placeholder="请输入店铺简介..."
placeholder-style="font-size:24rpx;color:#C2C5CC;"/>
</view>
</view>
</view>
<view class="item">
<view class="img-upload">
<tm-upload
:dataList="picsArray"
:upload_img_wh="uploadImgWH"
:upload_max="uploadMax"
:url="uploadUrl"
:header="uploadHeader"
@change="uploadedImgChange"/>
</view>
</view>
</view>
<view class="submit-btn" @tap="submit">确定修改</view>
</view>
</template>
<script>
import CitySelect from "@/components/CitySelect";
import tmUpload from '@/pagesInn/components/tm-upload/tm-upload.vue';
import {chooseImage} from "@/utils";
import {VUE_APP_API_URL} from "@/config"
import {getHotelTypeList, postHotelInfoEdit} from "@/api/inn.js";
var that;
export default {
components: {
CitySelect,
tmUpload
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
uploadUrl: VUE_APP_API_URL + '/api/upload',
uploadImgWH: (750 - 3 * 16 - 2 * 32) / 3.0,
uploadHeader: {
Authorization: "Bearer " + this.$store.getters.token
},
innHistory: {},//历史信息
picsArray: [],
typeList: [],//类型列表
typeIndex: 0,//选中的类型
typeRange: [],//类型数据源
uploadedFilesArray: [],
uploadMax: 10,
innApplyInfo: {
"address": "",
"areaId": 0,
"cityId": 0,
"provinceId": 0,
"content": "",
"cover": "",
"desc": "",
"logo": "",
"name": "",
"ownerName": "",
"pics": [],
"position": "",
"tel": "",
"qrcode": "",
"tips": "",
"type": "",
}
}
},
onShow: function () {
this.getHotelType();
},
onLoad: function (e) {
that = this;
if (e.hotel) {
//赋值
var hotel = JSON.parse(decodeURIComponent(e.hotel));
this.innHistory = hotel;
this.fillData(this.innApplyInfo, this.innHistory);
//Object.assign(this.innApplyInfo,hotel);
//this.addressText = this.innHistory.provinceName+" "+this.innHistory.cityName+" "+this.innHistory.areaName;
//图片填充
this.picsArray = hotel.pics.map(function (item) {
var obj = {
path: item,
upload_percent: 100
}
return obj;
});
}
},
methods: {
typePickerChange: function (e) {
this.typeIndex = e.target.value;
//修改type
if (this.typeList.length > 0) {
this.$set(this.innApplyInfo, 'type', this.typeList[this.typeIndex].id);
}
},
getHotelType: function () {
getHotelTypeList().then((res) => {
that.typeList = res.data;
//构建数据源
that.typeRange = [];
that.typeList.forEach((item, index) => {
that.typeRange.push(item.name);
});
//重新填写模式预填充type
let len = this.typeList.length;
if (len > 0) {
for (let i = 0; i < len; i++) {
if (this.typeList[i].id === this.innHistory.type) this.typeIndex = i;
}
}
}).catch((err) => {
}).finally(() => {
})
},
fillData: function (target, source) {
//var keys = Object.keys(target);
//this.uploadedFilesArray = source.pics;
Object.keys(target).forEach((value, key) => {
target[value] = source[value];
// console.log('key:'+value);
});
},
//文件上传结果
uploadedImgChange: function (uploadedFilesList) {
this.uploadedFilesArray = uploadedFilesList;
},
chooseQrcodeImg: function () {
chooseImage(img => {
that.$set(that.innApplyInfo, 'qrcode', img);
});
},
chooseLogoImg: function () {
chooseImage(img => {
that.innApplyInfo.logo = img;
});
},
chooseCoverImg: function () {
chooseImage(img => {
that.innApplyInfo.cover = img;
});
},
// successImage(e){
// uni.showModal({
// content : '上传成功,详细信息请看控制台'
// })
// },
// successvideo(e){
// },
submit: function () {
if (this.innApplyInfo.logo.length == 0) {
this.$dialog.error("请上传店铺LOGO图片");
return;
}
if (this.innApplyInfo.cover.length == 0) {
this.$dialog.error("请上传店铺封面图片");
return;
}
if (this.innApplyInfo.ownerName.length == 0) {
this.$dialog.error("请输入店主名字");
return;
}
// if (this.innApplyInfo.tips.length == 0) {
// this.$dialog.error("请输入关键词");
// return;
// }
if (this.innApplyInfo.content.length == 0) {
this.$dialog.error("请输入一句话介绍");
return;
}
if (this.innApplyInfo.desc.length == 0) {
this.$dialog.error("请输入店铺简介");
return;
}
if (this.uploadedFilesArray.length == 0) {
this.$dialog.error("请上传至少一张店铺图片");
return;
}
var param = {};
//深拷贝
param = JSON.parse(JSON.stringify(this.innApplyInfo));
if (this.uploadedFilesArray.length > 0) {
param.pics = this.uploadedFilesArray.join(',');
}
param.id = this.innHistory.id;
uni.showLoading();
postHotelInfoEdit(param).then((res) => {
uni.hideLoading()
uni.showToast({
title: '修改成功!',
mask: false,
duration: 1500
});
setTimeout(function () {
that.$yrouter.back();
}, 1000);
}).catch((err) => {
uni.hideLoading()
uni.showToast({
title: err.msg + '',
icon: 'none',
mask: false,
duration: 1500
});
}).finally(() => {
})
}
}
}
</script>
<style scoped lang="less">
.base-info-section {
padding: 32rpx;
background: #FFFFFF;
}
.base-info-section .section-title {
font-size: 28rpx;
font-family: Source Han Sans SC;
font-weight: 500;
color: #080F1A;
}
.base-info-section .item {
width: 100%;
text-align: left;
font-size: 26rpx;
color: #333;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
padding: 20rpx 0rpx;
position: relative;
}
.base-info-section .item .iconfont {
font-size: 26rpx;
color: #666;
}
.base-info-section .item::after {
content: "";
display: block;
position: absolute;
left: 0rpx;
right: 0;
bottom: 0;
border-bottom: 1rpx solid #f5f5f5;
z-index: 1;
height: 1rpx;
}
.base-info-section .item .pictrue {
width: 36rpx;
height: 36rpx;
margin-right: 16rpx;
}
.base-info-section .item .cell {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
}
.base-info-section .item .cell input {
text-align: right;
color: #C2C5CC;
}
.base-info-section .item .pictrue image {
width: 100%;
height: 100%;
}
.base-info-section .item.is_required .cell .cell-title {
flex-shrink: 0;
margin-right: 10rpx;
}
.base-info-section .item.is_required .cell .cell-value {
flex-grow: 1;
}
.base-info-section .item.is_required .cell .cell-title::before {
content: "*";
color: #ff4949;
margin-right: 4rpx;
}
.submit-btn {
height: 86rpx;
text-align: center;
line-height: 86rpx;
// margin: 50rpx auto 30rpx auto;
font-size: 32rpx;
color: #fff;
background: #0DC5C5;
position: fixed;
left: 0;
right: 0;
z-index: 2;
bottom: 0;
}
</style>