审查视图

pages/order/evaluate.vue 5.6 KB
1  
倪静楠 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
<template>
	<view class="content">
		<view class="" v-if="suessShow">
			<view class="fabBtn">
				<view class="btn">
					<image src="../../static/ic_41@2x.png" mode="" @click="submit"></image>
				</view>
			</view>
			<view class="goodBox">
				<view class="leftImg">
					<image src="../../static/ic_21@2x.png" mode=""></image>
				</view>
				<view class="nameBox">
					科麦斯无油静音空吗压力小型气550W-8L便捷吹尘木工打钉枪气泵空气压缩机
				</view>
			</view>
			<view class="evaluateBox">
				<view class="textBox">
					<view class="textrLeft">
						<image src="../../static/ic_42@2x.png" mode="" class="editIcon"></image>
					</view>
					<view class="textRight">
						<textarea value="" placeholder="从多个角度评价宝贝,可以帮助更多想买的人" confirm-type="done" maxlength="-1"
							@input="bindInput" />
					</view>
				</view>
				<view class="imgBox">
					<image src="../../static/ic_43@2x.png" mode=""
						style="width: 160rpx;height: 160rpx;margin-right: 10rpx;" @click="uploadImg"></image>
					<view class="uploadImg" v-for="(item,idnex) in fileList" :key="index">
						<image :src="item" mode=""></image>
						<image src="../../static/ic_19@2x.png" mode="" class="delicon" @click="deleteImg(index)">
						</image>
					</view>
				</view>
			</view>
		</view>
		<view class="noData" v-else>
			<image src="../../static/ic_44@2x.png" mode="" style="width: 320rpx;height: 320rpx;"></image>
			<view class="fabuText">
				发布成功
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				inputValue: '', //内容输入框
				suessShow: true, //是否成功
				fileList: [],
				urlImg: [],
				tempFilePaths: [],
				btnClick: true
			}
		},
		methods: {
			bindInput(e) {
				this.inputValue = e.detail.value
			},
			submit() {
				uni.showModal({
					title: '提示',
					content: '确定发布吗?',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			uploadImg() {
				let that = this
				that.tempFilePaths = []
				uni.chooseImage({
					count: 6,
					success: (chooseImageRes) => {
						let list = chooseImageRes.tempFilePaths
						list.forEach((item, index) => {
							that.tempFilePaths.push(item);
						})
						let lists = that.tempFilePaths
						lists.forEach(ele => {
							const uploadTask = uni.uploadFile({
								url: 'https://ketao.shequtaoapp.com/api/common/upload',
								filePath: ele,
								fileType: 'image',
								name: 'file',
								formData: {
									'user': 'test'
								},
								header: {
									'token': uni.getStorageSync('token') || ''
								},
								success: (uploadFileRes) => {
									let uploadList = JSON.parse(uploadFileRes.data).data
									that.fileList.push(uploadList.url)
									that.urlImg.push(uploadList.save_path)
								}
							});
						})

					}
				});
			},
			//删除图片
			deleteImg(idx) {
				this.fileList.splice(idx, 1);
				this.urlImg.splice(idx, 1);
				this.tempFilePaths.splice(idx, 1);
			},
			//发布
			submit() {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定发布吗?',
					success: function(res) {
						if (res.confirm) {
							let postData = {
								content: this.inputValue,
								images: this.fileList.toString(),
								id: '', //商品id
								order_item_id: '', //订单商品id
								level: '', //评星
							}
							if (that.btnClick) {
								that.btnClick=false
								request.post('/api/order/comment', postData).then(res => {
									if (res.code == 1) {
										uni.navigateBack({
											delta: 1
										})
										uni.showToast({
											title: '发布成功'
										})
									} else {
										uni.showToast({
											title: res.msg,
											icon: 'none'
										})
									}
								}).catch(err => {

								})
							}

						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
		background-color: #F7F8FA;
		box-sizing: border-box;
	}

	.fabBtn {
		padding: 16rpx 32rpx;
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		justify-content: flex-end;
		border-bottom: 2rpx solid #F7F8FA
	}

	.btn image {
		width: 114rpx;
		height: 52rpx;
	}

	.goodBox {
		background-color: #fff;
		padding: 32rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		border-bottom: 2rpx solid #F7F8FA
	}

	.leftImg {
		width: 136rpx;
		height: 136rpx;
		margin-right: 32rpx;
	}

	.leftImg image {
		width: 100%;
		height: 100%;
		border-radius: 8rpx;
	}

	.nameBox {
		flex: 1;
		color: #323233;
		font-size: 26rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.evaluateBox {
		background-color: #fff;
		padding: 32rpx;
		box-sizing: border-box;
	}

	.textBox {
		display: flex;
		justify-content: space-around;
	}

	.editIcon {
		width: 32rpx;
		height: 32rpx;
	}

	.uploadImg {
		width: 160rpx;
		height: 160rpx;
		margin-right: 10rpx;
		margin-bottom: 10rpx;
		position: relative;
	}

	.imgBox {
		display: flex;
		flex-wrap: wrap;
	}

	.uploadImg image {
		width: 100%;
		height: 100%;
	}

	.delicon {
		position: absolute;
		top: 0;
		right: 0;
		width: 40rpx !important;
		height: 40rpx !important;
		background-color: #fff;
	}

	.fabuText {
		color: #323233;
		font-size: 36rpx;
		text-align: center;
		font-weight: 600;
	}

	.noData {
		width: 320rpx;
		height: 380rpx;
		padding-top: 230rpx;
		margin: 0 auto;
	}
</style>