deming/pageE/tool/washComment.vue

123 lines
2.6 KiB
Vue
Raw Normal View History

2020-07-29 11:01:10 +00:00
<template>
<view class="comment">
<view class="main-container">
<u-input v-model="content" type="textarea" height="300" maxlength="200" />
2020-09-05 06:26:17 +00:00
<u-upload
2020-07-29 11:01:10 +00:00
ref="uUpload"
:custom-btn="true"
:max-count="count"
:auto-upload="false"
2020-09-05 06:26:17 +00:00
:action="action"
:header="header"
:form-data="formData"
:name="fileName"
:size-type="['original']"
@on-uploaded="setImageList"
2020-07-29 11:01:10 +00:00
>
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
<image src="../static/mine/27.png"></image>
</view>
2020-09-05 06:26:17 +00:00
</u-upload>
2020-07-29 11:01:10 +00:00
</view>
<u-toast ref="uToast" />
2020-09-05 06:26:17 +00:00
<view class="write-btn" @click="setLoaclList">发表评价</view>
2020-07-29 11:01:10 +00:00
</view>
</template>
<script>
export default {
data() {
return {
washId: '',
2020-09-05 06:26:17 +00:00
count: 1,
action: this.$u.http.config.baseUrl + '/Upload/uploadfile',
header: {
"authorization": 'Bearer' + " " + uni.getStorageSync('token')
},
fileName: 'common', // 与formData name 一样
formData: {
name: 'common', // 其他图片
},
2020-07-29 11:01:10 +00:00
content: '',
2020-09-05 06:26:17 +00:00
imageList: [],
2020-07-29 11:01:10 +00:00
}
},
onLoad(option) {
this.washId = option.id;
},
methods: {
verifyParams() {
if(this.$u.test.isEmpty(this.content)) {
this.$u.toast('内容不可为空');
return false;
}
return true;
},
2020-09-05 06:26:17 +00:00
setLoaclList() {
this.$refs.uUpload.upload();
},
setImageList(lists) {
// console.log(lists);
lists.forEach(item => {
this.imageList.push(item.response.data.file_name);
})
this.addWashEvaluate();
},
2020-07-29 11:01:10 +00:00
addWashEvaluate() {
if(!this.verifyParams()) return false;
this.$u.api.sendOrderComment({
id: this.washId,
comment: this.content,
2020-09-05 06:26:17 +00:00
comment_img: this.imageList[0]
2020-07-29 11:01:10 +00:00
}).then(res => {
this.$refs.uToast.show({
title: res.message,
back: true,
})
})
},
bindTextAreaBlur(event) {
this.content = event.detail.value;
}
},
};
</script>
<style lang="scss" scoped>
.comment {
min-height: calc(100vh - var(--window-top));
background-color: #ECECEC;
border-top: 1rpx solid #ffffff;
.main-container {
background-color: #ffffff;
padding: 30rpx;
margin-bottom: 10rpx;
2020-09-05 06:26:17 +00:00
textarea {
width: 100% !important;
height: 500rpx;
margin-bottom: 60rpx;
}
.slot-btn {
width: 140rpx;
height: 140rpx;
background: rgba(236,236,236,1);
border-radius: 10rpx;
text-align: center;
> image {
margin-top: 48rpx;
width: 54rpx;
height: 49rpx;
}
}
2020-07-29 11:01:10 +00:00
}
.write-btn {
margin: 120rpx auto 0;
width: 690rpx;
height: 98rpx;
background: rgba(255,120,15,1);
border-radius: 46rpx;
font-size: 36rpx;
color: rgba(255,255,255,1);
text-align: center;
line-height: 98rpx;
}
}
</style>