<template>
	<RefreshView ref="mescrollRef" :hasBack="true" text="发布活动" :useDownScroll="false" :useUpScroll="false"
		:isInterceptBack="true" @backClick="backClick" :useTitleLeftBtn="isCreate=='0'?'1':'0'" titleLeftBtnSource="存草稿"
		@leftBtn='leftBtnClick'>

		<view class="topLayout">
			<view class="topLayout_item" @click="topClik(1)">
				<text
					:class="{'topLayout_item_left1': oneShow== true, 'topLayout_item_left2': oneShow== false}">1</text>
				<text
					:class="{'topLayout_item_right2': oneShow== true, 'topLayout_item_right2': oneShow== false}">基本信息</text>
			</view>

			<view class="topLayout_item" @click="topClik(2)">
				<text
					:class="{'topLayout_item_left1': twoShow== true, 'topLayout_item_left2': twoShow== false}">2</text>
				<text
					:class="{'topLayout_item_right2': twoShow== true, 'topLayout_item_right2': twoShow== false}">设置活动项目</text>
			</view>

			<view class="topLayout_item" @click="topClik(3)">
				<text
					:class="{'topLayout_item_left1': threeShow== true, 'topLayout_item_left2': threeShow== false}">3</text>
				<text
					:class="{'topLayout_item_right2': threeShow== true, 'topLayout_item_right2': threeShow== false}">奖项及其他</text>
			</view>
		</view>
		<view v-if="oneShow">

			<PublishItem leftText="标题" :isShowRight="false"></PublishItem>
			<EditText hint="请输入活动名称" @onTextChange="text" :text="info.activityBaseInfo.name"></EditText>
			<view class=" line">
			</view>

			<PublishItem leftText="赛事简介" rightText="编辑" :isShowRight="true" @rightClick="clickItem('赛事介绍')">
			</PublishItem>
			<view style="display: flex;margin-left: 30rpx; margin-right: 30rpx;">
				<editor id="editor1" style="height: 50rpx; white-space: pre-wrap;" placeholder="点击进行编辑..." showImgSize
					showImgToolbar showImgResize :read-only="true" @click="clickItem('赛事介绍')" @ready="onEditorReady1">
				</editor>
			</view>
			<view class="line"></view>

			<PublishItem leftText="宣传海报" rightText="上传" :isShowRight="true" @rightClick="clickItem('宣传海报')">
			</PublishItem>
			<scroll-view style="width: 100%;white-space: nowrap;" scroll-x="true">
				<view v-for="(item,index) in info.activityBaseInfo.listImageFile" :key="index"
					style="display: inline-block;">
					<view style="margin-left: 20rpx;margin-right: 20rpx;display: flex;">
						<image :src="item" style="width: 220rpx;height: 150rpx;z-index: 1;" mode="aspectFill"
							@click="showImage(index)">
						</image>
						<image src="../../static/event-icon/delete1.png"
							style="margin-left: -40rpx;margin-top: 10rpx;width: 30rpx;height: 30rpx;z-index: 2;"
							@click="deleteImage(item)">
						</image>
					</view>

				</view>
			</scroll-view>
			<view class="line"></view>

			<view class="layout">
				<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png" mode="aspectFill">
				</image>
				<text class="layout_lift" style="flex: 1;">体育活动标签</text>
				<view class="layout_right" style="margin-right: 20rpx;">
					<text>{{info.activityBaseInfo.sportCategoryName}}</text>
				</view>
			</view>


			<view class="line"></view>

			<biaofun-datetime-picker :start="info.activityBaseInfo.enrollStartTime" @change="enrollStartTimeChange">
				<PublishItem leftText="报名开始时间" :middleText="info.activityBaseInfo.enrollStartTime" rightText="修改"
					:isShowRight="true"></PublishItem>
			</biaofun-datetime-picker>
			<view class="line"></view>

			<biaofun-datetime-picker :start="info.activityBaseInfo.enrollEndTime" @change="enrollEndTimeChange">
				<PublishItem leftText="报名截止时间" :middleText="info.activityBaseInfo.enrollEndTime" rightText="修改"
					:isShowRight="true">
				</PublishItem>
			</biaofun-datetime-picker>
			<view class="line"></view>

			<PublishItem leftText="联系方式" :middleText="name_mobile" rightText="修改" :isShowRight="true"
				@rightClick="clickItem('联系方式')"></PublishItem>

			<view class="line"></view>

			<PublishItem leftText="免责声明" rightText="编辑" :isShowRight="true" @rightClick="clickItem('免责声明')">
			</PublishItem>
			<view style="display: flex;margin-left: 30rpx; margin-right: 30rpx;">
				<editor id="editor2" style="white-space: pre-wrap;" placeholder="点击进行编辑..." showImgSize showImgToolbar
					showImgResize :read-only="true" @click="clickItem('免责声明')" @ready="onEditorReady2">
				</editor>
			</view>

			<view class="line"></view>

			<view class="layout">
				<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png" mode="aspectFill">
				</image>
				<text class="layout_lift" style="flex: 1;">参赛者取消报名</text>
				<view style="display: flex; flex: 1;justify-content: flex-end;margin-right: 15rpx;">
					<fui-dropdown-menu :size="30" selectedColor="#465CFF" :options="options" @click="typeItemClick"
						@close="typeClose" ref="ddmtype">
						<view class="fui-filter__item" @tap="filterTap()">
							<image style="width: 22rpx;height: 22rpx; margin-left: 15rpx;"
								src="../../static/event-icon/xia.png" mode="aspectFit" class="fui-filter__icon"
								:class="{'fui-icon__ani':typeShow}">
							</image>
							<text>{{type}}</text>
						</view>
					</fui-dropdown-menu>
				</view>
			</view>

			<view class="line"></view>

			<view class="layout">
				<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png" mode="aspectFill">
				</image>
				<text class="layout_lift" style="flex: 1;">是否公开</text>
				<view class="layout_right">
					<switch class="tui-fr" :checked="switch1Checked" @change="switch1Change">
					</switch>
				</view>
			</view>
			<text style="font-size: 24rpx; color:#ff0000 ; margin-left: 30rpx;">注：非公开赛事在“我的赛事”可见，分享后好友可报名。</text>

			<view style="height: 300rpx;"></view>

			<text class="btn" @click="jump()">设置活动项目</text>

		</view>

		<view v-if="twoShow">
			<view>
				<view v-for="(item,index) in info.listActivityItems " :key="index">
					<view class="items">
						<view class="layout1">
							<text class="number">{{index+1}}</text>
							<input class="name" type="text" @input="nameText($event, index)" placeholder="请输入活动项目名称"
								:value="item.name" />
							<view style="display: flex;padding-left: 30rpx; align-items: center;"
								@click="deleteItems(item)">
								<image style="width: 34rpx;height: 38rpx;" src="../../static/event-icon/delete.png"
									mode="aspectFit">
								</image>
							</view>
						</view>
						<view class="line"></view>
						<view class="layout2">
							<textarea class="explain" auto-height="true" style="min-height: 80rpx;"
								@input="explainText($event, index)" placeholder="活动项目说明（点击编辑）"
								:value="item.introduction" />
						</view>
						<view class="line"></view>

						<view style="background: #FFFFFF 100%;display: flex;flex-direction: row;">
							<view class="layout">
								<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png"
									mode="aspectFill">
								</image>
								<text class="layout_lift">报名类型</text>
								<view class="layout_right" style="flex: 1;margin-left: 50rpx;">
									<radio-group @change="radioChange($event, index)">
										<radio :checked="true" :value="item.enrollMold==0">个人</radio>
										<radio :value="item.enrollMold!=0" :disabled="true"
											style="margin-left: 50rpx;">
											团体(待建)</radio>
									</radio-group>
								</view>
							</view>
						</view>

						<view class="line"></view>

						<PublishItem leftText="人数费用" :middleText="item.num_money" rightText="设置" :isShowRight="true"
							@rightClick="itemClick('人数费用',index)">
						</PublishItem>
						<view class="line"></view>

						<biaofun-datetime-picker :start="item.startTime" @change="dateChange1($event, index)">
							<PublishItem leftText="开始时间" :middleText="item.startTime" rightText="修改"
								:isShowRight="true">
							</PublishItem>
						</biaofun-datetime-picker>

						<view class="line"></view>

						<picker mode="date" :start="item.endTime" @change="dateChange2($event, index)">
							<!-- <biaofun-datetime-picker :start="item.endTime" @change="dateChange2($event, index)" :mode="date"> -->
							<PublishItem leftText="结束时间" :middleText="item.endTime" rightText="修改" :isShowRight="true">
							</PublishItem>
							<!-- </biaofun-datetime-picker> -->
						</picker>

						<view class="line"></view>

						<!-- 	<PublishItem leftText="活动地点" :middleText="item.gymnasiumName" rightText="选择" :isShowRight="true"
							@rightClick="i+temClick('活动地点',index)">
						</PublishItem>
						<view class="line"></view> -->

						<PublishItem leftText="活动地点" :isShowRight="false"></PublishItem>
						<EditText hint="请输入活动地点" @onTextChange="address($event, index)" :text="item.gymnasiumName">
						</EditText>
						<view class=" line" />

						<view class="line" style="height: 25rpx;"></view>

					</view>
				</view>
			</view>

			<view style="height: 100rpx;background: #FFFFFF;" v-if="info.listActivityItems.length<6">
				<view class="addData" @click="addData()">
					<image style="width: 48rpx;height: 48rpx;" src="../../static/event-icon/add.png" mode="aspectFit">
					</image>
					<text style="color: #898989 ; margin-left: 10rpx;">点击继续添加活动项目</text>

				</view>
			</view>

			<view style="height: 150px;"></view>

			<text class="btn" @click="jump2()">奖项及其他设置</text>
		</view>

		<view v-if="threeShow">

			<PublishItem leftText="奖品设置" :isShowRight="false">
			</PublishItem>
			<view class="line"></view>
			<view class="layout">
				<textarea class="explain" @input="notesText" auto-height="true" style="min-height: 80rpx;"
					placeholder="奖品设置（点击编辑）" :value="info.activityNotesOther.notes" />
			</view>
			<view class="line"></view>

			<PublishItem leftText="特别鸣谢" rightText="选择赞助商" :isShowRight="true" @rightClick="clickItem('赞助商')">
			</PublishItem>

			<view style="display: flex;margin-left: 40rpx;margin-right: 40rpx;flex-direction: column;">
				<view v-for="(item,index) in nameList " :key="index">
					<view
						style="display: flex; width: 100%; padding-top: 10rpx;padding-bottom: 15rpx;justify-content: center;">
						<text style="color: #898989;font: size 50rpx;flex: 1;">{{item}}</text>
						<image style="width: 30rpx;height: 30rpx;" src="../../static/event-icon/delete.png"
							mode="aspectFit" @click="deleteItem(index)">
						</image>
					</view>
				</view>
			</view>

			<view class="line"></view>

			<!-- 	<PublishItem leftText="主办方" :isShowRight="false"></PublishItem>
			<EditText hint="请输入主办方名称" @onTextChange="organizerText" :text="info.activityNotesOther.organizer">
			</EditText>
			<view class="line"></view>
			 -->

			<view class="layout">
				<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png" mode="aspectFill">
				</image>
				<text class="layout_lift">主办方</text>
				<input style="width: 70%;margin-left: 30rpx;" type="text" placeholder="请输入主办方名称" @input="organizerText"
					:value="info.activityNotesOther.organizer" />
			</view>

			<view class="line"></view>

			<!-- <PublishItem leftText="承办方" :isShowRight="false"></PublishItem>
			<EditText hint="请输入承办方名称" @onTextChange="cocosponsorrText" :text="info.activityNotesOther.cosponsor">
			</EditText>
			 -->
			<view class="layout">
				<image style="width: 45rpx;height: 45rpx;" src="../../static/custom-icon/line.png" mode="aspectFill">
				</image>
				<text class="layout_lift">承办方</text>
				<input style="width: 70%;margin-left: 30rpx;" type="text" placeholder="请输入承办方名称"
					@input="cocosponsorrText" :value="info.activityNotesOther.cosponsor" />
			</view>


			<text class="btn" @click="jump3()">发布</text>
		</view>

	</RefreshView>
