<template>
	<view>
		<!-- <wike-skeleton :count="5" v-if="!applayList.length"></wike-skeleton> -->


		<!-- 	<view class="form u-flex align-center justify-center" :style="{height: windowHeight+'px'}"
			v-if="appInfo.page_template == 1 || !appInfo.page_template"> -->

		<view class="form u-flex align-center justify-center" :style="{height: windowHeight+'px'}"
			v-if="appInfo.page_template == 1">
			<view class="top-notice" v-if="appInfo && appInfo.notice"><u-notice-bar
					:text="appInfo.notice"></u-notice-bar></view>
			<view class="logo"><u--image :src="appInfo.site_logo_path?appInfo.site_logo_path:'/static/images/head.jpg'"
					shape="circle" width="200rpx" height="200rpx"></u--image></view>
			<u-transition :show="true" mode="slide-left">
				<view class="title">{{ appInfo.site_name?appInfo.site_name:'AI问答机器人' }}</view>
			</u-transition>
			<u-transition :show="true" mode="slide-right">
				<view class="desc">{{ appInfo.sub_title }}</view>
			</u-transition>
			<view class="btn-group">
				<view class="btn" @click="onToForm"><u-button shape="circle" iconColor="#ffffff" color="#207CF7"
						icon="chat" text="立即提问"></u-button></view>
				<view v-if="appInfo.is_aipainting&&appInfo.is_aipainting == 1" class="btn" @click="ondraw"><u-button
						shape="circle" iconColor="#ffffff" color="#ffc107" icon="edit-pen-fill" text="AI绘画"></u-button>
				</view>
			</view>
		</view>
		<view v-if="appInfo.page_template == 2 || appInfo.page_template == 3" style="background:#F4F7FC;">
			<view class="newTop">
				<view class="topTitle" :style="{paddingTop:isWx?'0':'53rpx',marginBottom:isWx?'0':'32rpx'}">
					<view class="" v-if="!isWx">
						AI人工智能助手
					</view>
				</view>
				<view class="overBox" style="">
					<u-notice-bar style="" bgColor='#C6D6E4' color='#3F5465' v-if="appInfo && appInfo.notice"
						:text="appInfo.notice" :playState="playState" @over="handleOver"
						@out="handleOut"></u-notice-bar>
				</view>
			</view>

			<view class="directask">
				<view class="addBg" style="padding-left: 0;padding-right: 0;">
					<!-- 📝 -->
					<view class="askaquestion u-flex align-center justify-between quesTop" style="">
						<!-- 🔥 -->
						<view class="u-flex align-center" style="align-items:center;">
							<image src="/static/newIndex/quesIcon.png" mode="" style="width: 60rpx;height: 68rpx;">
							</image>
							<view class="quesRight" style="display: flex;align-items: center;">
								<view class="quesTxt">直接提问</view>
								<image src="/static/newIndex/dian.png" mode=""
									style="height: 30rpx; height: 12rpx;margin-left: 10rpx;">
								</image>
							</view>
						</view>
						<block v-if="showchat4">
							<view class="modalTag" @click="showsheet = true">
								<view class="tagTxt" :class="[!isPc?'mw':'']">
									{{currentmodel}}
								</view>
								<image style="width: 22rpx;height: 12rpx;margin-left: 14rpx;"
									src="/static/newIndex/arrDown.png" mode=""></image>
							</view>
						</block>
						<block v-else-if="showchat35">
							<view class="modalTag" @click="showsheet = true">
								<view class="tagTxt" :class="[!isPc?'mw':'']">
									{{currentmodel}}
								</view>
								<image style="width: 22rpx;height: 12rpx;margin-left: 14rpx;"
									src="/static/newIndex/arrDown.png" mode=""></image>
							</view>
						</block>

						<!-- 文心一言 -->
						<block v-else>
							<view class="modalTag" @click="showsheet = true">
								<view class="tagTxt" :class="[!isPc?'mw':'']">
									{{currentmodel}}
								</view>
								<image style="width: 22rpx;height: 12rpx;margin-left: 14rpx;"
									src="/static/newIndex/arrDown.png" mode="">
								</image>
							</view>
						</block>
					</view>
					<view class="textarea">
						<view class="inputTxtBox">
							<u--textarea @focus="focustextarea" maxlength="-1" v-model="valuechat" height="100"
								border="none" :placeholder="placeholder"></u--textarea>
							<image v-if="valuechat" @click="valuechat = ''" class="clearImg" src="/static/clear.png"
								mode=""></image>
						</view>
						<!-- 	<view class="operate u-flex align-center">
							<view v-if="appInfo.page_template == 3" style="margin-right: 32rpx;">
								<u--image :showLoading="true" :src="homeTemplate1.mode[selectornot].img_file.path"
									width="30" height="30" @click="switchmodel = true" shape="circle"></u--image>
							</view>
						</view> -->
						<view class="clearAndSumBtn">
							<view @click="onSubmit(valuechat)" hover-class="hoversubmit" class="submit">
								{{tapsubmit}}
							</view>

							<view class="rClear">
								<image @click.stop="goLead" src="/static/wenhao.png" mode=""
									style="width: 52rpx;height: 52rpx;"></image>
							</view>
						</view>
					</view>
				</view>

				<!-- 	<view v-if="appInfo.page_template == 3" style="margin-bottom: 16px">
					<u-alert :title="appInfo.notice" type="warning" effect="dark"></u-alert>
				</view> -->


				<block v-if="appInfo.page_template == 2">
					<view class="askaquestion u-flex align-center justify-between" style="margin-bottom: 4rpx;">
						<!-- 🔥 -->
						<view class="u-flex align-center">
							<image src="/static/newIndex/fire.png"
								style="width: 40rpx;height: 42rpx;margin-left: 10rpx;"></image>
							<text class="hotTxt">热门提问</text>
						</view>
						<view @click="updateTemplate" class="tn-flex align-center"
							style="justify-content: flex-end;margin-top: 15rpx;">
							<view style="" class="change">换一换</view>
							<image ref="hyh" id="img01" class="shuaxin" :class="{'go':addRotate}"
								src="/static/newIndex/change.png" style="width: 32rpx;height:28rpx;">
							</image>
						</view>
					</view>
					<view class="" style="padding-left: 10rpx;padding-right: 10rpx;">
						<vastwu-barrage @teplateItemClicked="onSubmit" :textList1='templateData' :minTime="70"
							:maxTime="100" :trackList='[14,86,158]' width="100%" height="230rpx"
							ref="vBarrage"></vastwu-barrage>
					</view>
				</block>


				<view class="" v-if="appInfo.page_template == 2" style="padding-left: 10rpx;padding-right: 10rpx;">
					<view class="addbox">
						<view class="askaquestion u-flex align-center justify-between ">
							<!-- 🛠️ -->
							<view class="u-flex align-center" style="align-items: flex-end;">
								<image style="width: 60rpx;height: 64rpx;margin-left: 10rpx;"
									src="/static/newIndex/quesTemp.png"></image>
								<text class="hotTxt" style="margin-bottom: -6rpx;">应用</text>
							</view>
							<view @click="onhelper" class="tn-flex align-center"
								style="justify-content: flex-end;margin-top: 15rpx;">
								<view class="moreBox">
									<view class="moretxt" style="padding-left: 20rpx;">
										更多</view>
									<image src="/static/newIndex/yjt.png"
										style="width: 8rpx;height: 16rpx;margin-left: 8rpx;" mode="">
									</image>
								</view>
							</view>
						</view>
						<view style="margin-bottom: 10rpx;" class="mubanBox">
							<navigator class="helpme"
								:url="'/pages/template/detail?id=' + item.id+'&currentmodel='+currentmodel"
								v-for="(item, index) in applayList" :key="index">

								<view class="bottomBox">
									<view class="left">
										<view class="title">{{ item.title }}</view>
										<view class="sub_title">{{ item.sub_title }}</view>
									</view>
									<view class="right">
										<image v-if="index==0" src="/static/newIndex/mt.png"
											style="width: 48rpx;height: 48rpx;" mode="">
										</image>
										<image v-if="index==1" src="/static/newIndex/wa.png"
											style="width: 48rpx;height: 48rpx;" mode="">
										</image>
										<image v-if="index==2" src="/static/newIndex/qg.png"
											style="width: 48rpx;height: 48rpx;" mode="">
										</image>
										<image v-if="index==3" src="/static/newIndex/kd.png"
											style="width: 48rpx;height: 48rpx;" mode="">
										</image>
									</view>
								</view>
							</navigator>
						</view>
					</view>
				</view>
				<wike-ad></wike-ad>
			</view>
		</view>

		<!-- 研究所或大学生身份切换 -->

		<u-action-sheet @select="selectClick" :round="10" :actions="sheetlist" :title="titlesheet" :show="showsheet"
			safeAreaInsetBottom @close="showsheet = false" cancelText="关闭"></u-action-sheet>
		<!-- #ifdef H5 -->
		<!-- <u-popup :show="h5share" mode="center" @close="h5share = false">
			<view class="cu-dialog">
				<image class="guide-img" src="http://shopro.7wpp.com/imgs/modal/share_guide.png" mode=""></image>
			</view>
		</u-popup> -->
		<!-- #endif -->


		<wike-model v-if="signShow" :authorize="false" :title="signTitle" btnText="立即获取" @save="signSign"
			@close="signShow = false"></wike-model>
		<!-- <block v-if="is_aipainting"> -->
		<block>
			<wike-tabbar2 :currTabIndex='2' v-if="appInfo.page_template == 3" :onTabbar="onTabbar"
				:is_aipainting="is_aipainting" :isShowAnimate="isShowAnimate"
				:appInfos="appInfo.page_template"></wike-tabbar2>
			<wike-tabbar :currTabIndex='2' v-else :onTabbar="onTabbar" :is_aipainting="is_aipainting"
				:isShowAnimate="isShowAnimate" :appInfos="appInfo.page_template"></wike-tabbar>
		</block>
		<!-- 暂时注释 -->

		<wike-modal-qrcode :qrcode="gzhqrcode" :showconcern="showconcern"
			@concernclose="concernclose"></wike-modal-qrcode>


		<u-modal @cancel="handleCancel" @confirm="handleConfirm" cancelText='退出登录' showCancelButton :show="showFixInfo"
			confirmColor="#26b3a0" confirmText="完善信息" title="请完善个人手机号信息后使用本应用"
			content='您已充值,但未绑定手机号,请完善信息以方便为您提供进一步的服务'></u-modal>


		<!-- <view class="leadPic" v-if="showlead">
			<view class="lead1Box" v-show="showlead1">
				<view class="lead1">
					<image src="/static/images/lead1.png" mode=""></image>
					<view class="btn" @click="showlead1=false">
					</view>
				</view>
			</view>
			<view class="lead2Box" v-show="!showlead1">
				<view class="lead2">
					<image src="/static/images/lead2.png" mode=""></image>
					<view class="btn" @click="closeLead2">
					</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	let interstitialAd = null,
		timer,
		time2;


	import noticeBar from '@/components/noticeBar/index.vue'
	import vastwuBarrage from '@/components/vastwu-barrage/vastwu-barrage.vue'

	const isWechat = () => {
		return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
	}

	import {
		init
	} from "@/common";
	export default {
		components: {
			noticeBar,
			vastwuBarrage
		},
		data() {
			return {
				showlead: false,
				showlead1: true,


				showFixInfo: false,
				current: 0,

				playState: 'play',
				// current: 0,
				addRotate: false,

				signTitle: '',
				signShow: false,
				selectornot: 0,
				onTabbar: false,
				isShowAnimate: false,
				valuechat: '请写一篇西游记续集，里面包含一个角色马斯克',
				platform: this.$platform.get(),
				h5share: false,
				windowHeight: 0,
				placeholder: '您可以向AI提出任何问题...',
				tapsubmit: ' 获取答案',
				//模型
				// paintingmode:false,
				showsheet: false,
				titlesheet: '切换模型',
				//是否为gpt4模型
				showchat4: false,
				showchat35: false,

				// #ifdef H5
				sheetlist: [{
						index: 0,
						name: 'ChatGPT 4.0',
						subname: "超级高效沟通·简单提问",
						disabled: false
					},
					{
						index: 1,
						name: 'ChatGPT 3.5',
						subname: "高效沟通·简单提问",
						// color: '#207CF7',
						disabled: false
					},
					{
						index: 2,
						name: '文心一言',
						subname: "便捷沟通·简单提问",
						// color: '#207CF7',
						disabled: false
					},

					{
						index: 3,
						name: '讯飞火星',
						subname: "极速沟通·便捷提问",
						// color: '#207CF7',
						disabled: false
					},
				],
				// #endif
				// 消耗
				plan: {},
				currentmodel: '',
				switchmodel: false,
				is_aipainting: '',
				showconcern: false,
				gzhqrcode: '',

				showchatBaidu: false,

				templateData: [],
				applayList: [],
				homeTemplate1: null,

				appInfo: {}
			};
		},
		computed: {
			...mapGetters(['isLogin', 'userInfo', 'homeTemplate', 'userData']),
			isPc() {
				return navigator.userAgent.indexOf('Mobile') > -1 ? false : true
			},
			isWx() {
				return isWechat()
			}
		},
		async onLoad(o) {
			if (o.uniacid) {
				uni.setStorageSync('uniacid', o.uniacid)
				console.log('onload获取的应用ID----index', uni.getStorageSync('uniacid'));
			}

			var that = this;
			uni.getSystemInfo({
				success: function(res) {}
			});
			setTimeout(() => {
				that.onTabbar = true;
				that.isShowAnimate = true;
			}, 500);

			// this.getTemplateData()
		},
		onReady() {
			let that = this;
			// #ifdef MP-WEIXIN
			clearTimeout(timer);
			// 在适合的场景显示插屏广告
			timer = setTimeout(function() {
				// 在页面onLoad回调事件中创建插屏广告实例
				if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
					interstitialAd = wx.createInterstitialAd({
						adUnitId: that.appInfo.interstitial_id
					});
					interstitialAd.onLoad(() => {});
					interstitialAd.onError(err => {});
					interstitialAd.onClose(() => {
						if (that.appInfo.interstitial_infinite_status && that.appInfo
							.interstitial_infinite_status == 1) {
							that.showInterstitial();
						} else {
							interstitialAd.show().catch(err => {
								console.error(err);
							});
						}
					});
					interstitialAd.show().catch(err => {
						console.error(err);
					});
				}
			}, 4000);
			// #endif
		},
		async onShow() {
			let params = 'system.config';
			let Res = await this.$http('conf.getGroupConf', {
				group: params
			})

			if (Res.code == 0) {
				this.appInfo = Res.data
			}
			console.log('首页---appInfo', Res);

			// 生成固定通过链接分享信息
			if (uni.getStorageSync('token') && uni.getStorageSync('uniacid')) {
				let shareInfo = `uniacid=${uni.getStorageSync('uniacid')}&spm=` + this.$store.getters.userInfo.id +
					'.1.0.' + (['H5', 'wxOfficialAccount', 'wxMiniProgram', 'App'].indexOf(this.platform) + 1) +
					'.1'

				uni.setStorageSync('shareInfo', shareInfo)
				console.log('首页分享链接信息----------------------2：', shareInfo);
			}

			this.getTemplateData()

			this.$http('user.info').then(res => {
				if (res.code == 0) {
					console.log('用户是否是首次支付成功，但未填写手机号', res.data.is_new);
					this.showFixInfo = res.data.is_new;
					// this.showFixInfo = true;
				}
			})


			if (this.isLogin) {
				this.getUserData()
			}
			this.currentmodel = uni.getStorageSync("prestore") || "大学生"
			if (uni.getStorageSync("prestore") == '文心一言') {
				this.showchat4 = false
				this.showchat35 = false
				this.showchatBaidu = true

				this.sheetlist[2].color = "#207CF7"
				this.sheetlist[0].color = "black"
				this.sheetlist[1].color = "black"
				this.sheetlist[3].color = "black"
			} else if (uni.getStorageSync("prestore") == '研究生') {
				this.showchat4 = true
				this.showchat35 = false
				this.showchatBaidu = false

				this.sheetlist[0].color = "#207CF7"
				this.sheetlist[2].color = "black"
				this.sheetlist[1].color = "black"
				this.sheetlist[3].color = "black"
			} else if (uni.getStorageSync("prestore") == '讯飞火星') {
				this.sheetlist[3].color = "#207CF7"
				this.sheetlist[0].color = "black"
				this.sheetlist[2].color = "black"
				this.sheetlist[1].color = "black"

				this.showchat4 = false
				this.showchat35 = false
				this.showchatBaidu = false
			} else {
				this.sheetlist[1].color = "#207CF7"
				this.sheetlist[0].color = "black"
				this.sheetlist[2].color = "black"
				this.sheetlist[3].color = "black"

				this.showchat35 = true
				this.showchatBaidu = false
				this.showchat4 = false
			}
			this.init(this.currentmodel)
			this.windowHeight = uni.$u.sys().windowHeight
			this.systemwechat()


			// let oldHerfUrl = JSON.stringify(location.herf ? location.herf : '')
			// let oldHerfQuery = JSON.stringify(location.search)

			// location.href = JSON.parse(oldHerfUrl + oldHerfQuery + '&a=123466')
			// console.log('location.search', oldHerfQuery);

			// window.onhashchange() {

			// }
			// return
		},
		onUnload() {
			clearInterval(time2);
			// clearInterval(this.timer);
		},
		beforeDestroy() {
			// clearInterval(this.timer);
		},
		methods: {
			...mapActions(['getUserInfo', 'showAuthModal', 'getUserData', 'logout']),
			goLead() {
				uni.navigateTo({
					url: '/pages/user/public/lead'
				})
			},
			closeLead2() {
				this.showlead = false
				uni.setStorageSync('isLead', 'yes')
			},
			handleCancel() {
				this.showFixInfo = false
				this.logout()
				// uni.clearStorage()

				uni.reLaunch({
					url: '/pages/user/signin'
				})
			},
			handleConfirm() {
				uni.navigateTo({
					url: '/pages/user/userinfo?isNewUser=true'
				})
			},

			handleOver() {
				if (!this.isPc) return
				this.playState = 'paused'
			},
			handleOut() {
				if (!this.isPc) return
				this.playState = 'play'
			},
			async getTemplateData() {

				let whereIn = [187, 171, 179, 181]
				let res = await this.$http('common.template', {
					whereIn: whereIn.join(',')
				})
				if (res.code == 0) {
					this.templateData = res.data.hot
					this.applayList = res.data.template
					this.homeTemplate1 = res.data
					// this.$store.commit('TEMPLATE', res.data);


					console.log('首页热门提问：', this.templateData);
					console.log('首页应用列表：', this.applayList);
					console.log('首页homeTemplate1：', this.homeTemplate1);
					// uni.setStorageSync('homeTemplate1', res.data);


					if (!uni.getStorageSync('isLead') && res.data.hot.length) {
						this.showlead = true
					}
				}
			},

			handleTo(item) {
				if (item.name == '绘画') {
					uni.switchTab({
						url: '/pages/painting/painting'
					})
				} else if (item.name == '我的') {
					uni.switchTab({
						url: '/pages/user/user'
					})
				} else if (item.name == '充值') {

					uni.setStorageSync('chargeFromIndex', true)
					uni.navigateTo({
						url: '/pages/user/member/member'
					})
				} else if (item.name == '应用') {
					uni.switchTab({
						url: '/pages/template/template'
					})
				}
			},
			startScroll() {
				this.timer = setInterval(() => {
					this.offset += this.step
					if (this.offset >= this.itemWidth) {
						this.offset = 0
						this.noticeList.push(this.noticeList.shift())
					}
					// document.querySelector('.notice-content').style.transform = `translateX(-${this.offset}px)`
				}, this.speed)
			},


			...mapActions(['appInit', 'logout', 'getUserInfo', 'getUserData']),
			init(preModal) {
				var that = this;
				return Promise.all([this.appInit()]).then(res => {
					that.is_aipainting = that.appInfo.is_aipainting
					uni.setNavigationBarTitle({
						title: that.appInfo.site_name
					});
					that.getPlan(preModal);
				});
			},
			systemwechat() {
				this.$http('conf.getGroupConf', {
					group: 'system.wechat'
				}).then(res => {
					if (res.code == 0) {
						this.gzhqrcode = res.data.qrcode_path
						const focuson = uni.getStorageSync('focuson');
						// console.log(focuson);
						if (!focuson) {
							if (this.gzhqrcode) {
								if (this.appInfo.is_show_index_qrcode == 1) {
									this.showconcern = true
								}
								if (this.isLogin && this.appInfo.is_show_logged_qrcode == 1) {
									this.showconcern = true
								}
							}
						}
					}
				})
			},
			concernclose() {
				this.showconcern = false
			},
			onselect(e) {
				this.showcontext = false
				this.switchmodel = this.selectornot == e ? true : false
				this.selectornot = e;
			},
			showInterstitial() {
				time2 = setInterval(
					function() {
						interstitialAd.show().catch(err => {
							console.error(err);
						});
					},
					this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
				);
			},

			//选择模型
			selectClick(index) {
				for (var a = 0; a < this.sheetlist.length; a++) {
					this.sheetlist[a].color = '#000'
				}
				// #ifdef MP-WEIXIN
				this.sheetlist[index.index - 1].color = '#207CF7'
				// #endif
				// #ifdef H5
				this.sheetlist[index.index].color = '#207CF7'
				// #endif
				this.showchat4 = index.index == 0 ? true : false
				this.showchat35 = index.index == 1 ? true : false


				this.showchatBaidu = index.index == 2 ? true : false
				// this.showchat4 = false
				this.getcurrentmodel()
			},
			getPlan(preModal) {
				let that = this;
				this.$http('conf.getGroupConf', {
					group: 'system.plan'
				}).then(res => {
					if (res.code == 0) {
						this.plan = res.data

						let gpt = this.appInfo;
						// #ifdef H5
						// if (gpt.is_gpt4 == 2) {
						// 	this.sheetlist.shift()

						// 	this.sheetlist[0].name = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
						// 	this.sheetlist[0].subname = gpt.gpt35_intro ? gpt.gpt35_intro : '高效沟通·简单提问'

						// 	this.sheetlist[1].name = gpt.gpt3_alias ? gpt.gpt3_alias : '文心一言'
						// 	this.sheetlist[1].subname = gpt.gpt3_intro ? gpt.gpt3_intro : '便捷沟通·简单提问'

						// 	this.sheetlist[2].name = gpt.gpt2_alias ? gpt.gpt2_alias : '讯飞火星'
						// 	this.sheetlist[2].subname = gpt.gpt2_intro ? gpt.gpt2_intro : '极速沟通·便捷提问'
						// } else {
						// 	this.sheetlist[0].name = gpt.gpt4_alias ? gpt.gpt4_alias : 'ChatGPT 4.0'
						// 	this.sheetlist[0].subname = gpt.gpt4_intro ? gpt.gpt4_intro : '高效沟通·简单提问'

						// 	this.sheetlist[1].name = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
						// 	this.sheetlist[1].subname = gpt.gpt35_intro ? gpt.gpt35_intro : '高效沟通·简单提问'

						// 	this.sheetlist[2].name = gpt.gpt3_alias ? gpt.gpt3_alias : '文心一言'
						// 	this.sheetlist[2].subname = gpt.gpt3_intro ? gpt.gpt3_intro : '便捷沟通·简单提问'

						// 	this.sheetlist[3].name = gpt.gpt2_alias ? gpt.gpt2_alias : '讯飞火星'
						// 	this.sheetlist[3].subname = gpt.gpt2_intro ? gpt.gpt2_intro : '极速沟通·便捷提问'
						// }
						// #endif
						// #ifdef MP-WEIXIN
						// this.sheetlist[0].name = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
						// this.sheetlist[0].subname = gpt.gpt35_intro ? gpt.gpt35_intro : '高效沟通·简单提问'
						// this.sheetlist[0].name = 'ChatGPT 4.0'
						// this.sheetlist[0].subname = '高效沟通·简单提问'

						// this.sheetlist[1].name = 'ChatGPT 3.5'
						// this.sheetlist[1].subname = '高效沟通·简单提问'

						// this.sheetlist[2].name =: '文心一言'
						// this.sheetlist[2].subname = '便捷沟通·简单提问'
						// #endif
						// this.getcurrentmodel1(preModal)

					}
				})

			},
			// getcurrentmodel1(preModal) {

			// },
			getcurrentmodel() {
				let gpt = this.appInfo;
				if (this.showchat4) {
					this.currentmodel = gpt.gpt4_alias ? gpt.gpt4_alias : 'ChatGPT 4.0'
				} else if (this.showchat35) {
					this.currentmodel = gpt.gpt35_alias ? gpt.gpt35_alias : 'ChatGPT 3.5'
				} else if (this.showchatBaidu) {
					this.currentmodel = gpt.gpt3_alias ? gpt.gpt3_alias : '文心一言'
				} else {
					this.currentmodel = gpt.gpt2_alias ? gpt.gpt2_alias : '讯飞火星'
				}

				uni.setStorageSync('prestore', this.currentmodel);
			},
			updateTemplate() {
				// this.$store.dispatch('getTemplate');
				this.getTemplateData()

				this.addRotate = true
				setTimeout((item, index) => {
					this.addRotate = false
				}, 1000)
			},
			onToForm() {
				uni.navigateTo({
					url: '/pages/chat/chat'
				});
			},
			onhelper() {
				uni.switchTab({
					url: '/pages/template/template'
				});
			},
			focustextarea() {
				if (!this.isLogin) {
					uni.navigateTo({
						url: '/pages/user/signin'
					});
					uni.setStorageSync('route', '/pages/index/index');
					return;
				}
				if (this.valuechat == "请写一篇西游记续集，里面包含一个角色马斯克") {
					this.valuechat = ''
				}
			},
			ondraw() {
				// uni.navigateTo({
				// 	url: '/pages/chat/chat?draw=1'
				// });
				uni.switchTab({
					url: '/pages/painting/painting'
				})
			},
			signSign() {
				uni.navigateTo({
					url: '/pages/user/member/member'
				});
				this.signShow = false
			},
			onSubmit(e) {

				console.log('通过点击热门提问的问题：', e);
				var that = this;
				if (!that.isLogin) {
					uni.navigateTo({
						url: '/pages/user/signin'
					});
					uni.setStorageSync('route', '/pages/index/index');
					return;
				}
				if (!e) {
					uni.showToast({
						title: '请输入关键词或问题',
						icon: 'none'
					});

					return;
				}
				if (that.appInfo.time_member && that.appInfo.time_member == 1) {
					if (that.showchat4) {
						if (that.userData.vip_info && that.userData.is_validity > 0 && that.userData.vip_info
							.gpt4_used ==
							that.userData.vip_info.gpt4_times && that.userData.coin < that.plan.lock_gpt4) {
							var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
							// this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
							// 	"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signTitle =
								"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
								that.plan.lock_gpt4 + "</span><span>" + alias +
								"</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +
								"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signShow = true
							return;
						}
						if (that.userData.is_validity == 0 && that.userData.coin < that.plan.lock_gpt4) {
							var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
							this.signTitle =
								"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
								that.plan.lock_gpt4 + "</span><span>" + alias +
								"</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +
								"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signShow = true
							return;
						}
					} else {
						if (that.userData.is_validity > 0 && that.userData.vip_info.gpt35_used == that.userData
							.vip_info
							.gpt35_times && that.userData.coin <= 0) {
							var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
							// this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
							// 	"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signTitle =
								"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
								1 + "</span><span>" + alias +
								"</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +
								"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signShow = true
							return;
						}
						if (that.userData.is_validity == 0 && that.userData.coin <= 0) {
							var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
							this.signTitle =
								"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
								1 + "</span><span>" + alias +
								"</span></p><p style='padding-top: 10px;'>您的提问<span>" + alias +
								"</span>不足或会员套餐内剩余次数不足，无法发起提问</p>"
							this.signShow = true
							return;
						}
					}
				} else {
					if (that.showchat4 && that.userData.coin < that.plan.lock_gpt4) {
						var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
						this.signTitle =
							"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
							that.plan.lock_gpt4 + "</span><span>" + alias +
							"</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>" +
							that.userData.coin + "</span><span>" + alias + "</span>，无法发起提问，快去获取<span>" +
							alias +
							"</span>吧</p>"
						this.signShow = true
						return;
					}
					if (!that.showchat4 && that.userData.coin <= 0) {
						var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
						this.signTitle =
							"<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>" +
							1 + "</span><span>" + alias +
							"</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>" +
							that.userData.coin + "</span><span>" + alias + "</span>，无法发起提问，快去获取<span>" +
							alias +
							"</span>吧</p>"
						this.signShow = true
						return;
					}
				}
				// if(that.showchat4){
				// 	if(that.userData.coin < that.plan.lock_gpt4){
				// 		var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
				// 		this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>提问需要<span style='color: #26b3a0;padding: 0 4px;'>"+that.plan.lock_gpt4+"</span><span>"+alias+"</span></p><p style='padding-top: 10px;'>您当前有<span style='color: #26b3a0;padding: 0 4px;'>"+that.userData.coin+"</span><span>"+alias+"</span>，此模型不支持会员套餐，无法发起提问，快去获取<span>"+alias+"</span>吧</p>"
				// 		this.signShow = true
				// 		return;
				// 	}
				// }
				// if (that.appInfo.time_member && that.appInfo.time_member == 1) {
				// 	if (that.userData.is_validity > 0 && that.userData.vip_info.gpt35_used == that.userData.vip_info.gpt35_times && that.userData.coin <= 0) {
				// 		var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
				// 		this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>"+alias+"</span>/会员套餐内剩余次数不足</p>"
				// 		this.signShow = true

				// 		return;
				// 	}
				// 	if (that.userData.is_validity == 0) {
				// 		if (that.userData.coin <= 0) {
				// 			var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
				// 			this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
				// 				"</span>/会员套餐已到期</p>"
				// 			this.signShow = true
				// 			return;
				// 		}
				// 	}
				// } else {
				// 	if (that.userData.coin <= 0) {
				// 		var alias = that.appInfo.number_alias ? that.appInfo.number_alias : '点数';
				// 		this.signTitle = "<p style='font-weight: 550;font-size: 16px;'>您的提问<span>" + alias +
				// 			"</span>不足</p>"
				// 		this.signShow = true
				// 		return;
				// 	}
				// }

				if (this.currentmodel == '研究生') {
					that.showchat4 = true
				} else if (this.currentmodel == '大学生') {
					that.showchat35 = true
				}

				if (that.showchat4) {
					uni.navigateTo({
						url: '/pages/chat/chat?showchat4=' + e + '&chat4=1'
					});
					that.valuechat = ''
					return;
				} else if (that.showchat35) {
					uni.navigateTo({
						url: '/pages/chat/chat?question=' + e + '&selectornot=' + that.selectornot +
							'&showchat35=true'
					});
				} else if (that.showchatBaidu) {
					// 文心一言
					uni.navigateTo({
						url: '/pages/chat/chat?showchat3=' + e + '&chat3=1'
					});
					that.valuechat = ''
					return;
				} else {
					// 讯飞火星
					uni.navigateTo({
						url: '/pages/chat/chat?showchat2=' + e + '&chat2=1'
					});
					that.valuechat = ''
					return;
				}
			}
		}
	};
</script>

<style lang="scss">
	@import './painting.scss';
</style>