152 lines
3.0 KiB
Vue
152 lines
3.0 KiB
Vue
|
<template>
|
|||
|
<view class="content">
|
|||
|
<view class="container">
|
|||
|
<view class="input-box">
|
|||
|
<view style=" margin-right: 10px; ">标题:</view>
|
|||
|
<input type="text" placeholder="请输入" v-model="title" />
|
|||
|
</view>
|
|||
|
|
|||
|
|
|||
|
<u--textarea v-model="content" height="110px" placeholder="请输入具体内容" maxlength="-1"
|
|||
|
border="bottom"></u--textarea>
|
|||
|
<view class="input-box"><u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1"
|
|||
|
multiple :previewFullImage="true" :maxCount="3"></u-upload></view>
|
|||
|
|
|||
|
|
|||
|
<view class="anniu" @click="tomato()">提交</view>
|
|||
|
</view>
|
|||
|
|
|||
|
</view>
|
|||
|
</template>
|
|||
|
|
|||
|
<script>
|
|||
|
import upload from '@/utils/upload.js'
|
|||
|
import request from '../../utils/request';
|
|||
|
|
|||
|
export default {
|
|||
|
data() {
|
|||
|
return {
|
|||
|
title: '',
|
|||
|
content: '',
|
|||
|
fileList1: [],
|
|||
|
photo: '',
|
|||
|
type: 2
|
|||
|
}
|
|||
|
},
|
|||
|
onShow() {
|
|||
|
|
|||
|
},
|
|||
|
onPullDownRefresh() {
|
|||
|
console.log("刷新");
|
|||
|
uni.stopPullDownRefresh()
|
|||
|
},
|
|||
|
onReachBottom() {
|
|||
|
// this.show = true
|
|||
|
setTimeout(() => {
|
|||
|
console.log("加载执行");
|
|||
|
}, 2000)
|
|||
|
},
|
|||
|
|
|||
|
methods: {
|
|||
|
async tomato() {
|
|||
|
let res = await request({
|
|||
|
url: '/drivingSchool/system/dial/',
|
|||
|
method: 'post',
|
|||
|
data: {
|
|||
|
title: this.title,
|
|||
|
content: this.content,
|
|||
|
photo: this.photo,
|
|||
|
type: this.type
|
|||
|
}
|
|||
|
})
|
|||
|
console.log(res);
|
|||
|
if (res.code == 200) {
|
|||
|
uni.showToast({
|
|||
|
title: '提交成功'
|
|||
|
})
|
|||
|
uni.navigateBack()
|
|||
|
}
|
|||
|
},
|
|||
|
deletePic(event) {
|
|||
|
this[`fileList${event.name}`].splice(event.index, 1)
|
|||
|
|
|||
|
|
|||
|
},
|
|||
|
// 新增图片
|
|||
|
async afterRead(event) {
|
|||
|
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
|||
|
let lists = [].concat(event.file)
|
|||
|
let fileListLen = this[`fileList${event.name}`].length
|
|||
|
lists.map((item) => {
|
|||
|
this[`fileList${event.name}`].push({
|
|||
|
...item,
|
|||
|
|
|||
|
})
|
|||
|
})
|
|||
|
for (let i = 0; i < lists.length; i++) {
|
|||
|
const result = await this.uploadFilePromise(lists[i].url)
|
|||
|
let item = this[`fileList${event.name}`][fileListLen]
|
|||
|
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
|
|||
|
status: 'success',
|
|||
|
message: '',
|
|||
|
url: result
|
|||
|
}))
|
|||
|
fileListLen++
|
|||
|
}
|
|||
|
},
|
|||
|
uploadFilePromise(e) {
|
|||
|
console.log(e);
|
|||
|
upload({
|
|||
|
url: '/common/upload',
|
|||
|
filePath: e,
|
|||
|
}).then((res) => {
|
|||
|
this.photo = res.fileName
|
|||
|
console.log(this.photo);
|
|||
|
|
|||
|
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
goback() {
|
|||
|
uni.navigateBack()
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<style scoped lang="scss">
|
|||
|
.content {
|
|||
|
width: 100%;
|
|||
|
// background: linear-gradient(180deg, #4AA76F 0%, #4AA76F 20%, #f7f7f7 38%, #f7f7f7 100%);
|
|||
|
background: #f4f5f6;
|
|||
|
height: 100vh;
|
|||
|
}
|
|||
|
|
|||
|
.container {
|
|||
|
width: 100%;
|
|||
|
background: #f4f5f6;
|
|||
|
box-sizing: border-box;
|
|||
|
// padding-top: 88px;
|
|||
|
}
|
|||
|
|
|||
|
.input-box {
|
|||
|
width: 100%;
|
|||
|
background: #fff;
|
|||
|
display: flex;
|
|||
|
align-items: center;
|
|||
|
box-sizing: border-box;
|
|||
|
padding: 15px;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
.anniu {
|
|||
|
width: 80%;
|
|||
|
height: 40px;
|
|||
|
margin: 15px auto;
|
|||
|
display: flex;
|
|||
|
align-items: center;
|
|||
|
justify-content: center;
|
|||
|
color: #fff;
|
|||
|
background: #4AA76F;
|
|||
|
}
|
|||
|
</style>
|