<template>
	<view>
		<!-- 顶部操作条 -->
		<cu-custom :bgColor="'bg-main-color'" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">师傅入驻信息</block>
		</cu-custom>
		<view v-if="(servSkills && servSkills.length) || (servAreas && servAreas.length) " class="margin bg-white">
			<view class="padding">
				<view class="text-black text-bold">服务区域：</view>
				<view v-for="(item,index) in servAreas">
					<text>{{strReplace(item.mergerName, "-", ",")}}</text>
					<!-- <text v-if="index !== servAreas.length - 1">，</text> -->
				</view>
			</view>
			<view class="padding">
				<view class="text-black text-bold">服务技能：</view>
				<view v-for="(item,index) in servSkills">
					<text>{{item.mergeName}}</text>
					<!-- <text v-if="index !== servSkills.length - 1">，</text> -->
				</view>
			</view>
			<!-- <view class="padding">
				<view class="text-black text-bold">特殊技能：</view>
				<view class="solid margin-top-sm padding-sm" v-for="(item,index) in servSpecialSkills">
					<view class="margin-bottom-xs">类目：{{item.specialSkillName}}</view>
					<view class="margin-bottom-xs">是否危险技能：{{item.dangerous === 0 ? '否' : '是'}}</view>
					<view class="margin-bottom-xs">
						<view class="margin-bottom-xs">技能证书：</view>
						<image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="aspectFit"
							:src="item.credential" :data-url="item.credential" @click="viewImage($event, [item.credential])"></image>
					</view>
					<view v-if="item.dangerous == 1" class="margin-bottom-xs">
						<view class="margin-bottom-xs">保险证明：</view>
						<image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="aspectFit"
							:src="item.insurance" :data-url="item.insurance" @click="viewImage($event, [item.insurance])"></image>
					</view>
					<view>保险生效时期：{{item.insuranceStart}} ~ {{item.insuranceEnd}}</view>
				</view>
			</view> -->
			<view class="padding">
				<!-- <text class="text-black text-bold">审核状态：</text> -->
				<!-- <text v-if="curUserInfo.status === 0" class="text-green">审核通过</text> -->
				<!-- <text v-else-if="curUserInfo.status === 3" class="text-yellow">审核中</text> -->
				<!-- <text v-else-if="curUserInfo.status === 4" class="text-red">审核未通过</text> -->
				<button class="cu-btn bg-main-color shadow-blur" @click="navigate2ApplySettled">重新填写入驻信息</button>
			</view>
		</view>
		<view v-else class="margin bg-white padding">
			<view class="text-red padding-tb-sm">请完成入驻信息填写，需求大厅将根据师傅入驻信息推送任务单，无入驻信息将进行随机推送</view>
			<button class="cu-btn bg-main-color shadow-blur" @click="navigate2ApplySettled">填写入驻信息</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curUserInfo: {},
				servAreas: [],
				servSkills: [],
				servSpecialSkills: []
			}
		},
		// onLoad() {
		// 	this.loadData();
		// },
		onShow() {
			this.loadData();
		},
		methods: {
			async loadData() {
				this.curUserInfo = await this.$request.getCurUserNoCache();
				this.loadServAreas();
				this.loadServSkills();
				this.loadSpecialSkills();
			},
			async loadServAreas() {
				let res = await this.$request.getWorkerArea({
					workerId: this.curUserInfo.workerId
				});
				this.servAreas = res.data;
			},
			async loadServSkills() {
				let res = await this.$request.getWorkerGoodsCategory({
					workerId: this.curUserInfo.workerId
				});
				this.servSkills = res.data;
			},
			async loadSpecialSkills() {
				let res = await this.$request.getWorkerSpecialSkill({
					workerId: this.curUserInfo.workerId
				});
				this.servSpecialSkills = res.data;
			},
			viewImage(e, imgList) {
				uni.previewImage({
					urls: imgList,
					current: e.currentTarget.dataset.url
				});
			},
			navigate2ApplySettled() {
				uni.navigateTo({
					url: '/pages/my/master-occupancy'
				})
			},
			strReplace(wholeStr, newStr, oldStr) {
				if (wholeStr && wholeStr.length > 0) {
					wholeStr = wholeStr.replaceAll(oldStr, newStr);
				}
				return wholeStr;
			}
		},
	}
</script>

<style>
</style>
