<template>
	<view class="task-detail">
		<view class="task-detail-item">
			<view class="task-detail-label">
				姓名：
			</view>
			<view class="task-detail-content">
				张三
			</view>
		</view>
		<view class="task-detail-item">
			<view class="task-detail-label">
				评分：
			</view>
			<view class="task-detail-content">
				<uni-rate :readonly="true" :value="2" :max="5" />
			</view>
		</view>
		<view class="task-detail-bottom">
			<button type="primary" @click="handleOrder(operationType.receive)">接单</button>
			<button type="primary" @click="handleOrder(operationType.convert)">转单</button>
		</view>
		<uni-popup ref="popup" type="center">
			<uni-popup-modal title="确认接单？" @ok="handleSure" @cancel="handleCancel">
				<radio-group @change="radioChange">
					<label class="radio-wrap" v-for="(item, index) in convertOrderReason" :key="item.value">
						<view>
							<radio :value="item.value" :checked="index === current" />
						</view>
						<view>{{item.text}}</view>
					</label>
				</radio-group>
			</uni-popup-modal>
		</uni-popup>
	</view>
</template>

<script>
	import {operationType, convertOrderReason} from '../configs';
	import uniPopupModal from '@/components/uni-popup/uni-popup-modal.vue';

	export default {
		components: {
			uniPopupModal
		},
		data() {
			return {
				task: {
					name: '张三',
					member: '李四',
					orderNumber: '123123123',
					time: '2020-08-11'
				},
				operationType,
				openType: '',
				convertOrderReason,
				current: '1'
			}
		},
		methods: {
			openModal() {
				this.$refs.popup.open();
			},
			handleOrder(type) {
				console.log(`handle type: ${type}`);
				this.openType = type;
				this.openModal();
			},
			handleSure() {
				this.$refs.popup.close();
			},
			handleCancel() {
				this.$refs.popup.close();
			},
			radioChange(e) {
				const {value} = e.detail;
				this.current = value;
			}
		}
	}
</script>

<style lang="less" scoped>
	.task-detail {
		width: 100%;
		&-item {
			width: 100%;
			display: flex;
			align-items: center;
			flex-direction: row;
			border-bottom: 1px solid #666;
			padding: 10rpx 20rpx;
		}
		&-label {
			width: 100rpx;
		}
		&-content {
			flex: 1;
		}
		&-bottom {
			display: flex;
			justify-content: space-between;
			padding: 0 40rpx;
			margin-top: 40rpx;
		}
	}
	.pop-content {
		background: #fff;
		width: 600rpx;
		color: #000;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 10rpx;
	}
	.radio-wrap {
		display: flex;
		flex-direction: row;
		margin-bottom: 20rpx;
		align-items: center;
	}
	.pop-content-title {
		text-align: center;
		margin-bottom: 20rpx;
		font-weight: bold;
	}
	.pop-content-bottom {
		display: flex;
		justify-content: space-between;
		padding: 0 40rpx;
		margin-top: 40rpx;
	}
</style>
