<template>
	<view class="container">
		<view class="message">
			<view class="messageDetail">
				<view class="messageTitle">{{item.notice.title}}</view>
				<view class="messageTime">{{item.notice.releaseDate}} 发布</view>
			</view>
			<view class="messageContent" v-if="item.notice.type!='tx'">
			  <jyf-parser :html="item.notice.content" ref="article"></jyf-parser>
			</view>
			<view class="messageContent" v-else>
				<text style="margin-right: 20rpx;">{{item.notice.plainContent}}</text>
				<u-button @click="toAction(item)" shape="circle" plain size="mini" type="primary">
				  {{ item.notice.extInfo.bizType == 'SHELF_REPLENISH' ? '立即处理':'点击查看' }}
				</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import jyfParser from "@/components/jyf-parser/jyf-parser"
	export default{
		components: {
		    jyfParser
		},
		data(){
			return{
				item: {
					createDate: '',
					notice:{
						title: '',
						content: ''
					}
				}
			}
		},
		onLoad(options) {
			let  item = JSON.parse(options.item)
			this.item = Object.assign(this.item,item)
			// this.item.notice.extInfo = JSON.parse(this.item.notice.extInfo)
			console.log(item)
		},
		methods:{
			toAction (data) {
			  // 急送订单
			  if (data.notice.extInfo.bizType == 'TEMP_ORDER') {
				uni.redirectTo({ url: '/pages/sales/edit?pageType=detail&data='+JSON.stringify({ salesBillSn: data.notice.extInfo.bizSn }) })
			  }
			  // 补货订单
			  if (data.notice.extInfo.bizType == 'SHELF_REPLENISH') {
				uni.redirectTo({ url: '/pages/replenishmentManage/replenishmentList?billState=WAIT_CONFIRM' })
			  }
			  // 货架订单
			  if (data.notice.extInfo.bizType == 'SHELF_ORDER') {
				uni.redirectTo({ url: '/pages/shelfOrder/orderDetail?pageType=detail&orderBillSn='+data.notice.extInfo.bizSn })
			  }
			  // 货架异常
			  if (data.notice.extInfo.bizType == 'SHELF_WARN') {
				const shelfName = data.notice.plainContent.split('已经超过')[0]
				uni.redirectTo({ url: '/pages/shelfOrder/shelfOrder?bizType=SHELF_WARN&shelfSn='+data.notice.extInfo.bizSn+'&shelfName='+shelfName })
			  }
			},
		}
	}
</script>

<style lang="less">
	.container{
		width:100%;
		.message{
			margin: 20rpx;
			padding: 30rpx;
			font-size: 28rpx;
			background-color: #fff;
			border-radius: 30rpx;
			box-shadow: 2upx 2upx 6upx #eee;
			.messageDetail{
				margin: 0 0 30rpx 0;
				font-size: 32rpx;
				.messageTitle{
					flex-grow: 1;
					text-align: center;
					margin: 0 0 20rpx 0;
				}
				.messageTime{
					color:#989898;
					font-size: 24rpx;
					text-align: right;
				}
			}
			.messageContent{
				line-height: 46upx;
				word-break: break-all;
			}
		}
	}
	
</style>
