<template>
	<view class="message-container">
		<!-- 面包屑 -->
		<custom-breadcrumb separator=">">
			<custom-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to" :switch="route.switch">
				{{route.name}}
			</custom-breadcrumb-item>
		</custom-breadcrumb>
		<!-- 面包屑 -->

		<view class="content">
			<view class="title">所有通知</view>

			<view class="message-list">
				<view class="message-item flex align-center" v-for="(item, index) in messageList" :key="index" @click="handleItemClick(item)">
					<image src="/static/images/message_case_icon.png"></image>
					<view style="margin-left: 8rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{item.messageContent}}</view>
					<view style="margin-left: 8rpx;flex: 1;text-align: start;white-space: nowrap;"
						:class="getClass(item.businessStatus)">{{item.businessStatus | status}}</view>
					<u-icon name="arrow-right" size="12px"></u-icon>
				</view>
			</view>
			<view style="width: 100%;height: 60rpx;"></view>
		</view>

	</view>
</template>

<script>
	import {
		getMessageList,
	} from '@/api/my/my.js'
	import { isWeiXin } from '@/utils/common.js'
	export default {
		data() {
			return {
				routes: [{
						to: "/pages/phone/mine/index",
						name: "个人中心",
						switch: true
					},
					{
						to: "/pages/phone/mine/message/index",
						name: "所有通知",
						switch: true
					}
				],
				messageList: [],
				isWeiXin:false
			}
		},
		filters: {
			status(type) {
				//0审核通过 1审核未通过 2已美化 3完成绑定 4解除绑定
				let tempStr = '未知'
				switch (type) {
					case '0':
						tempStr = '审核通过'
						break
					case '1':
						tempStr = '审核未通过'
						break
					case '2':
						tempStr = '已美化'
						break
					case '3':
						tempStr = '完成绑定'
						break
					case '4':
						tempStr = '解除绑定'
						break
					case '5':
						tempStr = '已点评'
						break

				}
				return tempStr
			}
		},
		onLoad() {
			this.getMessageList()
			this.isWeiXin = isWeiXin()
		},
		methods: {
			getMessageList() {
				getMessageList().then(res => {
					if (res.code == 200) {
						this.messageList = res.data
					}
				})
			},
			getClass(type) {
				//0审核通过 1审核未通过 2已美化 3完成绑定 4解除绑定
				if (type == 0) {
					return 'color_green'
				} else if (type == 1) {
					return 'color_red'
				} else if (type == 2) {
					return 'blue'
				}
			},
			// 跳转课件详情
			handleItemClick(info){
				if(info.businessStatus == '3' || info.businessStatus == '4'){
					uni.navigateTo({
						url: '/pages/phone/mine/volunteer/index'
					})
				}else{
					uni.navigateTo({
						url: '/pages/phone/detail/index?id='+info.businessId+'&name='+info.messageContent
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.message-container {
		box-sizing: border-box;
		.content{
			padding: 0px 32rpx;
		}
		.title {
			font-size: 40rpx;
			font-weight: 600;
			margin-top: 40rpx;

		}

		.message-list {
			margin-top: 16rpx;

			.message-item {
				box-sizing: border-box;
				padding: 10rpx 0px;
				//height: 84rpx;
				font-size: 28rpx;
				color: #4E5969;

				image {
					width: 28rpx;
					height: 28rpx;
				}
			}
		}

		.color_green {
			color: #00B42A;
		}

		.color_red {
			color: #F53F3F;
		}

		.color_blue {
			color: #FB7299;
		}

	}
</style>
