<template>
	<view class="main">
		<view class="padding-lr">
			<view v-for="(item,index) in messageList" @click="gotoliaotian(item)" :key="index" class="padding-lr-sm padding-tb-sm bg-white margin-top-sm"
			 style="border-radius: 16rpx;box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);">
				<view class="flex justify-start align-center">
					<u-icon name="order"></u-icon>
					<text class="text-lg margin-left-xs">{{
						item.type==1?'医生确认接单':item.type==2?'医生确认结束':item.type==3?'系统通知':item.type==4?'下单成功':item.type==5?'服务包下单成功':item.type==6?'服务包到期':item.type==7?'充值成功':item.type==8?'余额付款成功':item.type==9?'修改密码':item.type==10?'修改绑定电话':item.type==11?'修改支付密码':item.type==12?'社区端通知':item.type==13?'后台通知':'订单通知'
						
					}}</text>
					<text class="flex-sub text-right">{{item.create_time}}</text>
				</view>
				<view class="margin-top-sm text-cut">
					{{item.content}}
				</view>
				<view class="text-right" style="position: relative">
					<!-- <u-badge size="mini" :absolute="false" type="error" v-if="item.status==1" :is-dot="true"></u-badge>
					<text class="margin-left-xs" v-if="item.status==1">未读</text>
					<text class="margin-left-xs" v-if="item.status==2">已读</text> -->
				</view>
			</view>
		</view>
		<u-empty text="暂无数据" mode="order" :show="show" margin-top="250"></u-empty>
		<view class="cu-tabbar-height"></view>
		<view class="cu-tabbar-height"></view>
		<u-no-network></u-no-network>
	</view>
</template>

<script>
	export default {
		onLoad(options) {

		},
		mounted() {
			this.getMessage()
		},
		data() {
			return {
				messageList: [],
				pageindex: 1,
				show: false
			}
		},
		onReachBottom() {
			this.getMessage()
		},
		methods: {
			getMessage: async function() {
				let res = await this.$request.post("/api/v1/user/userMessageList", {
					page: this.pageindex
				})
				console.log(res)
				if (res.status == 0) {
					if (this.pageindex > res.data.last_page) {
						uni.showToast({
							title: "没有更多了",
							icon: "none"
						})
					} else {
						this.messageList = this.messageList.concat(res.data.data)
						this.pageindex++
					}
				}
				if (this.messageList.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			},
			gotoliaotian(item) {
				if (item.type == 1 || item.type == 4) {
					uni.navigateTo({
						url: "../common_tools/my_consulting/consultingInfo?id=" + item.relation_id
					})
				}//else if(){
					
				//}
			}
		}
	};
</script>

<style scoped lang="scss">
	.main {}
</style>
