<template>
	<view class="main">
		<view class="opinionList" v-for="(item,index) in opinion" :key="index" :data-id="item.id" @click="gotoinfo">
			<view class="margin-top-sm margin-lr-sm">
				<view class="flex align-center justify-between">
					<text>医生：{{item.order.docter.name}}</text>
					<view class="phonezi">
						意见单
					</view>
				</view>
				<view class="text-df margin-top-sm" style="color: rgb(102,102,102);">
					咨询类型：<text style="color: rgb(51,51,51);">{{item.order.product_type==1?'电话咨询':'图文咨询'}}</text>
				</view>
				<view class="text-df margin-top-sm" style="color: rgb(102,102,102);">
					订单号：<text style="color: rgb(51,51,51);">{{item.order.order_sn}}</text>
				</view>
				<view class="text-df margin-top-sm" style="color: rgb(102,102,102);">
					填写时间：<text style="color: rgb(51,51,51);">{{item.created_at}}</text>
				</view>
			</view>
		</view>
		<u-empty text="暂无数据" :show="show" mode="order" margin-top="250"></u-empty>
		<view class="cu-tabbar-height"></view>
		<view class="cu-tabbar-height"></view>
	</view>
</template>

<script>
	export default {
		onLoad(op) {
			this.getopinion()
		},
		data() {
			return {
				pageindex: 1,
				opinion: [],
				show: false
			}
		},
		onReachBottom() {
			this.getopinion()
		},
		methods: {
			getopinion: async function() {
				let res = await this.$request.post("/api/v1/suggest/suggestList", {
					page: this.pageindex
				})
				console.log(res)
				if (res.status == 0) {
					if (this.pageindex > res.data.last_page) {
						uni.showToast({
							title: "没有更多了",
							icon: "none"
						})
					} else {
						this.opinion = this.opinion.concat(res.data.data)
						this.pageindex++
					}
				}
				if (this.opinion.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			},
			gotoinfo(e) {
				uni.navigateTo({
					url: "opinionInfo?id=" + e.currentTarget.dataset.id
				})
			}
		},
		onShow() {

		}
	}
</script>

<style lang="scss">
	.opinionList {
		padding-top: 40rpx;
		padding-bottom: 40rpx;
		border-radius: 16rpx;
		box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);
		margin-left: 20rpx;
		margin-right: 20rpx;
		margin-top: 15rpx;
	}

	.title_yijian {
		font-size: 20rpx;
		padding: 8rpx;
		border-radius: 20rpx;
		background-color: #0B73B9;
		color: #fff;
		width: 90rpx;
		text-align: center;
		margin-left: 20rpx;
		margin-right: 10rpx;
	}

	.phonezi {
		width: 160rpx;
		height: 54rpx;
		background: rgb(246, 246, 246);
		border-radius: 27rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
