<template>
	<view class="">
		<view class="y-start container">
			<view class="mt40">
				营期名称
			</view>
			<view class="box" @click="selectCourseTypeShowFun()">
				{{!courseName?'请选择营期名称':courseName}}
			</view>
			<template v-if="params.periodId">
				<view class="mt40">
					课程小节名称
				</view>
				<view class="box" @click="selectCourseShowFun()">
					{{!params.courseName?'请选择课程小节':params.courseName}}
				</view>
			</template>
			<view class="u-f u-f-jsb u-f-ac mt40">
				<view class=" mr20">
					自动催课
				</view>
				<u-radio-group v-model="params.isUrgeCourse" @change="groupChange" placement="row">
					<u-radio class="mr20" label="是" :name="true"></u-radio>
					<u-radio label="否" :name="false"></u-radio>
				</u-radio-group>
			</view>
			<view class="box" @click="selectTime(2)" v-if="params.isUrgeCourse">
				{{!params.urgeTime?'请选择发课时间':params.urgeTime && getDetaFun(params.urgeTime)}}
			</view>
			<view class="mt40">
				发送标题
			</view>
			<u--input class="mt20 input" placeholder="请输入标题" border="surround" v-model="params.title"></u--input>
			<template v-if="params.isUrgeCourse">
				<view class="mt40">
					催课文案
				</view>
				<u--textarea class="mt20 textarea" placeholder="请输入文案" v-model="params.urgeContent"></u--textarea>
			</template>
			<view class="u-f u-f-jsb u-f-ac mt40">
				<view class=" mr20">
					发送方式
				</view>
				<u-radio-group v-model="params.sendType" @change="sendChange" placement="row">
					<u-radio class="mr20" label="定时发送" :name="1"></u-radio>
					<u-radio label="实时发送" :name="2"></u-radio>
				</u-radio-group>
			</view>
			<view class="box" v-if="params.sendType && params.sendType==1" @click="selectTime(1)">
				{{!params.sendTime?'请选择发送时间':params.sendTime && getDetaFun(params.sendTime)}}
			</view>
			<view class="u-f u-f-jsb u-f-ac mt40">
				<view class=" mr20">
					接收主体
				</view>
				<u-radio-group v-model="recipientType" @change="recipientTypeChange" placement="row">
					<u-radio class="mr20" label="标签" :name="1"></u-radio>
					<u-radio label="会员" :name="2"></u-radio>
				</u-radio-group>
			</view>
			<template v-if="recipientType==1">
				<view class="box" @tap="selectTagFun('refresh')" v-if="selectTagList.length<=0">
					请选择标签
				</view>
				<view class="tagbox mt20 " @tap="selectTagFun('refresh')" v-else>
					<view class="" v-for="(item, index) in selectTagList" :key="item.tagId">
						<u-tag :text="item.tag" plain plainFill :show="item.checked" closable
							@close="deleteTag(index)"></u-tag>
					</view>
				</view>
			</template>
			<template v-if="recipientType==2">
				<view class="box" @tap="selectUserFun()" v-if="selectUserList.length<=0">
					请选择会员
				</view>
				<view class="tagbox mt20" @tap="selectUserFun()" v-else>
					<view class="es-mr-10" v-for="(item, index) in selectUserList" :key="item.userId">
						<u-tag :text="item.nickname" plain plainFill :show="item.checked"></u-tag>
					</view>
				</view>
			</template>
		</view>
		<view class="mt20 button mt20" @click="submitBatchSendCourse">
			<u-button type="primary" text="保存"></u-button>
		</view>
		<u-popup :show="selectCourseShow" :closeOnClickOverlay="true" :round='10' @close="closePopup"
			:safeAreaInsetTop="true" mode="bottom">
			<view class="container-right popbox">
				<view class="popbox-head">
					<u-icon class="close-circle" name="close-circle" color="#ccc" size="24"
						@click="closePopup"></u-icon>
					选择课程
				</view>
				<view class="justify-between align-center mb20 mlr20 ">
					<u-search placeholder="请输入课程名称" v-model="keyword" :showAction="false" height="30px"
						style="width:100%" @search='gettodaylist' @change="searchKeywordCourseList"></u-search>
				</view>
				<scroll-view style="height:44vh;margin-top: 20rpx;" :scroll-y="true" :refresher-enabled="isEnableds"
					:refresher-triggered="triggered" refresher-background="rgba(0,0,0,0)" :scroll-top='scrollTop'
					@refresherrestore="triggered = false" :upper-threshold="100" :lower-threshold="100"
					@refresherabort="triggered = false">
					<view class="list">
						<courseItem :from="'course'" :activeTab="1" :sourceType="'createTask'"
							v-for="(item,index) in dataList" :key="index" :info="item" @courseClick="courseClick(item)"
							@retime='reflashtime' />
						<u-loadmore :status="loadStatus" />
						<view class="h120"></view>
					</view>
				</scroll-view>
			</view>
		</u-popup>
		<u-datetime-picker :show="timeShow" v-model="defaultTime" @confirm="confirmTime" mode="datetime"
			:minDate="new Date().getTime()" :closeOnClickOverlay="true" @close="timeShow = false"
			@cancel="timeShow = false"></u-datetime-picker>
		<u-popup :show="showPop" :round="12" @close="closePopup" class="model" :zIndex="10076" style="flex: 0;">
			<view class="popbox">
				<view class="popbox-head">
					<u-icon class="close-circle" name="close-circle" color="#ccc" size="24"
						@click="closePopup"></u-icon>
					标签筛选
				</view>
				<view class="popbox-body">
					<view class="mb20">
						<u-search placeholder="请输入标签  多个标签用 , 隔开" v-model="keyword" :showAction="false" height="30px"
							@search="gettaglist" @change="searchKeywordTag"></u-search>
					</view>
					<scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds"
						:refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)"
						@refresherrestore="triggereds = false" :upper-threshold="100" :lower-threshold="100"
						@refresherabort="triggereds = false">
						<view class="tagbox-list x-f" style="white-space: nowrap;flex-wrap: wrap;">
							<view class="base-color-red fs24 bor-red p8 radius8 plr12" v-if="columnsa.length<=0">暂无标签
							</view>
							<view class="mlr10 mb10" v-for="(item,index) in columnsa" :key='item.tagId'>
								<u-tag :text="item.tag"
									:plain="(!params.tagIds || params.tagIds && !params.tagIds.includes(item.tagId))"
									:name="index" @click="chooseTag(index)"></u-tag>
							</view>
						</view>
						<view class="center fs24 mt20">
							<text class="mr20" @click="getTagpage('last','tag')">上一页</text>
							<text class="base-color-red">{{pagetag.pageNum}}/{{pagetag.pages}}</text>
							<text class="ml20" @click="getTagpage('next','tag')">下一页</text>
						</view>
					</scroll-view>
				</view>
				<view class="popbox-footer x-bc">
					<button class="popbox-footer-btn" @click="resetTag">重置</button>
					<button class="popbox-footer-btn con-btn" @click="confirmPop">确定</button>
				</view>
			</view>
		</u-popup>
		<u-popup :show="showvip" @close="closePopup">
			<view class="popbox">
				<view class="popbox-head">
					<u-icon class="close-circle" name="close-circle" color="#ccc" size="24"
						@click="closePopup"></u-icon>
					选择会员
				</view>
				<view class="popbox-body">
					<view class="mb20">
						<u-search placeholder="请输入会员昵称" v-model="keyword" :showAction="false" height="30px"
							@search="gettagUserlist" @change="searchKeyword"></u-search>
					</view>
					<view class="u-f u-f-ac" @tap="selectTagFun('refresh')">
						<view :class="[selectTagList && selectTagList.length>0 ?'mr20':'']">
							选择标签
						</view>
						<view class="u-f" v-if="selectTagList && selectTagList.length>0">
							<view class="" v-for="(item, index) in selectTagList" :key="item.tagId">
								<u-tag :text="item.tag" plain plainFill :show="item.checked" closable
									@close="deleteTag(index)"></u-tag>
							</view>
						</view>
						<view v-if="selectTagList.length<=0">
							<u-icon name="arrow-right" size="12"></u-icon>
						</view>
					</view>
					<scroll-view scroll-y="true" class="hb mt20" :refresher-enabled="isEnableds"
						:refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)"
						@refresherrestore="triggereds = false" :upper-threshold="100" :lower-threshold="300"
						@refresherabort="triggereds = false" @scrolltolower="reachBottom"
						@refresherrefresh="pullDownRefresh">
						<view class="tagbox-list x-f" style="white-space: nowrap;flex-wrap: wrap;">
							<view class="base-color-red fs24 bor-red p8 radius8 plr12" v-if="tagsuserlist.length<=0">
								暂无会员
							</view>
							<view class="mlr10 mb10" v-for="(item,index) in tagsuserlist" :key='item.userId'>
								<u-tag :text="item.nickname"
									:plain="(!params.userIds || params.userIds && !params.userIds.includes(item.userId))"
									:name="index" @click="checkboxClick(index)"></u-tag>
							</view>
						</view>
						<view class="center fs24 mt20">
							<text class="mr20" @click="getTagpage('last','user')">上一页</text>
							<text class="base-color-red">{{pagetag.pageNum}}/{{pagetag.pages}}</text>
							<text class="ml20" @click="getTagpage('next','user')">下一页</text>
						</view>
					</scroll-view>
				</view>
				<view class="popbox-footer x-bc">
					<button class="popbox-footer-btn" @click="resetUser">重置</button>
					<button class="popbox-footer-btn con-btn" @click="getuserid">确定</button>
				</view>
			</view>
		</u-popup>
		<u-popup :show="courseTypeShow" @close="closePopup">
			<view class="popbox">
				<view class="popbox-head">
					<u-icon class="close-circle" name="close-circle" color="#ccc" size="24"
						@click="closePopup"></u-icon>
					选择营期
				</view>
				<view class="popbox-body">
					<view class="mb20">
						<u-search placeholder="搜索课程" v-model="keyword" :showAction="false" height="30px"
							style="width:100%" @search="getFsCourseList('refresh')"
							@change="searchKeywordCourse"></u-search>
					</view>
					<scroll-view scroll-y="true" class="hb" :refresher-enabled="isEnableds"
						:refresher-triggered="triggereds" refresher-background="rgba(0,0,0,0)"
						@refresherrestore="triggereds = false" :upper-threshold="100" :lower-threshold="100"
						@refresherabort="triggereds = false">
						<view class="tagbox-list x-f" style="white-space: nowrap;flex-wrap: wrap;">
							<view class="base-color-red fs24 bor-red p8 radius8 plr12" v-if="courseList.length<=0">
								暂无课程
							</view>
							<view class="mlr10 mb10" v-for="(item,index) in courseList" :key='item.userId'>
								<u-tag :text="item.periodName"
									:plain="(searchCourseIdStorage && searchCourseIdStorage.periodId || !searchCourseIdStorage && searchCourseId) != item.periodId"
									:name="index" @click="handleCourse(item,index)"></u-tag>
							</view>
						</view>
						<view class="center fs24 mt20">
							<text class="mr20" @click="getTagpage('last','courseType')">上一页</text>
							<text class="base-color-red">{{pagetag.pageNum}}/{{pagetag.pages}}</text>
							<text class="ml20" @click="getTagpage('next','courseType')">下一页</text>
						</view>
					</scroll-view>
				</view>
				<view class="popbox-footer x-bc">
					<button class="popbox-footer-btn" @click="searchReset">重置</button>
					<button class="popbox-footer-btn con-btn" @click="searchConfirm">确定</button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		ca
	} from "date-fns/locale"
	import {
		batchSendCourse
	} from "./api/courseManage.js"
	import {
		getallTags,
		getFsCourseList,
		getCourseVdieoList,
		getfsuserList
	} from "./api/manageCompany.js"
	import courseItem from "./components/courseItem.vue"
	import dropdownPanel from "./components/dropdownPanel.vue"
	export default {
		components: {
			courseItem,
			dropdownPanel
		},
		data() {
			return {
				courseTypeShow: false,

				columnsa: [], //标签
				showPop: false,
				groupid: 0,
				pagetag: [],
				usertag: [],

				showvip: false, //会员
				tagsuserlist: [],
				userName: [],

				triggereds: false,
				defaultTime: Number(new Date()),
				timeShow: false,
				isUrgeClasses: '',
				selectCourseShow: false,
				dataList: [],
				triggered: false,
				loadStatus: 'loadmore',
				parameter: {
					pageNum: 1,
					pageSize: 10
				},
				scrollTop: 0,
				isEnableds: true,
				urgeClassesText: '',
				searchCourseId: null,
				searchCourseIdStorage: null,
				courserIndex: null,
				courseName: '',
				params: {
					userIds: [],
					companyUserId: 0,
					companyId: 0,
					periodId: 0,
					courseId: 0,
					courseName: '',
					videoId: 0,
					videoName: '',
					tagIds: [],
					tagNames: [],
					sendTime: '',
					sendType: 1,
					sendMode: 1,
					title: '',
					effectiveDuration: 0,
					id: 0,
					url: '',
					projectId: 0,
					isUrgeCourse: true,
					urgeTime: 0,
					urgeContent: ''
				},
				keyword: '',
				courseList: [],
				courseItme: '',
				pagetag: [],
				timer: null,
				recipientType: 1,
				selectUserList: [],
				selectTagList: [],
				searchTagIds: [],
				searchTagName: [],
				timeType: 0,
			}
		},
		onLoad(params) {
			if (params.title) {
				uni.setNavigationBarTitle({
					title: params.title
				});
			}
			let courseItemArr = uni.getStorageSync('courseItemArr')
			if (courseItemArr) {
				this.courseClick(courseItemArr)
				uni.removeStorageSync('courseItemArr')
			}
		},
		onShow() {
			uni.$on('selectUserData', (res) => {
				this.selectUserList = res
			})
		},
		mounted() {
			let companyUserInfo = uni.getStorageSync('companyUserInfo')
			companyUserInfo = JSON.parse(companyUserInfo)
			this.params.companyId = companyUserInfo.companyId
			this.params.companyUserId = companyUserInfo.userId
		},
		methods: {
			searchConfirm() {
				if (this.searchCourseIdStorage) {
					this.courseName = this.searchCourseIdStorage.periodName
					this.searchCourseId = this.searchCourseIdStorage.periodId
				}
				this.gettodaylist()
				this.keyword = ''
				this.courseTypeShow = false
				this.selectCourseShow = true
			},
			searchReset() {
				this.keyword = ''
				this.courserIndex = this.searchCourseIdStorage = null
			},
			handleCourse(item, index) {
				this.courserIndex = index
				this.searchCourseIdStorage = item
			},
			selindex(e) {
				this.params.pageNum = 1
				this.keyword = ''
				this.getFsCourseList('refresh')
			},
			checkboxClick(name) {
				this.tagsuserlist[name].checked = !this.tagsuserlist[name].checked
				const index = this.selectUserList.findIndex(item => item.userId == this.tagsuserlist[name].userId);
				if (index !== -1) {
					this.selectUserList.splice(index, 1);
				} else {
					this.selectUserList.push(this.tagsuserlist[name])
				}
				this.userName = this.selectUserList.map(v => v.nickname)
				this.params.userIds = this.selectUserList.map(v => v.userId)
			},
			deleteUser(index) {
				this.selectUserList.splice(index, 1)
				this.userName = this.selectUserList.map(v => v.nickname)
				this.params.userIds = this.selectUserList.map(v => v.userId)
			},
			getuserid() {
				//会员确定
				this.userName = this.tagsuserlist.filter(item => item.checked)
					.map(v => v.nickname)
				this.params.userIds = this.tagsuserlist.filter(item => item.checked).map(v => v.userId)
				this.showvip = !this.showvip
				if (this.recipientType == 2) {
					this.selectTagList = this.params.tagIds = this.params.tagNames = []
				}
			},
			close() {
				this.showvip = !this.showvip
			},
			async selectUserFun() {
				if (!this.params.projectId) return uni.showToast({
					icon: 'none',
					title: '请选择课程！'
				})
				let paramsId = ''
				if (this.selectUserList) {
					paramsId = this.selectUserList.map(item => item.userId)
				}
				return uni.navigateTo({
					url: `/pages_manage/selectMember?paramsId=${paramsId}&projectId=${this.params.projectId}`
				})
				await this.gettagUserlist('refresh')
				this.showvip = true
			},
			//会员列表
			gettagUserlist(type) {
				const param = {
					pageNum: this.parameter.pageNum,
					pageSize: this.parameter.pageSize,
					keyword: this.keyword,
					tagIds: this.params.tagIds
				}
				getfsuserList(param).then(res => {
					if (res.code == 200) {
						this.viewload = false;
						let dataList = res.data.list.map((item) => {
							return {
								...item,
								checked: false
							};
						});
						if (type == 'refresh') {
							this.tagsuserlist = dataList;
						} else if (type == 'more') {
							this.tagsuserlist = dataList;
						} else {
							this.tagsuserlist = [...this.tagsuserlist, ...dataList];
						}
						if (res.data.isLastPage) {
							this.status = 'nomore';
						} else {
							this.status = 'loadmore';
						}
						this.pagetag = res.data;
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			confirmPop() {
				//标签选择确定
				this.showPop = false
				this.params.tagNames = this.columnsa.filter(item => item.checked).map(v => v.tag)
				this.params.tagIds = this.columnsa.filter(item => item.checked).map(v => v.tagId)
				this.projectid = []
				this.projectuser = ''
				this.ids = []
				this.tagsuser = ''
				if (this.recipientType == 2) {
					this.showvip = true
					this.gettagUserlist('refresh')
				}
			},
			chooseTag(i) {
				this.columnsa[i].checked = !this.columnsa[i].checked
				const index = this.selectTagList.findIndex(item => item.tagId == this.columnsa[i].tagId);
				if (index !== -1) {
					this.selectTagList.splice(index, 1);
				} else {
					this.selectTagList.push(this.columnsa[i])
				}
				this.params.tagNames = this.selectTagList.map(v => v.tag)
				this.params.tagIds = this.selectTagList.map(v => v.tagId)
			},
			deleteTag(index) {
				this.selectTagList.splice(index, 1)
				this.tagNames = this.selectTagList.map(v => v.nickname)
				this.params.tagIds = this.selectTagList.map(v => v.userId)
				if (this.recipientType == 2) {
					this.showvip = true
					this.gettagUserlist('refresh')
				}
			},
			searchKeywordCourseList(e) {
				if (this.timer) {
					clearTimeout(this.timer)
				}
				this.timer = setTimeout(() => {
					this.keyword = e
					this.parameter.pageNum = 1
					this.gettodaylist()
					this.timer = ''
				}, 1000)
			},
			searchKeywordCourse(e) {
				if (this.timer) {
					clearTimeout(this.timer)
				}
				this.timer = setTimeout(() => {
					this.keyword = e
					this.parameter.pageNum = 1
					this.getFsCourseList('refresh')
					this.timer = ''
				}, 1000)
			},
			searchKeywordTag(e) {
				if (this.timer) {
					clearTimeout(this.timer)
				}
				this.timer = setTimeout(() => {
					this.keyword = e
					this.parameter.pageNum = 1
					this.gettaglist('refresh')
					this.timer = ''
				}, 1000)
			},
			searchKeyword(e) {
				if (this.timer) {
					clearTimeout(this.timer)
				}
				this.timer = setTimeout(() => {
					this.keyword = e
					this.parameter.pageNum = 1
					this.gettagUserlist('refresh')
					this.timer = ''
				}, 1000)
			},
			changeFunction(type) {
				switch (type) {
					case 'tag':
						return this.gettaglist('refresh')
					case 'user':
						return this.gettagUserlist('refresh')
					case 'courseType':
						return this.getFsCourseList('refresh')
				}
			},
			getTagpage(type, tag) {
				//标签页数选择
				if (type == 'last') {
					if (this.parameter.pageNum >= 2) {
						this.parameter.pageNum--
						this.changeFunction(tag)
					} else {
						uni.showToast({
							title: '已经是第一页',
							icon: 'none',
							duration: 1000
						});
					}
				} else {
					if (this.parameter.pageNum < this.pagetag.pages) {
						this.parameter.pageNum++
						this.changeFunction(tag)
					} else {
						uni.showToast({
							title: '已经是最后一页',
							icon: 'none',
							duration: 1000
						});
					}
				}
			},
			//重置标签
			resetTag() {
				this.keyword = ''
				this.parameter.pageNum = 1
				this.gettaglist('refresh')
			},
			resetUser() {
				this.userName = this.keyword = ''
				this.parameter.pageNum = 1
				this.params.userIds = this.selectUserList = []
				if (this.recipientType == 2) {
					this.selectTagList = this.params.tagIds = this.params.tagNames = []
				}
				this.gettagUserlist('refresh')
			},
			closePopup() {
				this.keyword = ''
				this.parameter.pageNum = 1
				this.courseTypeShow = this.selectCourseShow = this.showPop = this.showvip = false
				this.searchCourseIdStorage = ''
				if (this.recipientType == 2) {
					this.selectTagList = this.params.tagIds = this.params.tagNames = []
				}
			},
			async selectTagFun() {
				this.showvip = false
				await this.gettaglist('refresh')
				this.showPop = true
			},
			//获取标签列表
			gettaglist(type) {
				uni.showLoading({
					title: '加载中...'
				})
				const data = {
					pageNum: this.parameter.pageNum,
					pageSize: this.parameter.pageSize,
					keyword: this.keyword,
				}
				getallTags(data).then(res => {
					if (res.code == 200) {
						uni.hideLoading()
						const dataList = res.data.list.map(item => {
							let check = false
							if (this.params.tagIds.length > 0 && this.params.tagIds.includs(item.tagId)) {
								check = true
							}
							return {
								...item,
								checked: check,
							}
						})
						if (type == 'refresh') {
							this.columnsa = dataList
						} else {
							this.columnsa = [...this.columnsa, ...dataList]
						}
						if (res.data.isLastPage) {
							this.statusA = 'nomore'
						} else {
							this.statusA = 'loadmore'
						}
						this.pagetag = res.data
						this.changetag = this.columnsa
					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			async getFsCourseList(type) {
				const day = uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
				const param = {
					pageNum: this.parameter.pageNum,
					pageSize: this.parameter.pageSize,
					keyword: this.keyword
				}
				const res = await getFsCourseList(param)
				if (res.code == 200) {
					if (type == 'refresh') {
						this.courseList = res.data.list
					} else {
						// 加载更多 当前页和下一页合并
						this.courseList = [...this.courseList, ...res.data.list]
					}
					this.pagetag = res.data;
					if (res.data.isLastPage) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
				} else {
					uni.showToast({
						icon: 'none',
						title: res.msg,
					});
				}
			},
			selectTime(e) {
				this.timeType = e
				this.timeShow = true
			},
			groupChange(e) {
				this.params.isUrgeCourse = e
			},
			sendChange(e) {
				this.params.sendType = e
			},
			recipientTypeChange(e) {
				this.selectTagList = []
				this.selectUserList = this.params.tagIds = this.params.userIds = this.userName = this
					.params.tagNames = []
				this.recipientType = e
			},
			submitBatchSendCourse() {
				if (!this.params.courseId) return uni.showToast({
					icon: 'none',
					title: '请选择课程！'
				})
				if (!this.params.title) return uni.showToast({
					icon: 'none',
					title: '请填写标题！'
				})
				if (this.params.isUrgeCourse && !this.params.urgeTime) {
					return uni.showToast({
						icon: 'none',
						title: '请选择发课时间！'
					})
				} else if (this.params.isUrgeCourse && !this.params.urgeContent) {
					return uni.showToast({
						icon: 'none',
						title: '请填写催课文案！'
					})
				} else if (!this.params.isUrgeCourse) {
					this.params.urgeTime = ''
				}
				if (this.params.sendType == 1 && !this.params.sendTime) {
					return uni.showToast({
						icon: 'none',
						title: '请选择发送时间！'
					})
				} else if (this.params.sendType != 1) {
					this.params.sendTime = ''
				}
				if (this.recipientType == 1 && this.selectTagList.length <= 0) {
					return uni.showToast({
						icon: 'none',
						title: '请选择标签！'
					})
				} else if (this.recipientType == 2 && this.selectUserList.length <= 0) {
					return uni.showToast({
						icon: 'none',
						title: '请选择会员！'
					})
				}
				this.params.userIds = [...this.selectUserList.map(item => item.userId)]
				uni.showLoading({
					title: '加载中...'
				})
				batchSendCourse(this.params).then(res => {
					if (res.code == 200 || res.errCode == 0) {
						uni.hideLoading()
						uni.showToast({
							title: '保存成功！'
						})
						uni.$emit('updateList', true)
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			confirmTime(e) {
				if (this.timeType == 1) {
					this.params.sendTime = e.value
				} else {
					this.params.urgeTime = e.value
				}
				this.timeShow = false
			},
			getDetaFun(time) {
				const date = new Date(time)
				const year = date.getFullYear()
				let month = date.getMonth() + 1
				let day = date.getDate()
				let hour = date.getHours()
				let minute = date.getMinutes()
				let second = date.getSeconds()
				month = month >= 10 ? month : '0' + month
				day = day >= 10 ? day : '0' + day
				hour = hour >= 10 ? hour : '0' + hour
				minute = minute >= 10 ? minute : '0' + minute
				second = second >= 10 ? second : '0' + second
				return year + '-' + month + '-' + day + ' ' + hour + ':' + minute
			},
			reachBottom(options) {
				if (this.loadStatus === 'loadmore') {
					this.loadStatus = 'loading'
					uni.showNavigationBarLoading()
					setTimeout(() => {
						this.params.pageNum += 1;
						this.getListData('more')
						uni.hideNavigationBarLoading()
					}, 500);
				}
			},
			pullDownRefresh(options) {
				this.triggered = true;
				setTimeout(() => {
					this.triggered = false;
					uni.stopPullDownRefresh()
					this.params.pageNum = 1;
					if (this.seltoday == 0) {
						this.gettodaylist()
					} else {
						this.getListData('refresh')
					}
				}, 500)
			},
			reflashtime() {
				this.keywordlist = ''
				this.params.pageNum = 1
				this.dataList = []
				this.gettodaylist()
				this.getFsCourseList('refresh')
			},
			courseClick(e) {
				this.courseItme = e
				this.params.periodId = e.periodId
				this.params.courseId = e.courseId
				this.params.courseName = e.title
				this.params.videoId = e.videoId
				this.params.videoName = e.title
				this.params.projectId = e.projectId
				this.params.id = e.id
				this.courseName = e.periodName
				this.searchCourseId = e.periodId
				this.selectCourseShow = false
			},
			gettodaylist() {
				if (!this.searchCourseId) return
				const data = {
					keyword: this.keyword,
					periodId: this.searchCourseId,
					pageNum: this.parameter.pageNum,
					pageSize: this.parameter.pageSize,
				}
				getCourseVdieoList(data).then(res => {
					if (res.code == 200) {
						this.viewload = false
						this.dataList = res.data.list
						if (res.data.isLastPage) {
							this.loadStatus = 'nomore'
						} else {
							this.loadStatus = 'loadmore'
						}

					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg,
						});
					}
				})
			},
			async selectCourseTypeShowFun() {
				await this.getFsCourseList('refresh')
				this.courseTypeShow = true
			},
			async selectCourseShowFun() {
				await this.gettodaylist('refresh')
				this.selectCourseShow = true
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		width: calc(100vw - 48rpx);
		margin: 0 24rpx;
	}

	.box {
		background: #fff;
		padding: 10rpx 20rpx;
		width: 100%;
		margin-top: 20rpx;
	}

	.textarea {
		width: 100%;
	}

	.input {
		width: 100%;
		background: #fff;
	}

	.button {
		position: fixed;
		bottom: 0;
		width: calc(100vw - 48rpx);
		margin: 0 24rpx;
	}


	.mt20 {
		margin-top: 20rpx;
	}

	.mt40 {
		margin-top: 40rpx;
	}

	.mr20 {
		margin-right: 20rpx;
	}

	.container-right {
		padding: 10px;
		box-sizing: border-box;
		width: 100%;
		flex: 1;
		overflow-y: scroll;
	}

	.popbox {
		background-color: #fff;
		border-radius: 12px;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 14px;
		color: #333;

		&-head {
			padding: 15px;
			font-weight: bold;
			font-size: 15px;
			text-align: center;
			position: relative;
		}

		.close-circle {
			position: absolute;
			right: 10px;
			top: 50%;
			transform: translateY(-50%);
		}

		&-body {
			padding: 10px 10px;
		}

		.radiobox {
			&-item {
				padding: 10px 0;
				border-bottom: 1px solid #f5f5f5;

				&:last-child {
					border-bottom: none;
				}
			}
		}

		&-footer {
			padding: 15px 0;
		}

		&-footer-btn {
			flex: 1;
			height: 44px;
			line-height: 44px;
			margin: 0 10px;
			border-radius: 50px;
			border: none;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 14px;
			color: #333;

			&::after {
				border: none;
			}
		}

		.con-btn {
			background-color: #1677ff;
			color: #fff;
		}

		.choosetitle {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 15px;
			color: #333;
		}

		.invitetip {
			margin-top: 10px;
			background-color: #ebf5fb;
			color: #1677ff;
			padding: 5px 10px;
			border-radius: 5px;
		}

		.sharePop-item {
			padding: 0 10px;
			box-sizing: border-box;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 14px;
			display: inline-flex !important;

			image {
				height: 48px;
				width: 48px;
				margin-bottom: 10px;
			}
		}
	}

	.tagbox {
		// padding-top: 10rpx;
		font-size: 12px;
		color: #1677ff;
		background: #fff;
		width: 100%;
		display: flex;
		align-content: center;
		flex-wrap: wrap;
		padding: 0 20rpx;

		.tagbox-item {
			height: 26px;
			padding: 0 8px;
			margin: 0 6px 6px 0;
			border-radius: 4px;
			background-color: #e7f1fe;
			color: #1677ff;
			border: 1px solid #1677ff;
			box-sizing: border-box;
			font-size: 12px;
		}
	}

	::v-deep .courselist-footer {
		display: none;
	}

	.boxnav {
		flex-wrap: wrap;
		padding: 0 0 0 10px;

		&-item {
			width: 50%;
			overflow: hidden;
		}

		&-item-info {
			border: 1px solid #f5f5f5;
			text-align: center;
			color: #222;
			background-color: #f5f5f5;
			border-radius: 3px;
			padding: 5px;
			margin: 0 10px 10px 0;
		}

		&-active {
			border: 1px solid #1677ff !important;
			color: #1677ff !important;
			background-color: #e7f1fe !important;
		}
	}

	::v-deep .navs {}

	.courseTitlBox {
		padding: 20rpx;
	}
</style>