<template>
	<view class="page">
		<view class="content" v-if="file_show ==1" @click.stop="preview">
			<!-- <view class="jianli u-flex u-row-between" v-for="(item,index) in file" :key="index"> -->
			<view class="jianli u-flex u-row-between">
				<view class="u-flex">
					<image style="width: 80rpx; height: 80rpx;" src="../static/images/pdf.png" mode=""></image>
					<view class="">
						<view class="top">{{file.title}}.pdf</view>
						<text class="update">{{file.updatetime}}上传</text>
					</view>
				</view>
				<view class="" @click.stop="hint">
					<u-icon name="more-dot-fill" color="#000" size="28"></u-icon>
				</view>
			</view>
		</view>
		<view class="bottom">
			<view class="btn" @click="toupload">上传简历附件</view>
		</view>
		<u-modal confirmText="删除" :show="show" :title="title" :content='content' :showCancelButton="true"
			@confirm="destroy" @cancel="show = false"></u-modal>
		<u-popup customStyle="height:452rpx;padding:52rpx 0 0 0;" :show="hits_show" mode="bottom" round="32"
			@close="close">
			<view>
				<view @click="ren" class=" bttop" style="">
					重命名
				</view>
				<view class="" style="padding: 0 32rpx;">
					<view class="" style="height: 2rpx; background: #f3f3f3;margin-top: 34rpx;"></view>
				</view>
				<view @click="delect" class="bttop" style="height: 128rpx;line-height: 128rpx;">
					删除
				</view>
				<view class="" style="height: 20rpx; background: #f3f3f3;"></view>
				<view @click="close" class="bttop" style="height: 98rpx;line-height: 98rpx;">
					取消
				</view>
			</view>
			<!-- <view class="safe-area-inset-bottom"></view> -->
		</u-popup>
		<view style="height: 70vh;display: flex;justify-content: center;align-items: center;" v-if="file_show == 0">
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		resumeDetail,
		destroy,
		refresh,
		update
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				id: "",
				hits_show: false,
				show: false,
				file_show: "",
				file: {
					createtime: "",
					file: "",
					id: '',
					resume_id: '',
					title: "",
					updatetime: "",
					user_id: '',
				},
				content: '确定要删除该附件简历吗？'
			}
		},
		onLoad() {
			this.resumeDetail()
		},
		methods: {
			preview() {
				uni.openDocument({
					filePath: this.file.file,
					showMenu: true,
					success: function(res) {
						console.log('打开文档成功');
					},
					fail: () => {
						console.log('文件打开失败');
					}
				});
			},
			ren() {
				uni.navigateTo({
					url: "/pagesD/change-jianli?name=" + this.name,
					events: {
						getjianli: res => {
							update({
								source_type: "file",
								source_id: this.id,
								title: res.virtual_name
							}).then(res => {
								if (res.code == 1) {
									this.$u.toast("更改成功")
									this.resumeDetail()
								}
							})
						}
					}
				})
				this.close()
			},
			close() {
				this.hits_show = false
			},
			hint() {
				this.hits_show = true
			},
			toupload() {
				uni.navigateTo({
					url: "/pagesD/upload?type=" + 2,
					events: {
						up: res => {
							console.log(1111);
							this.resumeDetail()
						}
					}
				})
			},
			destroy() {
				this.show = false
				destroy({
					source_type: "file",
					source_id: this.id
				}).then(res => {
					this.resumeDetail()
				})
			},
			delect() {
				this.show = true
				this.hits_show = false
			},
			resumeDetail() {
				resumeDetail().then(res => {
					if (res.data.file == null) {
						this.file_show = 0
					} else {
						this.file_show = 1
						this.file = res.data.file
						this.id = res.data.file.id
						this.name = res.data.file.title
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bttop {
		text-align: center;
		font-size: 36rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		color: #222222;
		background: #fff;
	}

	.page {
		background: #F3F3F3;
		min-height: 100vh;
		padding: 10rpx 32rpx;
	}

	.top {
		font-size: 32rpx;
		font-family: SFPro, SFPro;
		font-weight: 400;
		color: #222222;
	}

	.update {
		font-size: 24rpx;
		font-family: SFPro, SFPro;
		font-weight: 400;
		color: #777777;
	}

	.jianli {
		width: 686rpx;
		height: 154rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-top: 20rpx;
		padding: 36rpx 38rpx;
		box-sizing: border-box;
	}

	.bottom {
		width: 750rpx;
		padding: 8rpx 38rpx 0;
		height: 166rpx;
		background: #FDFDFD;
		box-sizing: border-box;
		box-shadow: 0rpx 0rpx 0rpx 0rpx rgba(0, 0, 0, 0.2);
		position: fixed;
		bottom: 0;
		left: 0;
	}

	.btn {
		height: 88rpx;
		background: #0C66C2;
		border-radius: 12rpx;
		font-size: 32rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		text-align: center;
		line-height: 88rpx;
	}
</style>