<template>
	<view class="main">
		<view class="padding-lr">
			<view v-for="(item,index) in messageList" @click="gotoliaotian" :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}}</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
			}
		},
		methods: {
			getMessage: async function() {
				let res = await this.$request.post("/api/v1/user/userMessageList", {
					page: this.pageindex
				})
				console.log(res)
				if (res.status == 0) {
					this.messageList = res.data.data
					if (this.messageList.length == 0) {
						this.show = true
					} else {
						this.show = false
					}
				}
			},
			gotoliaotian(e){
				uni.navigateTo({
					url:"../common_tools/my_consulting/conversation"
				})
			}
		}
	};
</script>

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