<template>
	<view>
		<view style="padding:5rpx 20rpx 45rpx 20rpx;">
			<view class="desc">
				<hsInput label="用户编号" v-model="form.userCode" :disabled="true" />
			</view>
			<view class="desc">
				<hsInput label="领取人" v-model="form.userName" :disabled="true" />
			</view>
			<view class="desc">
				<hsDictSelect label="地点" dictKey="welfare_apply_addr" v-model="form.address" :disabled="isDisabled" />
			</view>
		</view>
		<u-gap height="70" bgColor="#ffffff"></u-gap>
		<view class="bottim_view">
			<view>
				<u-row>
					<u-col span="11">
						<u-button :disabled="isDisabled" class="btnDoPay" shape="circle" @click="submit" color="rgb(55,186,189)" text="报名">
						</u-button>
					</u-col>
				</u-row>
			</view>
		</view>
	</view>
</template>

<script>
	import hsDictSelect from "../components/dictSelect.vue"
	import hsInput from "../components/input.vue"
	export default {
		components: {
			hsDictSelect,
			hsInput
		},
		data() {
			return {
				isDisabled: false,
				defaultDept: '',
				form: {
					userCode: null,
					userName: null,
					address: null,
					id: uni.getStorageSync("applyInfo").id,
					source: uni.getStorageSync("applyInfo").source
				}
			}
		},
		onLoad() {
			this.getApplyData()
			this.form.userCode = uni.getStorageSync("userInfo").userName
			this.form.userName = uni.getStorageSync("userInfo").nickName
		},
		methods: {
			async submit() {
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/sumbitWelfare',
					method: 'post',
					data: this.form,
					urlType: this.$getUrlType()
				});
				if (res.code === 200) {
					this.$showModal("报名成功")
				} else {
					this.$showModal(res.msg)
				}
			},
			getApplyData() {
				this.$httpRequest({
					url: '/app/getApplyData?id=' + uni.getStorageSync("applyInfo").id,
					method: 'get',
					urlType: this.$getUrlType()
				}).then(res => {
					res = res.data
					if (res.code === 200) {
						if (res.data.nowStatus === '2') {
							this.form.address = res.data.address
							this.isDisabled = true
							this.$showModal("您已完成报名")
						}
					} else {

					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.desc {
		padding: 10rpx 5rpx;
		color: #818181;
		font-size: 20rpx;
	}

	.pickerView {
		// align-items: flex-end;
		padding: 10rpx 20rpx;
		border: 1rpx #eeeeee solid;
	}

	.pickerText {
		font-size: 26rpx;
		color: #b1b1b1;
	}

	.bottim_view {
		padding: 5px 20px 30px;
		position: fixed;
		left: 0px;
		bottom: 0px;
		width: 100%;
		height: 40px;
		background-color: #ffffff;
	}
</style>
