|
|
<template> <view class="pageBgImg"> <topNavbar title="我要咨询"></topNavbar> <view class="pad"> <view class="card"> <view class="h2">咨询内容</view> <view class="textareaBg"> <view class="flex"> <view class="icon"> <image src="@/static/images/index/edit.png" mode=""></image> </view> <view class="inputBox"> <u-textarea v-model.trim="value" ref="textarea" placeholder="详细说明问题,以便获得更好的回答~"></u-textarea> </view> </view> <view class="phoneBox"> <view class="imgBox"> <view class="img" v-for="(item,index) in imgArr" :key="item"> <view class="minusCircle" @click="deleteImg(item,index)"> <u-icon name="close-circle-fill" size="20" color="#b9061d"></u-icon> </view> <image :src="item" mode=""></image> </view> </view> <view class="phone" @click="chooseImages" v-if="imgArr.length<3"> <view class="phoneIcon"> <image src="@/static/images/index/btn_tupian.png" mode=""></image> </view> <view class="lab">添加图片</view> </view> </view> </view> </view> <view class="card" style="padding-bottom: 0; margin-top: 24rpx;"> <view class="phone_row"> <view class="label">联系电话</view> <view class="uInput my">{{ this.vuex_userInfo.phone }}</view> </view> </view> <view class="btn" :class="{active: value.length}" @click="submintFn">提交</view> </view> </view> </template>
<script>
import { createconsult } from '@/config/api.js' import { uploadImgApi } from '@/config/utils.js' // let url = 'api'
export default { data() { return { value: '', imgArr: [], } }, onLoad() { }, methods: { async submintFn() { let images = this.imgArr.join(',') if(!this.value.trim()) return this.$u.toast('请输入内容') let obj = { images, studentPhone: this.vuex_userInfo.phone, type: 1, studentId: this.studentId, content: this.value } const {data: res} = await createconsult(obj) this.$u.toast('发布成功') this.value = '' this.imgArr = [] setTimeout(()=>{ this.$goPage('/pages/indexEntry/consult/record/record?tab=1') },1500) }, deleteImg(item) { let index = this.imgArr.findIndex(val=>val==item) this.imgArr.splice(index, 1) }, //选择图片
chooseImages(type) { let imgNum = 3 - (this.imgArr.length) uni.chooseImage({ count: imgNum, //允许选择的数量
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], //从相册选择
success: res => { uni.showLoading({ title: '图片上传中...' }); console.log(res) console.log('图片信息') res.tempFiles.forEach(async (item,index)=>{ // 用索引做名字吧,小程序里获取不到文件名
const imgLink = await uploadImgApi(item.path, index) this.imgArr.push(imgLink) }) } }) }, } } </script>
<style lang="scss" scoped> .pageBgImg { .pad {} .card { padding: 0 24rpx 24rpx 24rpx ; .h2 { font-size: 32rpx; font-weight: 600; line-height: 96rpx; }
.textareaBg { min-height: 364rpx; background: #F8F8F8; border-radius: 16rpx; border: 2rpx solid #E8E9EC; display: flex; flex-direction: column; justify-content: space-between; .flex { padding: 20rpx; align-items: flex-start; .icon { width: 24rpx; height: 24rpx; margin: 0 14rpx 0 24rpx; }
.inputBox { flex: 1;
} /deep/ .inputBox .u-textarea { padding: 0 !important; border: none !important; background: none !important; font-size: 24rpx } }
.phoneBox { display: flex; padding: 0 10rpx 20rpx 20rpx; .imgBox { display: flex; .img { margin-right: 14rpx; position: relative; image { width: 160rpx; height: 160rpx; border-radius: 8rpx; overflow: hidden; } .minusCircle { position: absolute; right: -14rpx; top: -20rpx; z-index: 9;
} } }
.phone { border: 2rpx dashed #CDCED0; width: 160rpx; height: 160rpx; background: #F8F8F8; border-radius: 8rpx; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-direction: column; .phoneIcon { width: 60rpx; height: 60rpx; }
.lab { font-size: 20rpx; color: #686B73; margin-top: 8rpx; } } } } } .phone_row { display: flex; height: 104rpx; padding: 0 28rpx; line-height: 104rpx; .label { font-size: 32rpx; font-weight: 600; margin-right: 50rpx; } .uInput { flex: 1; } } .btn { width: 396rpx; height: 72rpx; background: #D1E7FE; border-radius: 8rpx; font-size: 28rpx; text-align: center; line-height: 72rpx; margin: 100rpx auto 114rpx auto; color: #fff; &.active { background: $themC; } } } </style>
|