</template>

<script>
	import fuiButton from "@/components/firstui/fui-dropdown-menu/fui-dropdown-menu.vue"
	export default {
		
		components: {
			"fuiButton": fuiButton
		},
		data() {
			return {
				oneShow: true,
				twoShow: false,
				threeShow: false,
				isCreate: "0",
				options: [{
					text: '退还报名费',
					value: 1,
				}, {
					text: '不退报名费',
					value: 0
				}],
				tagIndex: 0,
				name_mobile: "",
				typeShow: false,
				type: "退报名费",
				switch1Checked: true,
				switch2Checked: false,
				info: {
					sid: "",
					creatorSid: getApp().globalData.memberSid,
					adcode: this.ReadPreference("find_city_code"),
					activityBaseInfo: {
						enrollStartTime: this.TimeFormat(this.CurrentMillions(), "yyyy-MM-dd HH:mm"),
						enrollEndTime: this.TimeFormat(this.CurrentMillions(), "yyyy-MM-dd HH:mm"),
						listImageFile: [

						],
						cancelEnrollRefund: 0,
						inviteType: 0,
						linkerName: "",
						linkerPhone: "",
						sportCategorySid: "b9e0fce3-2cd0-4090-8bb4-b50e4f1b23cc",
						sportCategoryName: "乒乓球"
					},
					listActivityItems: [

					],
					activityNotesOther: {
						cosponsor: "",
						organizer: "",
						notes: "",
						listSponsorSid: []
					}
				},
				SportCategoryList: [],
				nameList: [],
			};

		},

		onLoad: function(option) {
			console.log('option.isCreate', option.isCreate)
			console.log('option.sid', option.sid)
			console.log('option.sportCategoryName', option.sportCategoryName)
			console.log('option.sportCategorySid', option.sportCategorySid)
			this.isCreate = option.isCreate
			this.info.activityBaseInfo.sportCategoryName = option.sportCategoryName
			this.info.activityBaseInfo.sportCategorySid = option.sportCategorySid
			let that = this

			if (this.IsEmpty(option.sid)) {

				if (this.HasCache()) {
					uni.showModal({
						title: '提示',
						content: '是否使用草稿内容',
						success: function(res) {
							if (res.confirm) { //这里是点击了确定以后
								console.log('用户点击确定')
								console.log('---->1', that.ReadGameCahce())
								that.info = that.ReadGameCahce()
								console.log('---->2', that.info)

								if (that.info.activityBaseInfo.linkerName != null && that.info
									.activityBaseInfo.linkerPhone != null) {
									that.name_mobile = that.info.activityBaseInfo.linkerName + "\u3000" +
										that.info.activityBaseInfo.linkerPhone
								}

								that.type = that.info.activityBaseInfo.cancelEnrollRefund == 1 ?
									"退还报名费" :
									"不退还报名费"
								that.switch1Checked = that.info.activityBaseInfo.inviteType == 0 ? true :
									false

								that.onEditorReady1()
								that.onEditorReady2()

							} else { //这里是点击了取消以后
								console.log('用户点击取消')
								console.log('option.isCreate', JSON.stringify(that.info))
							}
						}
					})
				}
			} else {
				this.Login()
					.then((res) => {
						that.info.activityBaseInfo.creatorSid = res
						getApp().globalData.memberSid = res
						that.WritePreference("memberSid", res)
						getApp().globalData.isLogin = true
						getApp().globalData.memberSid = res
						console.log('info', JSON.stringify(that.info))
						console.log('createSid', res)
						that.HTTP({
							url: 'v1/activityManagement/getActivityCreateInfo/' + res,
							method: 'GET',
							data: {},
							paramsType: "FORM",
							loading: true
						}).then((res) => {
							that.WriteGameCahce(res.data)
							that.info = res.data
							that.name_mobile = res.data.activityBaseInfo.linkerName + "\u3000" + res.data
								.activityBaseInfo.linkerPhone

							that.switch1Checked = res.data.activityBaseInfo.cancelEnrollRefund == 1 ?
								true : false
							that.switch2Checked = res.data.activityBaseInfo.inviteType == 1 ? true : false

							that.onEditorReady1()
							that.onEditorReady2()
							console.log('=======', res)
						});
					})


			}

		},
		onShow() {

			let backResult = this.OnActivityResult();

			if (backResult != undefined) {
				console.log("结果>" + JSON.stringify(backResult))
				if (!this.IsEmpty(backResult.linkerName)) {
					console.log("电话>" + JSON.stringify(this.info.activityBaseInfo))
					this.name_mobile = backResult.linkerName + "\u3000" + backResult.linkerPhone
					this.info.activityBaseInfo.linkerName = backResult.linkerName
					this.info.activityBaseInfo.linkerPhone = backResult.linkerPhone
					console.log("电话>" + JSON.stringify(this.info.activityBaseInfo))
				}
				if (!this.IsEmpty(backResult.introduction)) {
					this.info.activityBaseInfo.introduction = backResult.introduction
					this.onEditorReady1()
				}

				if (!this.IsEmpty(backResult.disclaimer)) {
					this.info.activityBaseInfo.disclaimer = backResult.disclaimer
					this.onEditorReady2()
				}

				if (!this.IsEmpty(backResult.sid)) {
					console.log("选择的球馆>" + JSON.stringify(backResult))
					// 选择的球馆
					this.info.listActivityItems[this.pos].gymnasiumSid = backResult.sid
					this.info.listActivityItems[this.pos].gymnasiumName = backResult.name
					console.log("选择的球馆>" + JSON.stringify(this.info.listActivityItems))

				}

				if (!this.IsEmpty(backResult.enrollMoney)) {
					// 人数费用
					console.log("enrollMoney>" + backResult.enrollMoney)

					let num = backResult.enrollNumbersLimit == 0 ? "不限制人数" : backResult.enrollNumbersLimit + "人"
					let price = backResult.enrollMoney == 0 ? "免费" : backResult.enrollMoney + "元"

					// this.num_money = num + " / " + price

					this.info.listActivityItems[this.pos].enrollMoney = backResult.enrollMoney
					this.info.listActivityItems[this.pos].enrollNumbersLimit = backResult.enrollNumbersLimit
					this.info.listActivityItems[this.pos].num_money = num + " / " + price

				}
				console.log("赞助商>" + JSON.stringify(backResult))
				if (!this.IsEmpty(backResult.sidList)) {
					console.log("list=====>" + JSON.stringify(backResult.sidList))
					this.info.activityNotesOther.listSponsorSid = backResult.sidList
					this.nameList = backResult.nameList

					console.log("sponsorList=====>" + JSON.stringify(this.info.activityNotesOther.listSponsorSid))
				}
			}

		},
		methods: {
			// 分享给好友
			onShareAppMessage: function(res) {
				// console.log("res", res)
				// console.log("data", res.target.dataset)
				// var data = res.target.dataset.info
				// // ①
				// let shareData = JSON.stringify({
				// 	// params: {
				// 	// 	code: data.code,
				// 	// 	codeKey: data.codeKey,
				// 	// 	customerSid: ''
				// 	// },
				// 	// functionName: 'bindCard',
				// 	// url: '/pages/detail/detail_affeection?sid=' + data.sid
			
				// 	url: '/pages/home/cloudCard2?shareSid=' + getApp().globalData.sid,
				// 	functionName: 'share'
				// })
				// // 转码传输
				// let value = encodeURIComponent(shareData)
			
				// return {
				// 	title: '汇融惠享-云菜窖',
				// 	// ②
				// 	path: '/pages/login/login?data=' + value,
				// 	imageUrl: 'https://supervise.yxtsoft.com/lpk/image/share_invite.png', //自定义图片路径，显示图片长宽比是 5:4。
				// 	success: function(res) {
				// 		console.log('aaaa', "分享成功")
				// 	},
				// 	fail: function(res) {
				// 		// 转发失败
				// 		console.log('aaaa', "用户点击了取消")
				// 	}
				// }
			
				let _this = this
				const promise = new Promise(resolve => {
					// 模拟网络请求
					setTimeout(() => {
			
						var params = {
							customerSid: getApp().globalData.sid
						}
			
						_this.$api.recommendNewUsers(params).then((resp) => {
			
			
							let shareData = JSON.stringify({
								// params: {
								// 	code: resp.transferCode,
								// 	codeKey: resp.sid
								// },
								// functionName: 'bindCard',
								// url: '/pages/bind/bind_cloudCard?code=' + resp
								// 	.transferCode + "&codeKey=" + resp.sid
			
								url: '/pages/home/myCellar?shareSid=' + getApp()
									.globalData.sid + "&orderSid=" + resp.sid,
								functionName: 'share'
							})
							// 转码传输
							let value = encodeURIComponent(shareData)
			
							resolve({
								title: '汇融惠享-云菜窖',
								// ②
								path: '/pages/login/login?data=' + value,
								imageUrl: 'https://supervise.yxtsoft.com/lpk/image/share_invite.png', //自定义图片路径，显示图片长宽比是 5:4。
			
							})
			
						}).catch(e => {
							_this.shortToast('发生错误,请稍后再试.')
							return
						})
			
					}, 0)
				})
			
				return promise
			
			
			},
			// 分享到朋友圈
			onShareTimeline() {
				return {
					title: '邀请您使用汇融云菜窖小程序', // 分享出的卡片标题
					path: '/pages/home/cloudCard2', // 他人通过卡片进入小程序的路径，可以在后面拼接URL的形式带参数
					imageUrl: '/static/logo_icon.png', // 分享出去的图片，默认为当前页面的截图。图片路径可以是本地文件路径或者网络图片路径。支持PNG及JPG。
				};
			},
			backClick() {
				let that = this
				uni.showModal({
					title: '提示',
					content: '赛事未发布，是否保存草稿？',
					success: function(res) {
						if (res.confirm) { //这里是点击了确定以后
							console.log('用户点击确定')
							that.WriteGameCahce(that.info)
							uni.navigateBack({
								delta: 1
							})
						} else { //这里是点击了取消以后
							console.log('用户点击取消')
							uni.navigateBack({
								delta: 1
							})
						}
					}
				})
			},
			leftBtnClick() {
				console.log('用户点击确定')
				this.WriteGameCahce(this.info)
				console.log('用户点击确定')
				uni.navigateBack({
					delta: 1
				})

			},
			rightBtnClick() {
				if (this.IsEmpty(this.info.activityBaseInfo.name)) {
					this.Toast("赛事名称不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.introduction)) {
					this.Toast("活动介绍不能为空");
					return;
				}
				if (this.info.activityBaseInfo.listImageFile.length === 0) {
					this.Toast("宣传图片不能为空")
					return
				}
				if (this.IsEmpty(this.info.activityBaseInfo.linkerName) || this.IsEmpty(this.info.activityBaseInfo
						.linkerPhone)) {
					this.Toast("联系方式不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.disclaimer)) {
					this.Toast("免责声明不能为空");
					return;
				}

				let info = this.info.listActivityItems;

				if (info.length == 0) {
					this.Toast("请添加活动项目")
					return
				}

				// 设置比赛项目
				for (var i = 0; i < info.length; i++) {

					if (this.IsEmpty(info[i].name)) {
						this.Toast("请输入活动项目名称")
						return
					}
					if (this.IsEmpty(info[i].introduction)) {
						this.Toast("请输入活动项目说明")
						return
					}
					if (this.IsEmpty(info[i].gymnasiumName)) {
						this.Toast("请选择活动地点")
						return
					}
				}

				// if (this.IsEmpty(this.info.activityNotesOther.notes)) {
				// 	this.Toast("奖品设置不能为空")
				// 	return
				// }
				// if (this.info.activityNotesOther.listSponsorSid.length === 0) {
				// 	this.Toast("赞助商不能为空")
				// 	return
				// }
				// if (this.IsEmpty(this.info.activityNotesOther.organizer)) {
				// 	this.Toast("主办方不能为空")
				// 	return
				// }
				// if (this.IsEmpty(this.info.activityNotesOther.cosponsor)) {
				// 	this.Toast("承办方不能为空")
				// 	return
				// }
				let _this = this
				this.Login()
					.then((res) => {
						_this.info.creatorSid = res
						getApp().globalData.memberSid = res
						_this.WritePreference("memberSid", res)
						getApp().globalData.isLogin = true
						getApp().globalData.memberSid = res
						console.log('info', JSON.stringify(_this.info))
						console.log('createSid', res)
						_this.HTTP({
							url: 'aos/v1/activityManagement/saveActivity',
							method: 'POST',
							data: _this.info,
							paramsType: "JSON",
							loading: true
						}).then((res) => {
							_this.ClearGameCache(_this.info)
							wx.navigateBack({
								delta: 1
							})
							console.log('=======', res)
						});
					})
			},
			topClik(index) {
				switch (index) {
					case 1:
						this.oneShow = true
						this.twoShow = false
						this.threeShow = false
						break
					case 2:
						this.oneShow = false
						this.twoShow = true
						this.threeShow = false
						break
					case 3:
						this.oneShow = false
						this.twoShow = false
						this.threeShow = true
						break
				}
			},
			text(e) {
				this.info.activityBaseInfo.name = e
			},
			clickItem(e) {
				let _this = this
				switch (e) {
					case "宣传海报":

						this.chooseUpload(9)
							.then((res) => {
								console.log("url>>>>", res);

								let a = _this.info.activityBaseInfo.listImageFile.concat(res.urls)
								_this.info.activityBaseInfo.listImageFile = a
								console.log("list", _this.info.activityBaseInfo.listImageFile)

							})


						break;
					case "联系方式":
						uni.navigateTo({
							url: "mobileInfoActivity?linkerName=" + _this.info
								.activityBaseInfo.linkerName +
								"&linkerPhone=" + _this.info
								.activityBaseInfo.linkerPhone
						})
						break;
					case "赛事介绍":
						uni.navigateTo({
							url: "explainActivity?introduction=" + _this.info
								.activityBaseInfo.introduction
						})
						break;
					case "免责声明":
						uni.navigateTo({
							url: "eventActivity?disclaimer=" + _this.info
								.activityBaseInfo.disclaimer
						})
						break;
					case "赞助商":
						uni.navigateTo({
							url: "sponsorList"
						})
						break;
				}
			},
			onEditorReady1() {

				// #ifdef  APP-PLUS
				uni.createSelectorQuery().select('#editor1').context((res) => {
					this.editorCtx1 = res.context
					this.editorCtx1.setContents({
						html: this.info.activityBaseInfo.introduction
					})
				}).exec()
				// #endif

				// #ifdef H5 || MP-WEIXIN
				this.createSelectorQuery().select('#editor1').context((res) => {
					this.editorCtx1 = res.context
					this.editorCtx1.setContents({
						html: this.info.activityBaseInfo.introduction
					})
				}).exec()
				// #endif
			},
			onEditorReady2() {

				// #ifdef  APP-PLUS
				uni.createSelectorQuery().select('#editor2').context((res) => {
					this.editorCtx2 = res.context
					this.editorCtx2.setContents({
						html: this.info.activityBaseInfo.disclaimer
					})
				}).exec()
				// #endif

				// #ifdef H5 || MP-WEIXIN
				this.createSelectorQuery().select('#editor2').context((res) => {
					this.editorCtx2 = res.context
					this.editorCtx2.setContents({
						html: this.info.activityBaseInfo.disclaimer
					})
				}).exec()
				// #endif
			},
			deleteImage(item) {
				let _this = this
				uni.showModal({
					title: '温馨提示',
					content: '确定要删除宣传图片吗？',
					success(res) {
						if (res.confirm) {
							_this.info.activityBaseInfo.listImageFile.splice(_this.info.activityBaseInfo
								.listImageFile.indexOf(item), 1)
						}
					}
				});

			},
			showImage(index) {
				// 预览图片
				let imgsArray = [];
				for (var j = 0; j < this.info.activityBaseInfo.listImageFile.length; j++) {
					let url = this.info.activityBaseInfo.listImageFile[j]
					imgsArray[j] = url
				}

				uni.previewImage({
					current: index,
					urls: imgsArray
				});
			},
			filterTap() {
				this.$refs.ddmtype.show()
				this.typeShow = true;
			},
			typeItemClick(e) {
				this.type = e.text
				this.info.activityBaseInfo.cancelEnrollRefund = e.value
				console.log(this.type)
				console.log(this.info.activityBaseInfo.cancelEnrollRefund)
				this.typeClose()
			},
			typeClose() {
				this.typeShow = false;
			},
			jump() {

				if (this.IsEmpty(this.info.activityBaseInfo.name)) {
					this.Toast("赛事名称不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.introduction)) {
					this.Toast("活动介绍不能为空");
					return;
				}
				if (this.info.activityBaseInfo.listImageFile.length === 0) {
					this.Toast("宣传图片不能为空")
					return
				}
				if (this.IsEmpty(this.info.activityBaseInfo.linkerName) || this.IsEmpty(this.info.activityBaseInfo
						.linkerPhone)) {
					this.Toast("联系方式不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.disclaimer)) {
					this.Toast("免责声明不能为空");
					return;
				}
				this.oneShow = false
				this.twoShow = true
				this.threeShow = false
			},


			enrollStartTimeChange(e) {
				this.info.activityBaseInfo.enrollStartTime = e.f1 + " " + e.hh + ":" + e.mm
				console.log(e)
			},
			enrollEndTimeChange(e) {
				this.info.activityBaseInfo.enrollEndTime = e.f1 + " " + e.hh + ":" + e.mm
			},
			switch1Change: function(e) {
				this.switch1Checked = !this.switch1Checked;
				this.info.activityBaseInfo.inviteType = this.switch1Checked == true ? 0 : 1;
				console.log(`switch1Change样式点击后是否选中：`, this.switch1Checked)
				console.log(`inviteType是否选中：`, this.info.activityBaseInfo.inviteType)
			},
			nameText(e, index) {
				this.info.listActivityItems[index].name = e.detail.value
			},
			explainText(e, index) {
				this.info.listActivityItems[index].introduction = e.detail.value
			},
			radioChange(e, index) {
				console.log(e);
				let radio = this.info.listActivityItems[index].enrollMold == 0
				radio = !radio
				this.info.listActivityItems[index].enrollMold = radio ? 0 : 1
				console.log(this.info.listActivityItems[index].enrollMold);
			},
			getData(info) {
				console.log("info>" + JSON.stringify(info))
				let num = info.enrollNumbersLimit == 0 ? "不限制人数" : info.enrollNumbersLimit + "人"
				let price = info.enrollMoney == 0 ? "免费" : info.enrollMoney + "元"

				return num + " / " + price
			},
			dateChange1(e, index) {
				console.log("eee>" + e.f3)
				console.log("index>" + index)
				this.info.listActivityItems[index].startTime = e.f1 + " " + e.hh + ":" + e.mm

			},
			dateChange2(e, index) {
				console.log("eee>" + JSON.stringify(e))
				console.log("index>" + index)
				this.info.listActivityItems[index].endTime = e.detail.value
			},
			deleteItems(item) {
				let _this = this
				console.log("====>" + _this.info.listActivityItems.length);

				uni.showModal({
					title: '温馨提示',
					content: '确定要删除这条活动项目吗？',
					success(res) {
						if (res.confirm) {
							_this.info.listActivityItems.splice(_this.info.listActivityItems.indexOf(item),
								1);
							console.log("====>" + _this.info.listActivityItems.length);
						}
					}
				});

			},
			itemClick(e, index) {
				this.pos = index
				let _this = this
				console.log("index====>" + index);
				console.log("this.pos====>" + this.pos);
				switch (e) {
					case "人数费用":
						uni.navigateTo({
							url: "InputHappyGameLimitActivity?enrollNumbersLimit=" +
								(_this.info.listActivityItems[index].enrollNumbersLimit == undefined ? "" :
									_this.info.listActivityItems[index].enrollNumbersLimit) +
								"&enrollMoney=" + (_this.info.listActivityItems[index].enrollMoney ==
									undefined ? "" :
									_this.info.listActivityItems[index].enrollMoney) +
								"&type=" + (_this.info.listActivityItems[index].type == undefined ? "" :
									_this.info.listActivityItems[index].type),
						})
						break;
						// case "活动地点":
						// 	uni.navigateTo({
						// 		url: "InputHappyGameAreaActivity",
						// 	})
						// 	break;
				}
			},
			address(e, index) {
				console.log(e)
				this.info.listActivityItems[index].gymnasiumName = e
			},
			addData() {
				this.info.listActivityItems.push({
					name: "活动项目" + (this.info.listActivityItems.length + 1),
					introduction: "",
					enrollNumbersLimit: "",
					enrollMoney: "",
					startTime: this.TimeFormat(this.CurrentMillions(), "yyyy-MM-dd HH:mm"),
					endTime: this.TimeFormat(this.CurrentMillions(), "yyyy-MM-dd"),
					gymnasiumName: "",
					gymnasiumSid: "",
					num_money: "不限制/免费",
					enrollMold: 0,
					groupNumber: 0
				})
				console.log(`length`, this.info.listActivityItems.length)
				console.log(`length`, this.info.listActivityItems)
			},
			jump2() {

				let info = this.info.listActivityItems;

				if (info.length == 0) {
					this.Toast("请添加活动项目")
					return
				}

				// 设置比赛项目
				for (var i = 0; i < info.length; i++) {

					if (this.IsEmpty(info[i].name)) {
						this.Toast("请输入活动项目名称")
						return
					}
					if (this.IsEmpty(info[i].introduction)) {
						this.Toast("请输入活动项目说明")
						return
					}
					if (this.IsEmpty(info[i].gymnasiumName)) {
						this.Toast("请选择活动地点")
						return
					}
				}
				this.oneShow = false
				this.twoShow = false
				this.threeShow = true
			},



			notesText(e) {
				this.info.activityNotesOther.notes = e.detail.value
			},
			cocosponsorrText(e) {
				this.info.activityNotesOther.cosponsor = e
			},
			organizerText(e) {
				this.info.activityNotesOther.organizer = e
			},
			deleteItem(item) {
				let _this = this
				console.log("====>" + _this.info.activityNotesOther.listSponsorSid.length);

				uni.showModal({
					title: '温馨提示',
					content: '确定要删除此赞助商吗？',
					success(res) {
						if (res.confirm) {
							_this.info.activityNotesOther.listSponsorSid.splice(_this.info.activityNotesOther
								.listSponsorSid.indexOf(item),
								1);
							console.log("====>" + _this.info.activityNotesOther.listSponsorSid.length);
						}
					}
				});
			},
			organizerText(e) {
				this.info.activityNotesOther.organizer = e.detail.value
			},
			cocosponsorrText(e) {
				this.info.activityNotesOther.cosponsor = e.detail.value
			},

			jump3() {

				if (this.IsEmpty(this.info.activityBaseInfo.name)) {
					this.Toast("赛事名称不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.introduction)) {
					this.Toast("活动介绍不能为空");
					return;
				}
				if (this.info.activityBaseInfo.listImageFile.length === 0) {
					this.Toast("宣传图片不能为空")
					return
				}
				if (this.IsEmpty(this.info.activityBaseInfo.linkerName) || this.IsEmpty(this.info.activityBaseInfo
						.linkerPhone)) {
					this.Toast("联系方式不能为空");
					return;
				}
				if (this.IsEmpty(this.info.activityBaseInfo.disclaimer)) {
					this.Toast("免责声明不能为空");
					return;
				}

				let info = this.info.listActivityItems;

				if (info.length == 0) {
					this.Toast("请添加活动项目")
					return
				}

				// 设置比赛项目
				for (var i = 0; i < info.length; i++) {

					if (this.IsEmpty(info[i].name)) {
						this.Toast("请输入活动项目名称")
						return
					}
					if (this.IsEmpty(info[i].introduction)) {
						this.Toast("请输入活动项目说明")
						return
					}
					if (this.IsEmpty(info[i].gymnasiumName)) {
						this.Toast("请选择活动地点")
						return
					}
				}

				let _this = this
				this.Login()
					.then((res) => {
						_this.info.activityBaseInfo.creatorSid = res
						getApp().globalData.memberSid = res
						_this.WritePreference("memberSid", res)
						getApp().globalData.isLogin = true
						getApp().globalData.memberSid = res
						console.log('info', JSON.stringify(_this.info))
						console.log('createSid', res)
						_this.HTTP({
							url: 'aos/v1/activityManagement/saveActivity',
							method: 'POST',
							data: _this.info,
							paramsType: "JSON",
							loading: true
						}).then((res) => {
							_this.ClearGameCache(_this.info)
							wx.navigateBack({
								delta: 1
							})
							console.log('=======', res)
						});
					})
			}
		}
	};
</script>

<style lang="scss">
	.topLayout {
		background: #F7F7F7;
		display: flex;
		padding: 30rpx 30rpx;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;

		.topLayout_item {
			display: flex;
			flex-direction: row;
			align-items: center;

			.topLayout_item_left1 {
				width: 48rpx;
				height: 48rpx;
				background-color: #007AFF;
				border-radius: 50%;
				color: #FFFFFF;
				font-size: 36rpx;
				justify-content: center;
				text-align: center;
				align-items: center;
			}

			.topLayout_item_left2 {
				width: 48rpx;
				height: 48rpx;
				border: 1rpx solid #D9D9D9;
				border-radius: 50%;
				color: #D9D9D9;
				font-size: 36rpx;
				justify-content: center;
				text-align: center;
				align-items: center;
			}

			.topLayout_item_right1 {
				font-size: 28rpx;
				color: #262626;
				justify-content: center;
				text-align: center;
				align-items: center;
				margin-left: 10rpx;
			}

			.topLayout_item_right2 {
				font-size: 28rpx;
				font-family: Adobe Heiti Std;
				font-weight: normal;
				justify-content: center;
				text-align: center;
				align-items: center;
				color: #262626;
				margin-left: 10rpx;
			}
		}
	}

	.layout {
		background: #FFFFFF 100%;
		display: flex;
		flex-direction: row;
		padding: 30rpx 15rpx;
		align-items: center;

		.layout_lift {
			display: flex;
			font-size: 30rpx;
			color: #101010;
		}

		.layout_right {
			display: flex;
			right: 32rpx;
			align-items: center;

			.tui-fr {
				zoom: .7
			}

		}
	}

	.fui-filter__item {
		height: auto;
		width: 300rpx;
		display: flex;
		flex-direction: row-reverse;
		align-items: center;
		font-size: 30rpx;
		/* #ifdef H5 */
		cursor: pointer;
		/* #endif */
	}

	.fui-filter__icon {
		transition: all .15s linear;
	}

	.fui-icon__ani {
		transform: rotate(180deg);
	}

	.line {
		width: 100%;
		height: 5rpx;
		background-color: #f5f4f9;
	}

	.tabLayout {
		background: #FFFFFF 100%;
		display: flex;
		flex-direction: row;
		padding-bottom: 20rpx;
	}

	.layout {
		background: #FFFFFF 100%;
		display: flex;
		flex-direction: row;
		padding: 30rpx 15rpx;
		align-items: center;

		.layout_lift {
			font-size: 30rpx;
			color: #101010;
		}

		.layout_right {
			display: flex;
			right: 32rpx;
			align-items: center;
		}
	}

	.items {
		display: flex;
		flex-direction: column;

		.layout1 {
			padding: 32rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			background: #FFFFFF;

			.number {
				width: 40rpx;
				height: 40rpx;
				background-color: #007AFF;
				border-radius: 50%;
				color: #FFFFFF;
				font-size: 32rpx;
				text-align: center;
				align-items: center;
				justify-content: center;
			}

			.name {
				margin-left: 20rpx;
				width: 80%;
			}
		}

		.layout2 {
			margin-top: 10rpx;
			background: #FFFFFF;
			display: flex;
			padding: 32rpx;
			height: auto;

			.explain {
				width: 100%;

			}
		}

		.layout3 {
			background: #FFFFFF;
			display: flex;
			margin-top: 10rpx;
			flex-direction: row;
			padding: 32rpx;

			.layout_lift {
				font-size: 28rpx;
				color: #101010;
			}

			.layout_mobile {
				display: flex;
				flex: 1;
				margin-left: 20rpx;
				font-size: 28rpx;
				color: #8F8F94;
			}

			.input {
				flex: 1;
				width: auto;
				margin-left: 20rpx;
			}

			.layout_right {
				display: flex;
				right: 32rpx;
				align-items: center;


				.layout_right_text {
					margin-right: 10rpx;
					font-size: 28rpx;
					color: #080808;
				}
			}
		}
	}

	.addData {
		display: flex;
		flex-direction: row;
		background: #FFFFFF;
		padding: 32rpx;
		align-items: center;
	}

	.btn {
		justify-content: center;
		width: 100%;
		margin-top: 100rpx;
		padding: 30rpx;
		font-size: 30rpx;
		color: #FFFFFF;
		background: #007AFF;
		text-align: center;
		flex: 1;
		position: absolute;
		bottom: 0;
	}
</style>
