<template>
	<div class="app-container">
		<el-row>
			<el-col :span="24">
				<div class="cell">
					<div class="cell-title">
						<div class="title-left">
							<div class="title">攻略管理</div>
						</div>
					</div>
					<div class="cell-body">
						<div class="controls">
							<el-form :inline="true" :model="formInline" class="demo-form-inline">
								<el-form-item label="">
									<el-input v-model="formInline.key" style="width: 280px;" prefix-icon="el-icon-search" clearable
										placeholder="请输入标题"></el-input>
								</el-form-item>
								<el-form-item>
									<el-button type="primary" class="btn-search" @click="btn_search">查询</el-button>
								</el-form-item>
							</el-form>
							<div>
								<el-button class="export" size="small" @click="add_strategy">
									<i class="el-icon el-icon-circle-plus-outline" style="font-size: 20px;"></i>
									<span style="font-size: 16px;">新增攻略</span>
								</el-button>
								<el-button class="export" size="small" @click="showSetPublisher">
									<i class="el-icon el-icon-setting" style="font-size: 20px;"></i>
									<span style="font-size: 16px;">发布人设置</span>
								</el-button>
							</div>
						</div>
						<el-table ref="multipleTable" :data="tableData" height="560" style="width: 100%" :cell-style="cell_style" v-loading="loading"
							:header-cell-style="header_cell_style">
							<el-table-column label="序号" align="center" width="66">
								<template slot-scope="scope">
									<span>{{ scope.row.xuhao }}</span>
								</template>
							</el-table-column>
							<el-table-column label="标题" align="center" width="180">
								<template slot-scope="scope">
									<span>{{ scope.row.title }}</span>
								</template>
							</el-table-column>
							<el-table-column label="描述" align="left">
								<template slot-scope="scope">
									<div style="height: 200px; overflow-y: auto;" class="scroll-container">
										<span v-html="scope.row.content"></span>
									</div>
								</template>
							</el-table-column>
							<el-table-column label="视频/图片" align="center" width="260">
								<template slot-scope="scope">
									<span v-if="typeof scope.row.image !== 'undefined'">
										<viewer>
											<el-carousel v-if="typeof scope.row.image == 'string'" height="180px">
												<el-carousel-item v-for="item in 1" :key="item">
													<img :src="scope.row.image" style="height: 180px; object-fit: contain; cursor: pointer;" />
												</el-carousel-item>
											</el-carousel>
											<el-carousel v-else height="180px">
												<el-carousel-item v-for="item in scope.row.image" :key="item">
													<img :src="item" style="height: 180px; object-fit: contain; cursor: pointer;" />
												</el-carousel-item>
											</el-carousel>
										</viewer>
									</span>
									<span v-else-if="typeof scope.row.video !== 'undefined'">
										<video-player class="video-player vjs-custom-skin" @play="onPlayerPlay($event)" :playsinline="true"
											:options="scope.row.video"></video-player>
									</span>
								</template>
							</el-table-column>
							<el-table-column label="选择地点" align="center" width="130">
								<template slot-scope="scope">
									<span>{{ scope.row.townName }}</span>
								</template>
							</el-table-column>
							<el-table-column label="发布时间" align="center" width="160">
								<template slot-scope="scope">
									<span>{{ scope.row.createDate }}</span>
								</template>
							</el-table-column>
							<el-table-column label="来源" align="center" width="88">
								<template slot-scope="scope">
									<span>{{ scope.row.publishWay }}</span>
								</template>
							</el-table-column>
							<el-table-column label="发布人" align="center" width="88">
								<template slot-scope="scope">
									<span>{{ scope.row.userName }}</span>
								</template>
							</el-table-column>
							<el-table-column label="操作" align="center" width="180">
								<template slot-scope="scope">
									<el-button v-if="scope.row.isTop == 0" @click="handleSetTop(scope.row.id, 1)" type="text"
										style="color: rgba(9, 101, 98, 1);" size="small">置顶</el-button>
									<el-button v-else @click="handleSetTop(scope.row.id, 0)" type="text" style="color: rgba(212, 48, 48, 1);"
										size="small">取消置顶</el-button>
									<el-button v-if="scope.row.publishWay !== '小程序'" @click="handleModifyClick(scope.row)" type="text"
										style="color: rgba(9, 101, 98, 1);" size="small">编辑</el-button>
									<el-button @click="handleDelClick(scope.row)" type="text" style="color: rgba(212, 48, 48, 1);" size="small">删除</el-button>
								</template>
							</el-table-column>
						</el-table>
						<div class="pagination-table">
							<el-pagination @current-change="currentPageChange" :current-page.sync="pagination.currentPage" :page-size="pagination.pageSize"
								layout="prev, pager, next, jumper" :total="pagination.total">
							</el-pagination>
						</div>
					</div>
				</div>
			</el-col>
		</el-row>
		<!-- 发布人设置 -->
		<el-dialog title="发布人设置" custom-class="configuration-window" :visible.sync="setPublisherVisible" :close-on-click-modal="false"
			:close-on-press-escape="false" @close="setPublisherVisible = false">
			<el-row style="display: none;">
				<el-col :span="24" style="display: flex; justify-content: space-between; padding: 0;">
					<div>
						<el-input v-model="publisherSearch.key" style="width: 180px; margin-right: 10px;" clearable placeholder="请输入用户名"></el-input>
						<el-button type="primary" class="configure-btn" @click="btn_search">查询</el-button>
					</div>
					<el-button class="configure-btn" @click="show_add_publisher_dialog = true">确定设置</el-button>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24" style="padding: 0;margin: 10px 0;">
					<el-table :data="tableData_publisher" height="380" style="width: 100%" :cell-style="cell_style" v-loading="loading"
						:header-cell-style="header_cell_style">
						<el-table-column label="序号" align="center" width="55">
							<template slot-scope="scope">
								<span>{{ scope.row.xuhao }}</span>
							</template>
						</el-table-column>
						<el-table-column label="ID" align="center">
							<template slot-scope="scope">
								<span>{{ scope.row.id }}</span>
							</template>
						</el-table-column>
						<el-table-column label="账号名" align="center">
							<template slot-scope="scope">
								<span>{{ scope.row.name }}</span>
							</template>
						</el-table-column>
						<el-table-column label="操作" align="center">
							<template slot-scope="scope">
								<el-button v-if="scope.row.mark == 0" @click="bindingPuhlisherIds(scope.row.id, 'add')" type="text"
									style="color: rgba(9, 101, 98, 1);" size="small">绑定</el-button>
								<el-button v-else @click="bindingPuhlisherIds(scope.row.id, 'del')" type="text" style="color: rgba(212, 48, 48, 1);"
									size="small">取消绑定</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-col>
			</el-row>
		</el-dialog>
		<!-- 新增攻略 -->
		<el-dialog title="新增攻略" custom-class="add-dlg-class" :visible.sync="dialogAddStrategyVisible" :close-on-click-modal="false"
			:close-on-press-escape="false" @close="dialogAddStrategyVisible = false">
			<div style="height: 675px; padding-right: 10px; overflow-y: auto;" class="scroll-container">
				<el-form :model="formAddDialog" ref="addDialogForm" :rules="addDialogFormRules">
					<el-form-item label="标题" :required="true" :label-width="formLabelWidth" prop="title">
						<el-input v-model="formAddDialog.title" placeholder="请输入标题"></el-input>
					</el-form-item>
					<el-form-item label="发布人" :required="true" :label-width="formLabelWidth" prop="publisher">
						<el-select v-model="formAddDialog.publisher" filterable clearable placeholder="请选择发布人">
							<el-option v-for="item in options" :key="item.publisher" :label="item.label" :value="item.publisher">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="内容" :required="true" :label-width="formLabelWidth" prop="content">
						<quill-editor v-model="formAddDialog.content" :options="editorOption"></quill-editor>
					</el-form-item>
					<el-form-item label="图片/视频" :required="true" :label-width="formLabelWidth" prop="imgs">
						<div class="add-strategy-img">
							<div v-for="(item, index) in formAddDialog.imgs">
								<div v-if="item.img == ''" class="add-strategy-img-box" @click="openImageUploadDialog(index, 'add')">
									<div class="add-strategy-img-plus"><i class="el-icon-plus"></i></div>
									<div class="add-strategy-img-txt">上传图片 {{index + 1}}</div>
								</div>
								<div v-else class="add-strategy-img-box">
									<viewer>
										<img :src="item.img" style="height: 120px; width: 120px; margin-bottom: -14px; cursor: pointer; border-radius: 5px;" />
										<div @click="del_local_display_img('formAddDialog.img', index)" class="add-strategy-img-clear">&times;</div>
									</viewer>
								</div>
							</div>
							<input type="file" ref="addImageUploadInput" style="display:none" accept=".jpg,.png"
								@change="uploadImageVideo($event, 'img', formAddDialog.imgIndex)" />
							<div v-if="formAddDialog.show_video == ''" class="add-strategy-img-box" style="border: 2px dashed #ff4949;"
								@click="openVideoUploadDialog('add')">
								<div class="add-strategy-img-plus" style="color: #ff4949; font-weight: bold;"><i class="el-icon-plus"></i></div>
								<div class="add-strategy-img-txt" style="color: #ff4949; font-weight: bold;">上传视频</div>
							</div>
							<div v-else class="add-strategy-img-box-video">
								<video-player class="video-player vjs-custom-skin" style="margin-top: 25px; overflow: hidden;" @play="onPlayerPlay($event)"
									:playsinline="true" :options="formAddDialog.show_video"></video-player>
								<div @click="del_local_display_img('formAddDialog.show_video', -1)" class="add-strategy-img-clear"
									style="color: #fff; background-color: #ff4949;">&times;</div>
							</div>
							<input type="file" ref="addVideoUploadInput" style="display:none" accept=".mp4" @change="uploadImageVideo($event, 'video', -1)" />
						</div>
					</el-form-item>
					<el-form-item label="选择地点" :required="true" :label-width="formLabelWidth" prop="rtownId">
						<el-select v-model="formAddDialog.rtownId" @change="handleAddAdressStrategy" placeholder="请选择地点">
							<el-option v-for="item in formAddDialog.rtownOptions" :key="item.id" :label="item.name" :value="item.id">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="" :required="true" :label-width="formLabelWidth" prop="hotelIds">
						<div style="display: flex; flex-wrap: wrap; justify-content: space-between;">
							<div v-for="(hotel, index) in formAddDialog.hotelNames" :label="hotel.name" :key="hotel.id">
								<viewer>
									<div class="hotel-box" :class="{'bg-color': hotel.checked}">
										<img :src="hotel.coverImg" style="width: 114px; height: 70px; border-radius: 5px;">
										<div class="hotel-box-txt" @click="getHotelIds(index, hotel.id)">
											<div style="margin: 0 0 10px 0;" class="hotel-list">{{hotel.name}}</div>
											<div v-if="hotel.type == 1" class="hotel-list">银宿级</div>
											<div v-else-if="hotel.type == 2" class="hotel-list">金宿级</div>
											<div v-else-if="hotel.type == 3" class="hotel-list">白金级</div>
											<div v-else class="hotel-list">等级未知</div>
										</div>
									</div>
								</viewer>
							</div>
						</div>
					</el-form-item>
					<el-form-item label="是否置顶" :label-width="formLabelWidth">
						<el-switch v-model="formAddDialog.istop" active-color="#096562" inactive-color="#ff4949"></el-switch>
					</el-form-item>
				</el-form>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogAddStrategyVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleAddStrategy">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 编辑攻略 -->
		<el-dialog title="编辑攻略" custom-class="add-dlg-class" :visible.sync="dialogModifyVisible" :close-on-click-modal="false" :close-on-press-escape="false"
			@close="dialogModifyVisible = false">
			<div style="height: 675px; padding-right: 10px; overflow-y: auto;" class="scroll-container">
				<el-form :model="formModifyDialog" ref="modifyDialogForm" :rules="modifyDialogFormRules">
					<el-form-item label="标题" :required="true" :label-width="formLabelWidth" prop="title">
						<el-input v-model="formModifyDialog.title" placeholder="请输入标题"></el-input>
					</el-form-item>
					<el-form-item label="发布人" :required="true" :label-width="formLabelWidth" prop="publisher">
						<el-select v-model="formModifyDialog.publisher" filterable placeholder="请选择发布人">
							<el-option v-for="item in options" :key="item.publisher" :label="item.label" :value="item.publisher">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="内容" :required="true" :label-width="formLabelWidth" prop="content">
						<quill-editor v-model="formModifyDialog.content" :options="editorOption"></quill-editor>
					</el-form-item>
					<el-form-item label="图片/视频" :required="true" :label-width="formLabelWidth" prop="imgs">
						<div class="add-strategy-img">
							<div v-for="(item, index) in formModifyDialog.imgs">
								<div v-if="item.img == ''" class="add-strategy-img-box" @click="openImageUploadDialog(index, 'modify')">
									<div class="add-strategy-img-plus"><i class="el-icon-plus"></i></div>
									<div class="add-strategy-img-txt">上传图片 {{index + 1}}</div>
								</div>
								<div v-else class="add-strategy-img-box">
									<viewer>
										<img :src="item.img" style="height: 120px; width: 120px; margin-bottom: -14px; cursor: pointer; border-radius: 5px;" />
										<div @click="del_local_display_img('formModifyDialog.img', index)" class="add-strategy-img-clear">&times;</div>
									</viewer>
								</div>
							</div>
							<input type="file" ref="modifyImageUploadInput" style="display:none" accept=".jpg,.png"
								@change="uploadModifyImageVideo($event, 'img', formModifyDialog.imgIndex)" />
							<div v-if="formModifyDialog.show_video == ''" class="add-strategy-img-box" style="border: 2px dashed #ff4949;"
								@click="openVideoUploadDialog('modify')">
								<div class="add-strategy-img-plus" style="color: #ff4949; font-weight: bold;"><i class="el-icon-plus"></i></div>
								<div class="add-strategy-img-txt" style="color: #ff4949; font-weight: bold;">上传视频</div>
							</div>
							<div v-else class="add-strategy-img-box-video">
								<video-player class="video-player vjs-custom-skin" style="margin-top: 25px; overflow: hidden;" @play="onPlayerPlay($event)"
									:playsinline="true" :options="formModifyDialog.show_video"></video-player>
								<div @click="del_local_display_img('formModifyDialog.show_video', -1)" class="add-strategy-img-clear"
									style="color: #fff; background-color: #ff4949;">&times;</div>
							</div>
							<input type="file" ref="modifyVideoUploadInput" style="display:none" accept=".mp4"
								@change="uploadModifyImageVideo($event, 'video', -1)" />
						</div>
					</el-form-item>
					<el-form-item label="选择地点" :required="true" :label-width="formLabelWidth" prop="rtownId">
						<el-select v-model="formModifyDialog.rtownId" @change="handleModifyAdressStrategy('change')" placeholder="请选择地点">
							<el-option v-for="item in formModifyDialog.rtownOptions" :key="item.id" :label="item.name" :value="item.id">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="" :required="true" :label-width="formLabelWidth" prop="hotelIds">
						<div style="display: flex; flex-wrap: wrap; justify-content: space-between;">
							<div v-for="(hotel, index) in formModifyDialog.hotelNames" :label="hotel.name" :key="hotel.id">
								<viewer>
									<div class="hotel-box" :class="{'bg-color': hotel.checked}">
										<img :src="hotel.coverImg" style="width: 114px; height: 70px; border-radius: 5px;">
										<div class="hotel-box-txt" @click="getModifyHotelIds(index, hotel.id)">
											<div style="margin: 0 0 10px 0;" class="hotel-list">{{hotel.name}}</div>
											<div v-if="hotel.type == 1" class="hotel-list">银宿级</div>
											<div v-else-if="hotel.type == 2" class="hotel-list">金宿级</div>
											<div v-else-if="hotel.type == 3" class="hotel-list">白金级</div>
											<div v-else class="hotel-list">等级未知</div>
										</div>
									</div>
								</viewer>
							</div>
						</div>
					</el-form-item>
					<el-form-item label="是否置顶" :label-width="formLabelWidth">
						<el-switch v-model="formModifyDialog.istop" active-color="#096562" inactive-color="#ff4949"></el-switch>
					</el-form-item>
				</el-form>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogModifyVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleModifyStrategy">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 删除攻略确认对话框 -->
		<el-dialog custom-class="el-dialog-delete-account" :visible.sync="dialogDeleteVisible" :close-on-click-modal="false" :close-on-press-escape="false"
			:show-close="false">
			<div slot="" class="del-account-body">
				<img src="../../icons/serveAC/del_warning.png" alt="">
				<div class="del-account-body-txt">是否确定从列表中删除？</div>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-user-cancel-btn" @click="dialogDeleteVisible = false"> 否 </el-button>
				<el-button class="add-user-confirm-btn" @click="dialogDeleteStrategy"> 是 </el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import {
		getTableData,
		setTop,
		getTown,
		getHotels,
		getPublisher,
		uploadFiles,
		insertStrategy,
		updateStrategy,
		delStrategy,
		bindingPublisher,
		publisherList
	} from '@/api/strategyMgr'

	import {
		isEmpty,
		cos
	} from '@/js/common'

	import {
		valid
	} from 'mockjs'

	import COS from 'cos-js-sdk-v5'
	import {
		config
	} from '@vue/test-utils'

	export default {
		data() {
			return {
				videoList: [],
				currentUserLevel: this.$store.state.user.level, // 当前用户的权限
				//currentUserCreateId: this.$store.state.user.create_id, // 当前用户的createId
				currentUserId: this.$store.state.user.user_id, // 当前用户的userId
				formLabelWidth: '100px',
				// 表格单元格样式
				cell_style: {
					color: '#1A202B',
					'font-size': '14px',
					'font-family': 'Microsoft YaHei-3970(82674968)'
				},
				// 表格头部样式
				header_cell_style: {
					background: '#E6ECFE',
					color: '#1A202B',
					'font-size': '16px',
					'font-family': 'Microsoft YaHei-3970(82674968)'
				},
				addDialogFormRules: { // 新增攻略验证规则
					title: [{
						required: true,
						message: '请输入标题',
						trigger: 'blur'
					}, {
						pattern: /^[\s\S]*[\u4e00-\u9fa5]{2,}[\s\S]*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					publisher: [{
						required: true,
						message: '请选择发布人',
						trigger: 'blur'
					}, {
						required: true,
						message: '请选择发布人',
						trigger: 'change'
					}],
					content: [{
						required: true,
						message: '请输入内容',
						trigger: 'blur'
					}, {
						pattern: /^[\s\S]*[\u4e00-\u9fa5]{3,}[\s\S]*$/,
						message: '至少3个汉字，其它字符不限',
						trigger: 'blur'
					}],
					imgs: [{
						required: true,
						message: '请选择图片或视频',
						trigger: 'blur'
					}, {
						validator: this.validateImgVideo,
						trigger: 'blur'
					}],
					rtownId: [{
						required: true,
						message: '请选择乡镇',
						trigger: 'blur'
					}],
					hotelIds: [{
						required: true,
						message: '请选择民宿',
						trigger: 'change'
					}]
				},
				// 富文本编辑器配置
				editorOption: {
					modules: {
						toolbar: [
							['bold', 'italic', 'underline', 'strike'], // 加粗、斜体、下划线、删除线按钮

							[{
								'list': 'ordered'
							}, {
								'list': 'bullet'
							}], // 有序列表和无序列表按钮
							[{
								'indent': '-1'
							}, {
								'indent': '+1'
							}], // 减少缩进和增加缩进按钮

							[{
								'size': ['small', false, 'large', 'huge']
							}], // 自定义下拉菜单，表示字体大小

							[{
								'color': []
							}, {
								'background': []
							}], // 下拉菜单，使用主题中的默认颜色和背景色
							[{
								'align': []
							}], // 下拉菜单，选择对齐方式

							['clean'] // 清除格式按钮，移除所有格式
						]
					},
					placeholder: '请输入内容'
				},
				modifyDialogFormRules: { // 编辑周边验证规则
					title: [{
						required: true,
						message: '请输入标题',
						trigger: 'blur'
					}, {
						pattern: /^[\s\S]*[\u4e00-\u9fa5]{2,}[\s\S]*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					publisher: [{
						required: true,
						message: '请选择发布人',
						trigger: 'blur'
					}, {
						required: true,
						message: '请选择发布人',
						trigger: 'change'
					}],
					content: [{
						required: true,
						message: '请输入内容',
						trigger: 'blur'
					}, {
						pattern: /^[\s\S]*[\u4e00-\u9fa5]{3,}[\s\S]*$/,
						message: '至少3个汉字，其它字符不限',
						trigger: 'blur'
					}],
					imgs: [{
						required: true,
						message: '请选择图片或视频',
						trigger: 'blur'
					}, {
						validator: this.validateModifyImgVideo,
						trigger: 'blur'
					}],
					rtownId: [{
						required: true,
						message: '请选择乡镇',
						trigger: 'blur'
					}],
					hotelIds: [{
						required: true,
						message: '请选择民宿',
						trigger: 'change'
					}]
				},
				// 查询数据
				formInline: {
					key: ''
				},
				publisherSearch: {
					key: ''
				}, // 搜索用户名
				bindedPublisherIds: '', // 绑定的用户ids
				videoOptions: {
					playbackRates: [0.5, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0], //播放速度
					autoplay: false, // 如果true,浏览器准备好时开始回放。
					muted: false, // 默认情况下将会消除任何音频。
					loop: false, // 导致视频一结束就重新开始。
					preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
					language: "zh-CN",
					aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
					fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
					sources: [{
						withCredentials: false,
						type: "video/mp4", // 这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目
						src: '', // https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4
					}],
					controls: true,
					hls: true,
					poster: "", // 你的封面地址
					notSupportedMessage: "此视频暂无法播放，请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
					controlBar: {
						progressControl: true,
						currentTimeDisplay: true,
						timeDivider: true,
						durationDisplay: true,
						remainingTimeDisplay: false,
						fullscreenToggle: true, // 全屏按钮
					},
					flash: {
						hls: {
							withCredentials: false
						}
					},
					html5: {
						hls: {
							withCredentials: false
						}
					}
				},
				addVideoUploadFileDisable: false, // 添加视频无效
				addImgsUploadFileDisable: false, // 添加图片无效
				modifyVideoUploadFileDisable: false, // 修改添加视频无效
				modifyImgsUploadFileDisable: false, // 修改添加图片无效
				options: [],
				formAddDialog: {
					title: '',
					publisher: '',
					content: '',
					rtownId: '',
					rtownOptions: [],
					hotelIds: [],
					hotelNames: [],
					showHotels: false,
					imgIndex: '',
					imgs: [{
						id: 1,
						img: ''
					}, {
						id: 2,
						img: ''
					}, {
						id: 3,
						img: ''
					}, {
						id: 4,
						img: ''
					}, {
						id: 5,
						img: ''
					}, {
						id: 6,
						img: ''
					}, {
						id: 7,
						img: ''
					}, {
						id: 8,
						img: ''
					}, {
						id: 9,
						img: ''
					}],
					show_video: '',
					post_video: '',
					istop: false
				},
				formModifyDialog: {
					id: '',
					title: '',
					publisher: '',
					content: '',
					rtownId: '',
					rtownOptions: [],
					hotelIds: [],
					hotelNames: [],
					showHotels: false,
					imgIndex: '',
					imgs: [{
						id: 1,
						img: ''
					}, {
						id: 2,
						img: ''
					}, {
						id: 3,
						img: ''
					}, {
						id: 4,
						img: ''
					}, {
						id: 5,
						img: ''
					}, {
						id: 6,
						img: ''
					}, {
						id: 7,
						img: ''
					}, {
						id: 8,
						img: ''
					}, {
						id: 9,
						img: ''
					}],
					show_video: '',
					post_video: '',
					istop: false
				},
				tableData: [], // 攻略分页列表
				tableData_publisher: [], // 发布人列表
				cond_data: {},
				// 分页参数
				pagination: {
					currentPage: 1,
					pageSize: 9,
					total: 0
				},
				loading: true,
				setPublisherVisible: false, // 发布人设置
				dialogAddStrategyVisible: false, // 新增攻略
				dialogModifyVisible: false, // 修改攻略
				dialogDeleteVisible: false, // 删除确认对话框
				delStrategyId: '', // 要删除的攻略id
				cosVal: {
					SecretId: "AKIDJSP9gz469yZv77tQjotsgHguvjIgtvkL",
					SecretKey: "b3MVRD1g8RYS9g195oMkvukQvDKZfbOz",
					SecurityToken: "1320402385",
					Bucket: "jinganminsu-1320402385",
					Region: "ap-nanjing",
				}
			}
		},
		created() {
			// 检测权限
			if (this.currentUserLevel !== 2) {
				this.$router.replace({
					path: '/data'
				})
				return
			}
			// 获取消费记录,表格数据
			this.get_table_data('list');
			// 绑定的发布人列表
			this.getPublisherOptions();

			this.getTown();

			this.videoList.push({
				playerOptions: {
					playbackRates: [0.5, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0], //播放速度
					autoplay: false, // 如果true,浏览器准备好时开始回放。
					muted: false, // 默认情况下将会消除任何音频。
					loop: false, // 导致视频一结束就重新开始。
					preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
					language: "zh-CN",
					aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
					fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
					sources: [{
						withCredentials: false,
						type: "video/mp4", // 这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目
						src: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4',
					}],
					controls: true,
					hls: true,
					poster: "", // 你的封面地址
					notSupportedMessage: "此视频暂无法播放，请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
					controlBar: {
						progressControl: true,
						currentTimeDisplay: true,
						timeDivider: true,
						durationDisplay: true,
						remainingTimeDisplay: false,
						fullscreenToggle: true, // 全屏按钮
					},
					flash: {
						hls: {
							withCredentials: false
						}
					},
					html5: {
						hls: {
							withCredentials: false
						}
					}
				}
			})
		},
		watch: {
			dialogAddStrategyVisible(newVal, oldVal) {
				if (newVal == true) {
					this.$nextTick(() => {
						this.$refs.addDialogForm.resetFields(); // 重置表单
						for (let i = 0; i < 9; i++) {
							this.del_local_display_img('formAddDialog.img', i);
						}
						this.del_local_display_img('formAddDialog.show_video', -1);
					});
				}
			}
		},
		mounted() {
			document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";

			document.addEventListener('fullscreenchange', this.handleFullScreenChange);
		},
		beforeDestroy() {
			document.removeEventListener('fullscreenchange', this.handleFullScreenChange);
		},
		methods: {
			// 绑定 或 解绑发布人
			bindingPuhlisherIds(id, param) {
				if (param == 'add') {
					if (this.bindedPublisherIds == '') {
						this.bindedPublisherIds = id;
					} else {
						this.bindedPublisherIds = this.bindedPublisherIds + ',' + id;
					}
				} else if (param == 'del') {
					if (this.bindedPublisherIds.includes(id + ',')) {
						this.bindedPublisherIds = this.bindedPublisherIds.replace(id + ',', '');
					} else if (this.bindedPublisherIds.includes(',' + id)) {
						this.bindedPublisherIds = this.bindedPublisherIds.replace(',' + id, '');
					} else {
						this.bindedPublisherIds = this.bindedPublisherIds.replace(id, '');
						//this.$message.warning('至少保留一个发布人');
						//return
					}
				}
				let data = {
					id: this.currentUserId,
					userId: this.bindedPublisherIds
				}

				let that = this;
				bindingPublisher(data).then((res) => {
					if (res.code === 200) {
						if (param == 'add') {
							that.$message.success('绑定成功')
						} else if (param == 'del') {
							that.$message.success('解绑成功')
						}
						// 发布人列表
						that.showSetPublisher()
						// 绑定的发布人列表
						this.getPublisherOptions();
					} else {
						that.$message.warning(res.message)
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
			},
			// 发布人列表
			showSetPublisher() {
				let that = this;
				publisherList(that.currentUserId).then((res) => {
					// console.log(res.data.pageList);
					if (res.code === 200) {
						let tempData = res.data.pageList;
						that.tableData_publisher = [];
						if (typeof tempData !== 'undefined' && tempData !== '') {
							let ids = '';
							for (let i = 0; i < tempData.length; i++) {
								let tdata = {
									xuhao: i + 1,
									id: tempData[i].id,
									name: tempData[i].user_name,
									mark: tempData[i].mark
								};
								that.tableData_publisher.push(tdata);
								if (tempData[i].mark == 1) {
									ids = ids + tempData[i].id + ',';
								}
							}
							that.bindedPublisherIds = ids.substring(0, ids.length - 1);
						} else {
							that.tableData_publisher = [];
							that.$message.warning('没有符合条件的数据！')
						}
					} else {
						that.tableData_publisher = [];
						that.$message.warning('没有符合条件的数据！')
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
				// 显示对话框窗口
				that.setPublisherVisible = true;
			},
			// 获取发布人
			getPublisherOptions() {
				var that = this;
				getPublisher(this.currentUserId).then((res) => {
					// console.log(res.data.pageList);
					if (res.code === 200) {
						let tempData = res.data.pageList;
						if (typeof tempData !== 'undefined' && tempData !== '') {
							that.options = []
							for (var i = 0; i < tempData.length; i++) {
								let tmp = {
									publisher: tempData[i].id,
									label: tempData[i].user_name
								}
								that.options.push(tmp)
							}
							that.options.sort((a, b) => a.label.localeCompare(b.label))
						} else {
							that.options = []
							that.$message.warning('没有符合条件的数据！')
						}
					} else {
						that.options = []
						that.$message.warning('没有符合条件的数据！')
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
			},
			// 验证图片和视频必须选择一个
			validateImgVideo(rule, value, callback) {
				let imgsEmpty = true;
				for (let i = 0; i < this.formAddDialog.imgs.length; i++) {
					if (this.formAddDialog.imgs[i].img !== '') {
						imgsEmpty = false;
					}
				};
				if (!this.formAddDialog.show_video && imgsEmpty) {
					callback(new Error('图片/视频需要选择一项'));
				} else {
					callback();
				}
			},
			validateModifyImgVideo(rule, value, callback) {
				let imgsEmpty = true;
				for (let i = 0; i < this.formModifyDialog.imgs.length; i++) {
					if (this.formModifyDialog.imgs[i].img !== '') {
						imgsEmpty = false;
					}
				};
				if (!this.formModifyDialog.show_video && imgsEmpty) {
					callback(new Error('图片/视频需要选择一项'));
				} else {
					callback();
				}
			},
			handleSetTop(id, istop) {
				if (typeof id == 'undefined' || id == '') {
					this.$message.error('id值无效！');
					return;
				}
				var that = this;
				setTop(id, istop).then((res) => {
					if (res.code === 200) {
						that.get_table_data('list')
						if (istop == 1) {
							that.$message.success('置顶成功！')
						} else {
							that.$message.success('取消置顶成功！')
						}
					} else {
						that.$message.warning(res.message)
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
			},
			// 全屏
			handleFullScreenChange() {
				if (!document.fullscreenElement) {
					// 退出全屏逻辑
					this.playering.pause()
				}
			},
			// 定义点击播放按钮，自动全屏化的方法
			full(e) {
				// 做兼容处理
				if (e.requestFullscreen) {
					e.requestFullscreen()
				} else if (e.mozRequestFullScreen) {
					e.mozRequestFullScreen()
				} else if (e.msRequestFullscreen) {
					e.msRequestFullscreen()
				} else if (e.oRequestFullscreen) {
					e.oRequestFullscreen()
				} else if (e.webkitRequestFullscreen) {
					e.webkitRequestFullScreen()
				} else {
					// var docHtml = document.documentElement;
					// var docBody = document.body;
					var videobox = document.getElementsByClassName('video-player')
					var cssText = 'width:100%;height:100%;overflow:hidden;'
					// docHtml.style.cssText = cssText;
					// docBody.style.cssText = cssText;
					videobox.style.cssText = cssText + ';' + 'margin:0px;padding:0px;'
					document.IsFullScreen = true
				}
			},
			/**
			 * 获取攻略记录,表格数据
			 */
			get_table_data(param) {
				this.loading = true
				this.get_condtion();

				let data = this.cond_data;
				if (param == 'search') {
					data.page = 1
					this.pagination.currentPage = 1
				}

				var that = this;
				// console.log(data);
				getTableData(data).then((res) => {
					// console.log(res.data.pageList);
					if (res.code === 200) {
						let tempData = res.data.pageList;
						if (typeof tempData !== 'undefined' && tempData !== '') {
							that.pagination.total = res.data.total
							that.tableData = []
							for (var i = 0; i < tempData.length; i++) {
								tempData[i].xuhao = (that.pagination.currentPage - 1) * that.pagination.pageSize + i + 1
								tempData[i].createDate = tempData[i].createDate.substring(0, tempData[i].createDate.length - 2)
								if (typeof tempData[i].video !== 'undefined') {
									let tmpOption = JSON.parse(JSON.stringify(that.videoOptions))
									tmpOption.sources[0].src = tempData[i].video
									tempData[i].video = tmpOption
								}
								that.tableData.push(tempData[i])
							}
						} else {
							that.tableData = []
							that.$message.warning('没有符合条件的数据！')
						}
					} else {
						that.tableData = []
						that.$message.warning('没有符合条件的数据！')
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
				that.loading = false;
			},
			getTown() {
				var that = this;
				getTown().then((res) => {
					if (res.code === 200) {
						that.formAddDialog.rtownOptions = res.data
						that.formModifyDialog.rtownOptions = res.data
					} else {
						that.$message.warning(res.message)
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
			},
			// 定义点击播放按钮，调用全屏化的方法
			onPlayerPlay(player) {
				// console.log('player play===>>>', player)
				this.playering = player
				this.full(player)
			},
			// 添加/修改 对话框单击上传图片
			openImageUploadDialog(index, param) {
				if (param == 'add') {
					if (this.addImgsUploadFileDisable == true) {
						this.$message.warning('图片 和 视频只能选其一');
						return;
					}
					this.formAddDialog.imgIndex = index;
					this.$refs.addImageUploadInput.click();
				} else if (param == 'modify') {
					if (this.modifyImgsUploadFileDisable == true) {
						this.$message.warning('图片 和 视频只能选其一');
						return;
					}
					this.formModifyDialog.imgIndex = index;
					this.$refs.modifyImageUploadInput.click();
				}
			},
			// 添加/修改 对话框单击上传视频
			openVideoUploadDialog(param) {
				if (param == 'add') {
					if (this.addVideoUploadFileDisable == true) {
						this.$message.warning('图片 和 视频只能选其一');
						return;
					}
					this.$refs.addVideoUploadInput.click();
				} else if (param == 'modify') {
					if (this.modifyVideoUploadFileDisable == true) {
						this.$message.warning('图片 和 视频只能选其一');
						return;
					}
					this.$refs.modifyVideoUploadInput.click();
				}
			},
			// 修改对话框单击上传详情图
			openImageDetailUploadDialog_modify() {
				this.$refs.modifyImageDetailUploadInput.click();
			},
			// 攻略新增上传文件
			uploadImageVideo(event, imgOrVideo, index) {
				// 点击取消,长度为0
				if (event.target.files.length == 0)
					return;

				const file = event.target.files[0];
				const key = `/uploads/gonglue/${new Date().getTime()}`; // 设置上传到 COS 后的文件名
				var that = this
				const cos = new COS(that.cosVal);
				cos.putObject({
						Bucket: "jinganminsu-1320402385",
						Region: "ap-nanjing",
						Key: key,
						Body: file,
					},
					function(err, data) {
						if (err) {
							// console.error(err);
							that.$message.error(err);
							if (imgOrVideo == 'img') {
								that.$set(that.formAddDialog.imgs[index], 'img', '')
							} else {
								that.$set(that.formAddDialog, 'video', '')
							}
							return;
						} else {
							// console.log(data);
							if (!isEmpty(`${data.Location}`)) {
								if (imgOrVideo == 'img') {
									that.$set(that.formAddDialog.imgs[index], 'img', `https://${data.Location}`)
								} else {
									var tmpOption = that.videoOptions
									tmpOption.sources[0].src = `https://${data.Location}`
									that.$set(that.formAddDialog, 'show_video', tmpOption)
									that.$set(that.formAddDialog, 'post_video', `https://${data.Location}`)
								}
							} else {
								if (imgOrVideo == 'img') {
									that.$set(that.formAddDialog.imgs[index], 'img', '')
								} else {
									that.$set(that.formAddDialog, 'show_video', '')
								}
							}
						}
						event.target.value = null;
						that.onlyOneFileClass('add');
					}
				);
			},
			// 添加攻略时，只能添加图片或视频中的一种，不能两个同时上传
			onlyOneFileClass(param) {
				if (param == 'add') {
					let imgsEmpty = true;
					let tmpImgs = this.formAddDialog.imgs;
					for (let i = 0; i < tmpImgs.length; i++) {
						if (tmpImgs[i].img !== '') {
							imgsEmpty = false;
						}
					};
					if (!imgsEmpty) {
						this.addVideoUploadFileDisable = true;
					} else {
						this.addVideoUploadFileDisable = false;
					}
					if (this.formAddDialog.show_video) {
						this.addImgsUploadFileDisable = true;
					} else {
						this.addImgsUploadFileDisable = false;
					}
				} else {
					let imgsEmpty = true;
					let tmpImgs = this.formModifyDialog.imgs;
					for (let i = 0; i < tmpImgs.length; i++) {
						if (tmpImgs[i].img !== '') {
							imgsEmpty = false;
						}
					};
					if (!imgsEmpty) {
						this.modifyVideoUploadFileDisable = true;
					} else {
						this.modifyVideoUploadFileDisable = false;
					}
					if (this.formModifyDialog.show_video) {
						this.modifyImgsUploadFileDisable = true;
					} else {
						this.modifyImgsUploadFileDisable = false;
					}
				}
			},
			// 攻略修改上传文件
			uploadModifyImageVideo(event, imgOrVideo, index) {
				// 点击取消,长度为0
				if (event.target.files.length == 0)
					return;

				const file = event.target.files[0];
				const key = `/uploads/gonglue/${new Date().getTime()}`; // 设置上传到 COS 后的文件名
				var that = this
				const cos = new COS(this.cosVal);
				cos.putObject({
						Bucket: "jinganminsu-1320402385",
						Region: "ap-nanjing",
						Key: key,
						Body: file,
					},
					function(err, data) {
						if (err) {
							// console.error(err);
							that.$message.error(err);
							if (imgOrVideo == 'img') {
								that.$set(that.formModifyDialog.imgs[index], 'img', '')
							} else {
								that.$set(that.formModifyDialog, 'show_video', '')
							}
							return;
						} else {
							// console.log(data);
							if (!isEmpty(`${data.Location}`)) {
								if (imgOrVideo == 'img') {
									that.$set(that.formModifyDialog.imgs[index], 'img', `https://${data.Location}`)
								} else {
									var tmpOption = this.videoOptions
									tmpOption.sources[0].src = `https://${data.Location}`
									that.$set(that.formModifyDialog, 'show_video', tmpOption)
									that.$set(that.formModifyDialog, 'post_video', `https://${data.Location}`)
								}
							} else {
								if (imgOrVideo == 'img') {
									that.$set(that.formModifyDialog.imgs[index], 'img', '')
								} else {
									that.$set(that.formModifyDialog, 'show_video', '')
								}
							}
						}
						event.target.value = null;
						that.onlyOneFileClass('modify');
					}
				);
			},
			// 删除本地显示的图片或视频
			del_local_display_img(param, index) {
				if (param === 'formAddDialog.img') {
					this.$set(this.formAddDialog.imgs[index], 'img', '');
				} else if (param === 'formAddDialog.show_video') {
					this.$set(this.formAddDialog, 'show_video', '');
				} else if (param === 'formModifyDialog.img') {
					this.$set(this.formModifyDialog.imgs[index], 'img', '');
				} else if (param === 'formModifyDialog.show_video') {
					this.$set(this.formModifyDialog, 'show_video', '');
					this.$set(this.formModifyDialog, 'post_video', '');
				}
				this.onlyOneFileClass('add');
			},
			// 获取民宿ids
			getHotelIds(index, id) {
				this.formAddDialog.hotelNames[index].checked = !this.formAddDialog.hotelNames[index].checked;
				if (this.formAddDialog.hotelNames[index].checked == true) {
					this.formAddDialog.hotelIds.push(id);
				} else {
					let newArr = this.formAddDialog.hotelIds.filter(item => item !== id);
					this.formAddDialog.hotelIds = newArr;
				}
			},
			// 获取修改民宿ids
			getModifyHotelIds(index, id) {
				this.formModifyDialog.hotelNames[index].checked = !this.formModifyDialog.hotelNames[index].checked;
				if (this.formModifyDialog.hotelNames[index].checked == true) {
					this.formModifyDialog.hotelIds.push(id);
				} else {
					let newArr = this.formModifyDialog.hotelIds.filter(item => item !== id);
					this.formModifyDialog.hotelIds = newArr;
				}
			},
			// 添加地点，选择乡镇后显示民宿
			handleAddAdressStrategy() {
				var that = this;
				if (this.formAddDialog.rtownId !== '') {
					getHotels(this.formAddDialog.rtownId).then((res) => {
						// console.log(res);
						if (res.code == 200) {
							that.formAddDialog.showHotels = true;
							for (let i = 0; i < res.data.pageList.length; i++) {
								res.data.pageList[i].checked = false;
							}
							that.formAddDialog.hotelNames = res.data.pageList;
						} else {
							that.$message.error(res.message)
						}
					})
				}
			},
			// 编辑地点，选择乡镇后显示民宿
			handleModifyAdressStrategy(param) {
				var that = this;
				if (that.formModifyDialog.rtownId !== '') {
					getHotels(that.formModifyDialog.rtownId).then((res) => {
						// console.log(res);
						if (res.code == 200) {
							let tmpdata = res.data.pageList;
							that.formModifyDialog.showHotels = true;
							if (param == 'change') {
								that.$set(that.formModifyDialog, 'hotelIds', [])
								for (let i = 0; i < tmpdata.length; i++) {
									tmpdata[i].checked = false;
								}
							} else {
								for (let i = 0; i < tmpdata.length; i++) {
									let mhotelIds = that.formModifyDialog.hotelIds;
									let tf = false;
									for (let j = 0; j < mhotelIds.length; j++) {
										if (tmpdata[i].id == mhotelIds[j]) {
											tf = true;
										}
									}
									tmpdata[i].checked = tf;
								}
							}
							that.formModifyDialog.hotelNames = tmpdata;
						} else {
							that.$message.error(res.message)
						}
					})
				}
			},
			// 添加攻略
			handleAddStrategy() {
				var that = this;
				var v = true;
				this.$refs.addDialogForm.validate(valid => {
					if (valid == false) {
						v = false;
					}
				});
				if (v == false || that.formAddDialog.rtownId == '' || that.formAddDialog.hotelIds.length == 0) {
					return;
				}
				that.formAddDialog.create_id = this.formAddDialog.publisher;
				var data = that.formAddDialog;
				insertStrategy(data).then((res) => {
					// console.log(res);
					if (res.code == 200) {
						that.get_table_data('list')
						that.dialogAddStrategyVisible = false
						that.$message.success('攻略添加成功！')
						that.resetFormAddDialog();
					} else {
						that.$message.error(res.message)
					}
				})
			},
			// 重置添加表单
			resetFormAddDialog() {
				this.formAddDialog = {
					title: '',
					publisher: '',
					content: '',
					rtownId: '',
					rtownOptions: this.formAddDialog.rtownOptions,
					hotelIds: [],
					hotelNames: [],
					showHotels: false,
					imgIndex: '',
					imgs: [{
						id: 1,
						img: ''
					}, {
						id: 2,
						img: ''
					}, {
						id: 3,
						img: ''
					}, {
						id: 4,
						img: ''
					}, {
						id: 5,
						img: ''
					}, {
						id: 6,
						img: ''
					}, {
						id: 7,
						img: ''
					}, {
						id: 8,
						img: ''
					}, {
						id: 9,
						img: ''
					}],
					show_video: '',
					post_video: '',
					create_id: '',
					istop: false
				}
			},
			// 编辑攻略
			handleModifyStrategy() {
				var that = this;
				var v = true;
				this.$refs.modifyDialogForm.validate(valid => {
					if (valid == false) {
						v = false;
					}
				});
				if (v == false || that.formModifyDialog.rtownId == '' || that.formModifyDialog.hotelIds.length == 0) {
					return;
				}
				that.formModifyDialog.create_id = this.formModifyDialog.publisher;
				var data = that.formModifyDialog;
				updateStrategy(data).then((res) => {
					// console.log(res);
					if (res.code == 200) {
						that.get_table_data('list')
						that.dialogModifyVisible = false
						that.$message.success('攻略修改成功！')
						that.resetFormModifyDialog();
					} else {
						that.$message.error(res.message)
					}
				});
			},
			// 重置修改表单变量
			resetFormModifyDialog() {
				this.formModifyDialog = {
					id: '',
					title: '',
					publisher: '',
					content: '',
					rtownId: '',
					rtownOptions: this.formModifyDialog.rtownOptions,
					hotelIds: [],
					hotelNames: [],
					showHotels: false,
					imgIndex: '',
					imgs: [{
						id: 1,
						img: ''
					}, {
						id: 2,
						img: ''
					}, {
						id: 3,
						img: ''
					}, {
						id: 4,
						img: ''
					}, {
						id: 5,
						img: ''
					}, {
						id: 6,
						img: ''
					}, {
						id: 7,
						img: ''
					}, {
						id: 8,
						img: ''
					}, {
						id: 9,
						img: ''
					}],
					show_video: '',
					post_video: '',
					istop: false
				}
			},
			/**
			 * 新增攻略
			 */
			add_strategy() {
				this.dialogAddStrategyVisible = true;

				this.resetFormAddDialog();
			},
			/**
			 * 打开编辑攻略
			 * @param {Object} row
			 */
			handleModifyClick(row) {
				//console.log(row);
				this.resetFormModifyDialog();

				this.$set(this.formModifyDialog, 'id', row.id)
				this.$set(this.formModifyDialog, 'title', row.title)
				this.$set(this.formModifyDialog, 'publisher', row.userId)
				this.$set(this.formModifyDialog, 'rtownId', row.townId)
				let strArray = row.hotelId.split(',');
				let numArray = strArray.map(Number);
				this.$set(this.formModifyDialog, 'hotelIds', numArray)

				this.handleModifyAdressStrategy('none');

				this.$set(this.formModifyDialog, 'content', row.content)
				if (typeof row.image !== 'undefined') {
					let imgs = row.image;
					for (let i = 0; i < imgs.length; i++) {
						if (imgs[i] !== '') {
							this.$set(this.formModifyDialog.imgs[i], 'img', imgs[i])
						}
					}
				}
				if (row.isTop == 1) {
					this.$set(this.formModifyDialog, 'istop', true)
				} else {
					this.$set(this.formModifyDialog, 'istop', false)
				}

				if (typeof row.video !== 'undefined') {
					var tmpOption = JSON.parse(JSON.stringify(row.video));
					this.$set(this.formModifyDialog, 'show_video', tmpOption)
					this.$set(this.formModifyDialog, 'post_video', row.video.sources[0].src)
				}

				this.onlyOneFileClass('modify');

				this.dialogModifyVisible = true
			},
			/**
			 * 显示删除攻略
			 */
			handleDelClick(row) {
				this.delStrategyId = row.id;
				this.dialogDeleteVisible = true;
			},
			/**
			 * 删除攻略记录
			 */
			dialogDeleteStrategy() {
				var that = this;
				delStrategy(that.delStrategyId).then((res) => {
					// console.log(res);
					if (res.code == 200) {
						that.get_table_data('list');
						that.dialogDeleteVisible = false;
						that.$message.success('攻略删除成功！');
					} else {
						that.$message.error(res.message);
					}
				});
			},
			/**
			 * 查询条件
			 */
			get_condtion() {
				let data = {
					page: this.pagination.currentPage,
					rows: this.pagination.pageSize
				}

				if (this.formInline.key !== '') {
					data.key = this.formInline.key
				}

				this.cond_data = data;
			},
			/**
			 * 搜索
			 */
			btn_search() {
				this.get_table_data('search')
			},
			/**
			 * currentPage 改变时会触发
			 * @param {Object} val
			 */
			currentPageChange(val) {
				this.pagination.currentPage = val
				this.get_table_data('pages')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.app-container {
		background-color: #EFF2F7;
		padding: 10px;

		.el-row {

			.el-col {
				padding: 10px;

				.cell {
					padding: 30px;
					border-radius: 10px;
					background-color: #FFFFFF;
					box-shadow: 0px 3px 21px 0px rgba(60, 108, 254, 0.16);

					.cell-title {
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin-bottom: 30px;
						padding-bottom: 30px;
						border-bottom: 1px solid #CCCCCC;

						.title-left {
							display: flex;
							align-items: center;

							.title {
								font-size: 22px;
								font-family: Microsoft YaHei-3970(82674968);
								font-weight: bold;
								color: #1A202B;
							}

							.title-detail {
								margin-left: 50px;
								font-size: 18px;
								font-family: Microsoft YaHei-3970(82674968);
								color: #1A202B;
							}
						}

						.title-right {
							display: flex;
							justify-content: space-between;
							align-items: center;

							.el-button {
								width: 110px;
								height: 46px;
								background: #2B4CFE;
								font-size: 18px;
								color: #FFFFFF;
								font-family: Microsoft YaHei-3970(82674968);
								border-radius: 5px;
							}

							.el-button--warning {
								background: #F88A64;
							}
						}
					}

					.cell-body {

						.controls {
							display: flex;
							justify-content: space-between;
							align-items: center;

							.demo-form-inline {
								display: inline-flex;
								flex-wrap: wrap;
								align-items: center;
								justify-content: flex-start;

								.btn-search {
									background: rgba(9, 101, 98, 1);
									font-size: 14px;
									color: #FFFFFF;
									font-family: Microsoft YaHei-3970(82674968);
									border-radius: 5px;
									border: none;
								}
							}

							.export {
								background: rgba(9, 101, 98, 1);
								font-size: 14px;
								color: #FFFFFF;
								font-family: Microsoft YaHei-3970(82674968);
								border-radius: 5px;
								margin-bottom: 22px;
								border: none;
							}
						}

						.pagination-table {
							display: flex;
							justify-content: flex-end;
							align-items: center;
							height: 30px;
							margin-top: 20px;

							.txt-notice {

								span {
									font-size: 28px;
									font-weight: 500;
									font-family: '微软雅黑';
								}
							}

							::v-deep .el-pagination {
								display: flex;
								justify-content: flex-end;
								align-items: center;
							}

							::v-deep .el-pagination ul {
								display: flex;

							}

							::v-deep .el-pagination button,
							::v-deep .el-pagination li {
								display: flex;
								justify-content: center;
								align-items: center;
								width: 50px;
								height: 36px;
								border: 1px solid #626262;
								border-radius: 3px;
								font-size: 14px;
								margin: 0 5px;
							}

							::v-deep .el-pagination span {
								margin-left: 10px;
							}

							::v-deep .el-pagination .el-pagination__jump {
								font-size: 16px;
							}

							::v-deep .el-pagination .el-pagination__editor {
								width: 50px;
								height: 36px;
								margin: 0 5px;
							}

							::v-deep .el-pagination .el-input__inner {
								width: 50px;
								height: 36px;
								border: 1px solid #626262;
								margin: -4px 0 0 0;
							}
						}
					}
				}
			}
		}

		::v-deep .el-dialog {
			margin: 0 !important;
			width: 600px;
			height: 560px;
			background: #FFFFFF;
			box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
			border-radius: 6px;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

			.el-dialog__header {
				display: flex;
				align-items: center;
				width: 100%;
				height: 58px;
				padding: 30px;
				border-radius: 6px 6px 0px 0px;
				font-weight: bold;
				border-bottom: 1px solid rgba(230, 230, 230, 1);
			}

			.el-dialog__body {
				padding-bottom: 0;

				.el-form-item__label,
				.el-form-item__content {
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #53575A;
				}
			}

			// 删除对话框的样式
			.del-account-body {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				height: 180px;

				img {
					width: 72px;
				}

				.del-account-body-txt {
					height: 58px;
					line-height: 58px;
					font-size: 18px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #333333;
				}
			}

			.el-dialog__footer {
				padding-bottom: 0 !important;
				text-align: center;

				.el-button.el-button--default {
					width: 75px;
					height: 40px;
					border: 1px solid #2B4CFE;
					border-radius: 6px;
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #2B4CFE;
				}

				.el-button.el-button--primary {
					width: 75px;
					height: 40px;
					background: #2B4CFE;
					border-radius: 6px;
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #FFFFFF;
					margin-left: 60px;
				}
			}
		}
	}
</style>

<style>
	.perimeter-class {
		width: 900px !important;
		height: 760px !important;
	}

	.el-date-editor--daterange.el-input__inner {
		width: 280px !important;
	}

	.demo-table-expand {
		font-size: 0;
	}

	.demo-table-expand label {
		width: 180px;
		color: #99a9bf;
	}

	.demo-table-expand .el-form-item {
		margin-right: 0;
		margin-bottom: 0;
		width: 33%;
	}

	.show-imgs {
		display: flex;
	}

	.imgs {
		display: flex;
		flex-direction: row;
		margin-left: 20px;
	}

	.lbl-cls {
		display: inline-block;
		width: 100px;
		text-align: right;
		padding-right: 10px;
		color: #bbb;
	}

	.export {
		background: rgba(9, 101, 98, 1) !important;
		font-size: 14px !important;
		color: #FFFFFF !important;
		font-family: Microsoft YaHei-3970(82674968);
		border-radius: 5px !important;
		margin-bottom: 22px !important;
		border: none !important;
	}

	.add-class {
		height: 450px !important;
		width: 800px !important;
	}

	.dialog-footer {
		display: flex;
		justify-content: flex-end;
	}

	.add-info-cancel-btn {
		color: rgba(9, 101, 98, 1) !important;
		border: 1px solid rgba(9, 101, 98, 1) !important;
	}

	.add-info-confirm-btn {
		border: none !important;
		background: rgba(9, 101, 98, 1) !important;
		color: #fff !important;
		border-radius: 5px !important;
		margin-left: 28px !important;
	}

	.el-form-item>label {
		color: rgba(128, 128, 128, 1) !important;
	}

	.custom-input {
		width: 7rem !important;
	}

	.custom-input input {
		width: 7rem !important;
	}

	.el-radio {
		margin-right: 10px;
	}

	.el-form-item {
		margin-bottom: 16px !important;
	}

	.add-dlg-class {
		width: 830px !important;
		height: 850px !important;
	}

	.el-carousel__indicators {
		display: none !important;
	}

	.el-tabs__item {
		width: 100px !important;
		text-align: center !important;
		font-size: 20px !important;
	}


	.el-tabs__item.is-active,
	.el-tabs__item:hover {
		color: rgba(9, 101, 98, 1) !important;
	}

	.el-tabs__active-bar {
		color: rgba(9, 101, 98, 1) !important;
		background-color: rgba(9, 101, 98, 1) !important;
	}

	.el-dialog-delete-account {
		height: 300px !important;
		width: 500px !important;
	}

	.el-dialog-delete-account .el-dialog__header {
		display: none !important;
	}

	.add-user-cancel-btn {
		color: rgba(9, 101, 98, 1) !important;
		border: 1px solid rgba(9, 101, 98, 1) !important;
	}

	.add-user-confirm-btn {
		border: none !important;
		background: rgba(9, 101, 98, 1) !important;
		color: #fff !important;
		border-radius: 5px !important;
		margin-left: 28px !important;
	}

	.ql-container {
		height: 150px;
	}

	.add-strategy-img {
		display: flex;
		justify-content: space-between;
		flex-flow: row wrap;
	}

	.add-strategy-img-box {
		position: relative;
		margin: 0 0 10px 0;
		width: 128px;
		height: 128px;
		border: dashed 1px #096562;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		border-radius: 5px;
		cursor: pointer;
	}

	.add-strategy-img-box-video {
		position: relative;
		margin: 0 0 10px 0;
		width: 128px;
		height: 128px;
		border: dashed 1px #096562;
		border-radius: 5px;
		cursor: pointer;
		border: 2px dashed #ff4949;
	}

	.add-strategy-img-plus {
		color: #096562;
		font-size: 30px;
		height: 30px;
		line-height: 30px;
	}

	.add-strategy-img-txt {
		color: #096562;
	}

	.add-strategy-img-clear {
		position: absolute;
		top: 5px;
		right: 5px;
		width: 22px;
		height: 22px;
		background: rgba(9, 108, 98, 1.0);
		border-radius: 50%;
		font-size: 22px;
		color: #fff;
		cursor: pointer;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.scroll-container::-webkit-scrollbar {
		width: 1px;
		/* 根据需要调整滚动条的宽度 */
	}

	.scroll-container::-webkit-scrollbar-track {
		background-color: #ccc;
		/* 设置滚动条轨道的颜色 */
	}

	.scroll-container::-webkit-scrollbar-thumb {
		background-color: rgba(9, 101, 98, 1);
		/* 设置滚动条滑块的颜色 */
	}

	.hotel-box {
		display: flex;
		align-items: center;
		margin: 5px 0;
		padding: 5px;
		cursor: pointer;
		border-radius: 5px;
		border: 1px solid #096562;
	}

	.hotel-box-txt {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		align-items: flex-start;
		font-size: 16px;
		padding: 10px;
	}

	.hotel-list {
		width: 186px;
		text-align: left;
		line-height: 1.2em;
	}

	.bg-color {
		color: #FFFFFF;
		background-color: #096562;
	}

	.configure-btn-position {
		display: flex;
		justify-content: flex-end;
	}

	.configure-btn {
		border: none !important;
		background: rgba(9, 101, 98, 1) !important;
		color: #fff !important;
		border-radius: 5px !important;
	}

	.action-btns {
		display: flex;
		justify-content: space-around;

	}

	.bg-btn {
		color: rgba(9, 101, 98, 1);
	}

	.add-ms-class {
		width: 400px !important;
		height: 280px !important;
	}

	.add-ms-class .el-input__inner {
		width: 220px !important;
	}
</style>