完善企业基本信息
This commit is contained in:
@@ -10,12 +10,16 @@
|
||||
<label>企业简介</label>
|
||||
<textarea v-model="description" placeholder="输入企业简介" />
|
||||
</view>
|
||||
<view class="item info-text">
|
||||
<label>企业地址</label>
|
||||
<input v-model="address" placeholder="输入企业地址" />
|
||||
</view>
|
||||
</view>
|
||||
<block v-for="(module,index) in modules" :key="index">
|
||||
<block v-for="(module, moduleIndex) in modules" :key="moduleIndex">
|
||||
<view class="module-item" v-if="module.type === 1">
|
||||
<view class="module-title">
|
||||
<input class="title-input" type="text" v-model="module.title" placeholder="输入标题" />
|
||||
<view class="remove-btn" @click="removeModule(index)">删除</view>
|
||||
<view class="remove-btn" @click="removeModule(moduleIndex)">删除</view>
|
||||
</view>
|
||||
<view class="module-textarea">
|
||||
<textarea placeholder="输入文字内容" v-model="module.content.content" />
|
||||
@@ -24,13 +28,19 @@
|
||||
<view class="module-item" v-if="module.type === 2">
|
||||
<view class="module-title">
|
||||
<input class="title-input" type="text" v-model="module.title" placeholder="输入标题" />
|
||||
<view class="remove-btn" @click="removeModule(index)">删除</view>
|
||||
<view class="remove-btn" @click="removeModule(moduleIndex)">删除</view>
|
||||
</view>
|
||||
<view class="module-imgs">
|
||||
<view class="item" v-for="(item, index) in module.content.image.showpath" :key="index">
|
||||
<view
|
||||
class="item"
|
||||
v-for="(item, index) in module.content.image.showpath"
|
||||
:key="index"
|
||||
@click="openImg(module.content.image.showpath, index)"
|
||||
@longpress="removeImg('imgs', moduleIndex, index)"
|
||||
>
|
||||
<image class="cover" :src="item" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="item" @click="updImgs(index)">
|
||||
<view class="item" @click="updImgs(moduleIndex)">
|
||||
<view class="item-upd cover">
|
||||
<uni-icons type="plus" size="20" color="#999"/>
|
||||
<view>上传图片</view>
|
||||
@@ -42,19 +52,31 @@
|
||||
<view class="module-item" v-if="module.type === 3">
|
||||
<view class="module-title">
|
||||
<input class="title-input" type="text" v-model="module.title" placeholder="输入标题" />
|
||||
<view class="remove-btn" @click="removeModule(index)">删除</view>
|
||||
<view class="remove-btn" @click="removeModule(moduleIndex)">删除</view>
|
||||
</view>
|
||||
<view class="module-videos">
|
||||
<view class="item">
|
||||
<image class="cover" v-if="module.content.video_image.showpath != ''" :src="module.content.video_image.showpath" mode="aspectFill" />
|
||||
<view class="item-upd" @click="updImg('videoCover', index)" v-else>
|
||||
<image
|
||||
class="cover"
|
||||
v-if="module.content.video_image.showpath != ''"
|
||||
:src="module.content.video_image.showpath"
|
||||
mode="aspectFill"
|
||||
@click="openImg([module.content.video_image.showpath], 0)"
|
||||
@longpress="removeImg('videoCover', moduleIndex, '')"
|
||||
/>
|
||||
<view class="item-upd" @click="updImg('videoCover', moduleIndex)" v-else>
|
||||
<uni-icons type="plus" size="20" color="#999"/>
|
||||
<view>上传视频封面</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<video class="cover" v-if="module.content.video_url.showpath != ''" :src="module.content.video_url.showpath" />
|
||||
<view class="item-upd" @click="updImg('video', index)" v-else>
|
||||
<video
|
||||
class="cover"
|
||||
v-if="module.content.video_url.showpath != ''"
|
||||
:src="module.content.video_url.showpath"
|
||||
@longpress="removeImg('video', moduleIndex, '')"
|
||||
/>
|
||||
<view class="item-upd" @click="updImg('video', moduleIndex)" v-else>
|
||||
<uni-icons type="plus" size="20" color="#999"/>
|
||||
<view>上传视频</view>
|
||||
</view>
|
||||
@@ -77,6 +99,7 @@
|
||||
return {
|
||||
logo : '',
|
||||
description : '',
|
||||
address : '',
|
||||
modules : [],
|
||||
modulesType : []
|
||||
};
|
||||
@@ -87,6 +110,7 @@
|
||||
this.logo = info.base.cover
|
||||
this.description = info.base.description
|
||||
this.modules = info.extends
|
||||
this.address = info.info.address
|
||||
this.modulesType = res[1]
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
@@ -96,9 +120,37 @@
|
||||
})
|
||||
},
|
||||
methods:{
|
||||
// 图片预览
|
||||
openImg(paths, index){
|
||||
|
||||
console.log(paths)
|
||||
console.log(index)
|
||||
|
||||
uni.previewImage({
|
||||
urls : paths,
|
||||
current : index,
|
||||
indicator: 'number'
|
||||
})
|
||||
},
|
||||
// 删除图片
|
||||
removeImg(type, moduleIndex, index){
|
||||
let modulesObj = this.modules[moduleIndex]
|
||||
if(type === 'videoCover'){
|
||||
modulesObj.content.video_image.showpath = ''
|
||||
modulesObj.content.video_image.path = ''
|
||||
}
|
||||
if(type === 'imgs'){
|
||||
modulesObj.content.image.showpath.splice(index, 1)
|
||||
modulesObj.content.image.path.splice(index, 1)
|
||||
}
|
||||
if(type === 'video'){
|
||||
modulesObj.content.video_url.showpath = ''
|
||||
modulesObj.content.video_url.path = ''
|
||||
}
|
||||
this.$set(this.modules, moduleIndex, modulesObj)
|
||||
},
|
||||
// 单图上传
|
||||
updImg(type, index){
|
||||
console.log(index)
|
||||
switch(type){
|
||||
case 'logo':
|
||||
uni.chooseImage({
|
||||
@@ -119,7 +171,6 @@
|
||||
})
|
||||
break
|
||||
case 'videoCover':
|
||||
console.log('封面')
|
||||
uni.chooseImage({
|
||||
crop: {width: 500, height: 350},
|
||||
success: path=> {
|
||||
@@ -128,10 +179,8 @@
|
||||
uri : path.tempFilePaths[0]
|
||||
}]).then(res => {
|
||||
let modulesObj = this.modules[index]
|
||||
|
||||
modulesObj.content.video_image.showpath = [...modulesObj.content.video_image.showpath, ...res.url]
|
||||
modulesObj.content.video_image.path = [...modulesObj.content.video_image.path, ...res.path]
|
||||
|
||||
modulesObj.content.video_image.showpath = res.url[0]
|
||||
modulesObj.content.video_image.path = res.path[0]
|
||||
this.$set(this.modules, index, modulesObj)
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
@@ -145,10 +194,22 @@
|
||||
case 'video':
|
||||
uni.chooseVideo({
|
||||
success: path=> {
|
||||
console.log(path)
|
||||
uploads([{
|
||||
name: 'video',
|
||||
uri : path.tempFilePath
|
||||
}]).then(res => {
|
||||
let modulesObj = this.modules[index]
|
||||
modulesObj.content.video_url.showpath = res.url[0]
|
||||
modulesObj.content.video_url.path = res.path[0]
|
||||
this.$set(this.modules, index, modulesObj)
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
console.log('上传视频')
|
||||
break
|
||||
}
|
||||
},
|
||||
@@ -232,7 +293,28 @@
|
||||
|
||||
// 保存基础信息
|
||||
onNavigationBarButtonTap(e){
|
||||
console.log(this.modules)
|
||||
basicsInfo('PUT', {
|
||||
cover : this.logo,
|
||||
description : this.description,
|
||||
address : this.address,
|
||||
extends : this.modules
|
||||
}).then(res => {
|
||||
uni.showModal({
|
||||
title : '提示',
|
||||
content : '基本信息已保存',
|
||||
showCancel : false,
|
||||
success : modalRes=> {
|
||||
if(modalRes.confirm){
|
||||
this.$Router.back()
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,6 +376,10 @@
|
||||
width: 100%;
|
||||
height: 160rpx;
|
||||
}
|
||||
input{
|
||||
height: 40rpx;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 模块
|
||||
|
||||
Reference in New Issue
Block a user