<template>
	<view class="message-detail-index">
		<view class="message-detail-content">
			{{detail.sendUserName}}{{detail.message}}
		</view>
		<view class="message-btn-box">
			<view class="message-btn red" @click="btnClick('拒绝')">拒绝</view>
			<view class="line"></view>
			<view class="message-btn primary" @click="btnClick('同意')">同意</view>
		</view>
	</view>
</template>

<script>
	import {
		getMessageDetailById,
		bindProject
	} from '@/request/api/message.js'
	export default {
		data() {
			return {
				messageId: '',
				detail: {}
			}
		},
		onLoad(body) {
			this.messageId = body.id;
			this.detail = JSON.parse(body.item);
		},
		methods: {
			init() {

			},
			btnClick(msg) {
				uni.showModal({
					title: '有极提示',
					content: '是否' + msg + '加入该项目',
					success: (res) => {
						if (res.confirm) {
							bindProject({
								organizationId: this.detail.organizationId,
								projectId: this.detail.projectId,
								clientId: this.detail.dataId,
								userId: this.$store.getters.user.userId,
								identityId: this.detail.identityId || 1
							}).then(res => {
								if (res.code === 200) {
									this.$toast('操作成功')
								}
							})
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.message-detail-index {
		background: $uni-white;
		padding: 20rpx;
		padding-bottom: 0;
		margin: 20rpx 30rpx;
		border-radius: 10rpx;

		.message-detail-content {
			min-height: 200rpx;
			padding-bottom: 40rpx;
		}

		.message-btn-box {
			width: 100%;
			display: flex;
			height: 80rpx;
			align-items: center;
			border-top: 1px solid $uni-border-3;

			.line {
				width: 1px;
				height: 40rpx;
				background: $uni-border-3;
			}

			.message-btn {
				text-align: center;
				flex: 1;
			}

			.red {
				color: $uni-error;
			}

			.primary {
				color: $uni-primary;
			}
		}

	}
</style>