<template>
	<view>
		<home v-show="curType=='home'" :curPage="0" v-if="tabCurTab==isLogin"></home>
		<find v-show="curType=='find'" :curPage="1" v-if="tabCurTab==isLogin"></find>
		<msg v-show="curType=='msg'" :curPage="2" v-if="tabCurTab==isLogin"></msg>
		<user v-show="curType=='user'" :curPage="3" v-if="tabCurTab==isLogin"></user>
		<view class="tabbar" :style="{'padding-bottom': paddingBottomHeight + 'upx'}" :class="$store.state.AppStyle" v-if="tabCurTab==isLogin">
			<view class="tabbar-operate-bg" :class="isPost?'show':''" @tap="getShow()"></view>
			<view class="tabbar-operate" :class="isPost?'show':''"
				:style="{'padding-bottom': paddingBottomHeight + 'upx'}">
				
				<view class="tabbar-operate-main tn-flex tn-flex-row-between tn-bg-white about-shadow tn-margin-top-xl" style="display: flex; flex-wrap: wrap; justify-content: space-around;">
				  <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="sy_appbox&&appModOrder==1&&isShow" @tap="toLink('../plugins/sy_appbox/post')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-folder"></view>
				      </view>  
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">应用投稿</text>
				      </view>
				    </view>
				  </view>
					<view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="wzof==1&&modOrder==2&&isShow" @tap="toLink('../edit/articlePost')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-image-text"></view>
				      </view>  
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">文章投稿</text>
				      </view>
				    </view>
				  </view>
				  <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="tzof==1&&isShow" @tap="toLink('../forum/section?type=2')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-calendar"></view>
				      </view>  
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">发布帖子</text>
				      </view>
				    </view>
				  </view>
				  <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="wzof==1&&modOrder==1&&isShow" @tap="toLink('../edit/articlePost')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-image-text"></view>
				      </view>  
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">文章投稿</text>
				      </view>
				    </view>
				  </view> 
				  <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="sy_appbox&&appModOrder==0&&isShow" @tap="toLink('../plugins/sy_appbox/post')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-folder"></view>
				      </view>  
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">应用投稿</text>
				      </view>
				    </view>
				  </view>
				   <block v-if="shopof==1&&wzof==1&&tzof==1&&isShow">
					<view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" @tap="toLink('../space/post?type=0')" v-if="isShow">
					  <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
					    <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
					      <view class="tn-icon-topics"></view>
					    </view>  
					    <view class="tn-text-center">
					      <text class="tn-text-ellipsis">发布动态</text>
					    </view>
					  </view>
					</view>
				   </block>
				   <block v-else>
					   <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" @tap="toLink('../space/post?type=0')" v-if="isShow">
					     <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
					       <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
					         <view class="tn-icon-topics"></view>
					       </view>  
					       <view class="tn-text-center">
					         <text class="tn-text-ellipsis">图文动态</text>
					       </view>
					     </view>
					   </view>
					   <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" @tap="toLink('../space/post?type=4')" v-if="isShow">
					     <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
					       <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
					         <view class="tn-icon-live-stream"></view>
					       </view>  
					       <view class="tn-text-center">
					         <text class="tn-text-ellipsis">视频动态</text>
					       </view>
					     </view>
					   </view>
				   </block>
				   <!--  #ifdef H5 || APP-PLUS -->
				  <view style="flex: 1; min-width: 140rpx; max-width: 200rpx;padding: 50rpx 25rpx 25rpx 25rpx;" v-if="shopof==1&&isShow" @tap="toLink('../edit/addshop')">
				    <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" style="display: flex;align-items: center;justify-content: space-around;">
				      <view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur" style="background-color: #F3F2F7;color: #7C8191;display: flex;justify-content: center;align-items: center;">
				        <view class="tn-icon-cart"></view>
				      </view> 
				      <view class="tn-text-center">
				        <text class="tn-text-ellipsis">发布商品</text>
				      </view>
				    </view>
				  </view>
				  <!--  #endif -->
				  
				</view>
			</view>
			<block v-for="(item, index) in list" :key="index" v-if="tabCurTab==isLogin">

				<view class="tabbar-item" @tap="tabbarChange(item.type,index)">
					<view class="user-rz">
						<image class="item-img" :src="item.icon_a+'.png'" v-if="curType == item.type"></image>
						<image class="item-img" :src="item.icon" v-else></image>
						
						<!-- #ifdef  H5 -->
						<view class="cu-tag round bg-red sm user-rz-icon border-white" v-if="index == 2&&msgNoticeSum!=0&&msgNoticeSum<=99">{{msgNoticeSum}}</view>
						<view class="cu-tag round bg-red sm user-rz-icon border-white" v-if="index == 2&&msgNoticeSum>99">99+</view>
						<!-- #endif -->
						<!-- #ifdef APP-PLUS || MP -->
						<view class="cu-tag round bg-red sm user-rz-icon-xcx border-white" v-if="index == 2&&msgNoticeSum!=0&&msgNoticeSum<=99">{{msgNoticeSum}}</view>
						<view class="cu-tag round bg-red sm user-rz-icon-xcx border-white" v-if="index == 2&&msgNoticeSum>99">99+</view>
						<!-- #endif -->
						
					
					
					
					
					</view>
					<view class="item-name" :class="{'tabbarActive': curType == item.type}" v-if="item.text">
						{{item.text}}</view>
					<!-- <image class="item-img" :src="item.icon_a+curStyle+'.png'" v-if="curType == item.type"></image>
					<view class="item-name" :class="{'tabbarActive': curType == item.type}" v-if="item.text">{{item.text}}</view> -->
				</view>
				<view class="tabbar-item addPost" v-if="index==1" @tap="getShow()" :class="isPost?'postShow':''">
					<view class="addPost-main">
						<view class="addPost-i">
							<view class="addPost-move">
								<text class="cuIcon-add"></text>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<!--维护弹窗-->
		<view class="announcement" v-if="tabCurTab==0">
			<view class="announcement-bg">
		
			</view>
			<view class="announcement-main">
				<view class="announcement-title">
					服务器连接失败
				</view>
				<view class="announcement-concent" style="background-color: white;">
					<rich-text :nodes="whtext"></rich-text>
				</view>
				<view class="announcement-btn tn-flex" style="justify-content: space-around;">
					<button class="cu-btn bg-blue lg" @tap="getgg()">刷新</button>
					<button class="cu-btn bg-blue lg" @tap="gogw">官网</button>
					<button class="cu-btn bg-blue lg" @tap="goqun">加群</button>
				</view>
			</view>
		</view>
		<!--弹窗公告-->
		<view class="announcement" v-if="isAnnouncement&&Update!=1&&tabCurTab==isLogin">
			<view class="announcement-bg" @tap="isAnnouncement=false">
		
			</view>
			<view class="announcement-main">
				<view class="announcement-title">
					公告
					<text class="cuIcon-close text-red" @tap="isAnnouncement=false"></text>
				</view>
				<view class="announcement-concent" style="background-color: white;">
					<rich-text :nodes="announcement"></rich-text>
				</view>
				<view class="announcement-btn">
					<button class="cu-btn bg-blue lg" @tap="readAnnouncement">我知道了</button>
				</view>
			</view>
		</view>
		<!--update-->
		<!--  #ifdef H5 || APP-PLUS -->
		<view v-if="iosOf!=0&&scrollTop>40" class="forum-post-btn-2 tn-main-gradient-orange box-shadow-2" @tap="refresh()">
					<text class="tn-icon-refresh-simple"></text>
				</view>
				<view v-if="iosOf!=0&&scrollTop<=40" class="forum-post-btn-1 tn-main-gradient-orange box-shadow-2" @tap="refresh()">
					<text class="tn-icon-refresh-simple"></text>
				</view>
				<view v-if="scrollTop>40" class="forum-post-btn-1 tn-main-gradient-blue box-shadow-1" @tap="totop()">
					<text class="tn-icon-totop"></text>
				</view>
			<!--  #endif -->
		<!--  #ifdef APP-PLUS -->
		<view class="update" v-if="Update==1&&tabCurTab==isLogin">
			<view class="update-bg">

			</view>
			<view class="update-box">
				<view class="update-main">
					<image src="../../static/app-plus/ic_ar.png"></image>
					<view class="update-title">发现新版本</view>
					<view class="update-intro"><rich-text :nodes="versionIntro"></rich-text>新版本号：{{versionTitle}}</view>
					<view class="update-btn grid col-1" v-if="qzgx==1">
						<view class="update-btn-box">
							<view class="update-btn-main bg-blue" @tap="isUpdate(true)">
								立即更新
							</view>
						</view>
					</view>
					<view class="update-btn grid col-2" v-else>
						<view class="update-btn-box">
							<view class="update-btn-main bg-blue" @tap="isUpdate(true)">
								更新
							</view>
						</view>
						<view class="update-btn-box">
							<view class="update-btn-main bg-gray" @tap="closeUpdate()">
								取消
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--  #endif -->
		<!--#ifdef APP-PLUS-->
		<view class="Startupmap" v-if="!isStart&&isvip==0">
			<view class="Startupmap-close" @tap="toStart">
				<text>跳过</text>
			</view>
			<view class="Startupmap-pic" @tap="toStartUrl">
				<image :src="startImg.localUrl"></image>
				<!-- <image src="_doc/uniapp_save/16631684216820.png"></image> -->
			</view>
		</view>
		<!--#endif-->
	</view>

</template>

<script>
	import {
		localStorage
	} from '../../js_sdk/mp-storage/mp-storage/index.js'
	export default {
		data() {
			return {
				isPost: false,
				paddingBottomHeight: 0, //苹果X以上手机底部适配高度
				list: [{
					text: '首页',
					icon: '/static/tabbar/home.png', //未选中图标
					icon_a: '/static/tabbar/home_cur', //选中图片
					type: "home",
				}, {
					text: '圈子',
					icon: '/static/tabbar/square.png',
					icon_a: '/static/tabbar/square_cur',
					type: "find",
				}, {
					text: '消息',
					icon: '/static/tabbar/find.png',
					icon_a: '/static/tabbar/find_cur',
					type: 'msg',
					
				}, {
					text: '我的',
					icon: '/static/tabbar/user.png',
					icon_a: '/static/tabbar/user_cur',
					type: "user",
				}, ],
				curType: "home",
				curStyle: "blue",
				isLogin:1,
				whtext: this.$API.getFailText(),
				FailWeb: this.$API.getFailWeb(),
				FailUrl: this.$API.getFailUrl(),
				tabCurTab:1,
				gonggaotime: 86400000,
				curPage: 0,
				qzgx: 1,
				isShow: false,
				announcement: "",
				isAnnouncement: false,
				versionCode: 0,
				wgtVer: '',
				msgNoticeSum: 0,
				Update: 0,
				versionUrl: "",
				versionTitle: "",
				versionIntro: "",
				scrollTop: 0,
				modOrder: 0,
				wzof: 0,
				isHuaWei: this.$API.isHuaWei(),
				isTy: false,
				tzof: 0,
				pyuser: 0,
				shopof: 0,
				startImg: {
					localUrl: ""
				},
				isStart: false,
				iosOf: 0,
				unreadNumLoading: null,
				backButtonPress: 0,
				isvip:0,
				pageShow:false,
				sy_appbox:false,
				appModOrder:0,
			};
		},
		onHide() {
			var that = this;
			that.pageShow = false;
		},
		onUnload() {
			var that = this;
			that.pageShow = false;
		},
		onPageScroll(res){
			var that = this;
			that.scrollTop = res.scrollTop;
		},
		onBackPress() {
			// #ifdef APP-PLUS
			this.backButtonPress++;
			if (this.backButtonPress > 1) {
				plus.runtime.quit();
			} else {
				plus.nativeUI.toast('再按一次退出应用');
			}
			setTimeout(() => {
				this.backButtonPress = 0;
			}, 1000);
			// #endif
			return true;
		},
		onPullDownRefresh() {
			var that = this;
			uni.$emit('onPullDownRefresh', that.curPage);
			var timer = setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onShow() {
			var that = this;
			setTimeout(function() {
				uni.$emit('onShow', that.curPage);
			}, 200);
			// #ifdef APP-PLUS
			//外部启动APP处理
			var args = plus.runtime.arguments;
			plus.runtime.arguments = null;
			plus.runtime.arguments = "";
			if (args) {

				//跳转到文章
				if (args.indexOf("?info=") != -1) {
					var arr = args.split("?info=");
					uni.navigateTo({
						url: '/pages/contents/info?cid=' + arr[1]
					});
				}
				//判断是否是扫码登录
				if (args.indexOf("?scan=") != -1) {
					var arr = args.split("?scan=");
					that.scanLogin(arr[1]);
				}
			}
			// #endif
			if(that.pageShow){
				that.unreadNum();
			 }
			that.getUnreadNum();
			
		},
		//触底监听
		onReachBottom() {
			var that = this;
			uni.$emit('onReachBottom', that.curPage);
		},
		// #ifdef MP
		onShareAppMessage(res) {
			var that = this;
			if (res.from === 'button') {
				// 来自页面内分享按钮
			}
			if (res.from === 'menu') {
				// 来自页面内分享按钮
			}
			var title = that.$API.GetAppName();
			var data = {
				title: title,
			}

			return data;

		},
		onShareTimeline() {
			var that = this;
			var title = that.$API.GetAppName();
			var data = {
				title: title,
			}

			return data;
		},
		// #endif
		onLoad(res) {
			let that = this;
			// #ifdef APP-PLUS
			plus.screen.lockOrientation('portrait-primary');
			// #endif
			//会员不显示开屏广告
			if(localStorage.getItem('userinfo')){
				var userInfo = JSON.parse(localStorage.getItem('userinfo'));
				that.isvip = userInfo.isvip;
				if(that.isvip==1){
					that.isStart=true;
				}
				
			}
			let platform = uni.getSystemInfoSync().platform;
			
			localStorage.setItem('app_platform', platform);
			uni.getSystemInfo({
				success: function(res) {
					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
					console.log("当前设备型号：" + res.model)
					model.forEach(item => {

						//适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
						if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
							that.paddingBottomHeight = 40;
						}
					})
				}
			});
			var cachedPlugins = localStorage.getItem('getPlugins');
			if (cachedPlugins) {
				const pluginList = JSON.parse(cachedPlugins);
				// 检查插件是否存在于插件列表中 
				// #ifdef APP-PLUS || H5
				that.sy_appbox = pluginList.includes('sy_appbox');
				// #endif
			}
			if(that.sy_appbox){
				that.getAppBoxInfo();
			}
			that.getAnnouncement();
			// #ifdef APP-PLUS
			that.isUpdate(false);
			// #endif


			setTimeout(function() {
				that.isStart = true;
			}, 5000);
			// #ifdef APP-PLUS
			that.appStartImg();
			//#endif
			that.unreadNum();
			that.getUnreadNum();
			// setTimeout(function() {
			// 	uni.$emit('onShow', 0);
			// }, 200); 
			
			uni.$on('goUser', function(data) {
				that.tabbarChange("user", 3)
			});
			uni.$on('goMsg', function(data) {
				that.tabbarChange("msg", 2)
			});

			//确认当前风格
			localStorage.setItem('curFullStyle', "index");
			
		},
		
		onReady() {
			setTimeout(function() {
				uni.$emit('onShow', 0);
			}, 200);
		},
		mounted() {
			this.getgg();
			// #ifdef APP-PLUS || H5
			this.initStatusBarStyle();
			// #endif
		},
		methods: {
			getAppBoxInfo() {
				var that = this;
				uni.request({
					url: that.$API.PluginLoad('sy_appbox'),
					data: {
						"action": "getConfig",
					},
					method: 'GET',
					dataType: "json",
					success(res) {
						if (res.data.code == 200) {
							that.appModOrder = res.data.data.appModOrder;
						} else {
							console.log(res.data);
						}
					},
					fail(error) {
						console.log(error);
						uni.showToast({
							title: "网络开小差了",
							icon: 'none'
						})
					}
				})

			},
			// #ifdef APP-PLUS || H5
			initStatusBarStyle() {
				if (uni.getSystemInfoSync().platform === 'android') {
					this.iosOf = 0; // Android 平台
				} else {
					this.iosOf = 1; // iOS 平台
				}
			
			},
			// #endif
			getShow() {
				var that = this;
				that.isPost=!that.isPost;
				if (that.isPost===false) {
					setTimeout(function() {
						that.isShow=false;
					}, 150);
				}else{
					setTimeout(function() {
						that.isShow=true;
					}, 110);
				}
			},
			tabbarChange(type, index) {
				var that = this;
				that.isPost = false;
				setTimeout(function() {
					that.isShow=false;
				}, 150);
				that.curPage = index;
				that.curType = type;
				that.unreadNum();
				that.getUnreadNum();
				setTimeout(function() {
					uni.$emit('onShow', index);
				}, 200);

			},
			closeUpdate() {
				var that = this;
				that.Update = 0;
				// uni.showTabBar({
				// 	animation: true
				// });
			},
			// #ifdef APP-PLUS
			//权限检测
			showTC(){
				var that = this;
				var tc1 = false;
				let _permissionID = 'android.permission.WRITE_EXTERNAL_STORAGE';
				let _permissionID2 = 'android.permission.CAMERA';
				plus.android.checkPermission(_permissionID2,
					granted => {
						if (granted.checkResult == -1) {
							console.log('无相机权限');
							uni.showModal({
								title: '权限申请说明',
								content: '我们将申请获取相机权限和访问相册权限，便于您使用拍照上传您的照片/视频及用于更换头像、意见反馈、保存相册、发布动态等场景。',
								cancelText: "取消",
								confirmText: "同意",
								showCancel: true,
								confirmColor: '#000',
								cancelColor: '#666',
								success: (res) => {
									if (res.confirm) {
										console.log('弹窗同意');
										tc1 = true;
										that.requestPermissions();
									}else{
										console.log('弹窗取消');
										that.isTy = false
										tc1 = true;
									}
								}
							})
							//还未授权当前查询的权限，打开权限申请目的自定义弹框
							that.$nextTick(() => {
								setTimeout(() => {
									that.ani = 'uni-' + that.type
								},30)
							})
						}
					},
					error => {
						console.log(error.message);
					}
				);
				plus.android.checkPermission(_permissionID,
					granted => {
						if (granted.checkResult == -1) {
							console.log('无相册权限');
							if(!tc1){
								uni.showModal({
									title: '权限申请说明',
									content: '我们将申请获取相机权限和访问相册权限，便于您使用拍照上传您的照片/视频及用于更换头像、意见反馈、保存相册、发布动态等场景。',
									cancelText: "取消",
									confirmText: "同意",
									showCancel: true,
									confirmColor: '#000',
									cancelColor: '#666',
									success: (res) => {
										if (res.confirm) {
											console.log('弹窗同意');
											return that.requestPermissions();
										}else{
											console.log('弹窗取消');
											that.isTy = false
										}
									}
								})
							}
							
							//还未授权当前查询的权限，打开权限申请目的自定义弹框
							that.$nextTick(() => {
								setTimeout(() => {
									that.ani = 'uni-' + that.type
								},30)
							})
						}
					},
					error => {
						console.log(error.message);
					}
				);
				
			},
			requestPermissions() {
				let _this = this;
			
					let _permissionID = 'android.permission.WRITE_EXTERNAL_STORAGE';
					let _permissionID2 = 'android.permission.CAMERA';
					
					plus.android.checkPermission(_permissionID2,
						granted => {
							if (granted.checkResult == -1) {
								//还未授权当前查询的权限，打开权限申请目的自定义弹框
								
								_this.$nextTick(() => {
									setTimeout(() => {
										_this.ani = 'uni-' + _this.type
									},30)
								})
							}
						},
						error => {
							console.log(error.message);
						}
					);
					plus.android.requestPermissions([_permissionID2],
						(e) => {
							//关闭权限申请目的自定义弹框
							_this.ani = '';
							_this.$nextTick(() => {
								
							})
							console.log(e,'kkkkk')
							if (e.granted.length > 0) {
								//当前查询权限已授权
								console.log('1已同意');
								plus.android.checkPermission(_permissionID,
									granted => {
										if (granted.checkResult == -1) {
											//还未授权当前查询的权限，打开权限申请目的自定义弹框
											
											_this.$nextTick(() => {
												setTimeout(() => {
													_this.ani = 'uni-' + _this.type
												},30)
											})
										}
									},
									error => {
										console.log(error.message);
									}
								);
								plus.android.requestPermissions([_permissionID],
									(e) => {
										//关闭权限申请目的自定义弹框
										_this.ani = '';
										_this.$nextTick(() => {
											
										})
										console.log(e,'kkkkk')
										if (e.granted.length > 0) {
											//当前查询权限已授权
											console.log('2已同意');
											_this.isTy = true
										}
										if (e.deniedAlways.length > 0) {
											//当前查询权限已被永久禁用，此时需要引导用户跳转手机系统设置去开启
											uni.showModal({
												title: '温馨提示',
												content: '您没有给予访问相册权限，不给予权限将无法使用该功能，立即去设置开启？',
												cancelText: "取消",
												confirmText: "去设置",
												showCancel: true,
												confirmColor: '#000',
												cancelColor: '#666',
												success: (res) => {
													if (res.confirm) {
														_this.goSetting();
													}else{
														_this.isTy = false
													}
												}
											})
										}
									})
							}
							if (e.deniedAlways.length > 0) {
								//当前查询权限已被永久禁用，此时需要引导用户跳转手机系统设置去开启
								uni.showModal({
									title: '温馨提示',
									content: '您没有给予使用相机权限，不给予权限将无法使用该功能，立即去设置开启？',
									cancelText: "取消",
									confirmText: "去设置",
									showCancel: true,
									confirmColor: '#000',
									cancelColor: '#666',
									success: (res) => {
										if (res.confirm) {
											_this.goSetting();
										}else{
											_this.isTy = false
										}
									}
								})
							}
						})
				
			},
			//跳转手机系统设置
			goSetting() {
					var Intent = plus.android.importClass("android.content.Intent");
					var Settings = plus.android.importClass("android.provider.Settings");
					var Uri = plus.android.importClass("android.net.Uri");
					var mainActivity = plus.android.runtimeMainActivity();
					var intent = new Intent();
					intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
					var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
					intent.setData(uri);
					mainActivity.startActivity(intent);
			},
			// #endif
			toLink(text) {
				var that = this;
				
				that.isPost = false;
				if (that.isPost===false) {
					setTimeout(function() {
						that.isShow=false;
					}, 150);
				}else{
					setTimeout(function() {
						that.isShow=true;
					}, 110);
				}
				if (!localStorage.getItem('token') || localStorage.getItem('token') == "") {
					uni.showToast({
						title: "请先登录哦",
						icon: 'none'
					})
					return false;
				}
				if(that.isTy==false&&that.isHuaWei==1){
					that.showTC()
				}
				uni.navigateTo({
					url: text
				});
			},
			refresh() {
						      uni.startPullDownRefresh({
						        success: () => {
						        },
						      });
						      setTimeout(() => {
						        uni.stopPullDownRefresh({
						          success: () => {
						          },
						        });
						      }, 2000);
						    },
						totop() {
							// 返回顶部操作
							// #ifdef APP-PLUS
							uni.pageScrollTo({
								scrollTop: 0,
								duration: 300
							});
							// #endif
							// #ifdef H5
						
							window.scrollTo({
								top: 0,
								behavior: 'smooth', // Optional: add smooth scrolling behavior
							});
							// #endif
						
						},
			getgg() {
				var that = this;
				uni.request({
					url: that.$API.SPgonggao(),
					method: 'GET',
					dataType: "json",
					success(res) {
						that.tabCurTab = res.data.swiperinfo;
						that.gonggaotime = res.data.ggtime;
						if(res.data.swiperinfo!=1){
							that.tabCurTab = 0
						}
						if(that.tabCurTab==0){
							setTimeout(() => {
								that.getgg();
							}, 2000);
						}
					},
					fail(error) {
						that.tabCurTab = 0
						if(that.tabCurTab==0){
							setTimeout(() => {
								that.getgg();
							}, 2000);
						}
						console.log(error);
					}
				})
				uni.request({
					url: that.$API.SPset(),
					method: 'GET',
					dataType: "json",
					success(res) {
						that.wzof = res.data.wzof;
						that.tzof = res.data.tzof;
						that.shopof = res.data.shopof;
						that.modOrder = res.data.modOrder;
							
					},
					fail(error) {
						console.log(error);
					}
				})
			
			},
			getAnnouncement() {
				var that = this;
				that.$Net.request({
					url: that.$API.GetUpdateUrl(),
					header: {
						'content-type': 'application/json'
					},
					method: 'get',
					success: function(res) {
						that.announcement = res.data.announcement;
						if (that.announcement != "" || res.data.announcement) {
							if (localStorage.getItem('isAnnouncement')) {
								var oldTime = Number(localStorage.getItem('isAnnouncement'));
								var curTime = new Date().getTime();
								var difference = curTime - oldTime;
								if (difference > that.gonggaotime) {
									that.isAnnouncement = true;
								}
							} else {
								that.isAnnouncement = true;
							}
			
						}
			
					},
					fail: function(res) {
			
					}
				})
			},
			isUpdate(Status) {
				var that = this;
			
				plus.runtime.getProperty(plus.runtime.appid, function(inf) {
			
					that.wgtVer = inf.version //获取当前版本号
					that.versionCode = inf.versionCode;
					var version = inf.versionCode;
					that.$Net.request({
						url: that.$API.GetUpdateUrl(),
						header: {
							'content-type': 'application/json'
						},
						method: 'get',
						success: function(res) {
							var versionCode = res.data.versionCode;
							that.versionUrl = res.data.versionUrl;
							that.versionTitle = res.data.version;
							that.versionIntro = res.data.versionIntro;
							that.qzgx = res.data.qzgx;
							if (Status) {
								// uni.showToast({
								// 	title:"检测完成",
								// 	icon:'none',
								// 	duration: 1000,
								// 	position:'bottom',
								// });
			
							}
							if (versionCode > version) {
								console.log("有更新");
								uni.hideTabBar({
									animation: true
								})
								that.Update = 1;
								if (Status) {
									if (res.data.versionUrl != "") {
										plus.runtime.openURL(res.data.versionUrl);
									}
								}
							}
			
						},
						fail: function(res) {
			
						}
					})
			
				})
			},
			gogw(){
				var that = this;
				// #ifdef APP-PLUS
				plus.runtime.openURL(that.FailWeb);
				// #endif
				// #ifdef H5
				window.open(that.FailWeb)
				// #endif
				// #ifdef MP-WEIXIN
				uni.showToast({
					title: "小程序无法转跳",
					icon: 'none'
				})
				// #endif
			},
			goqun(){
				var that = this;
				// #ifdef APP-PLUS
				plus.runtime.openURL(that.FailUrl);
				// #endif
				// #ifdef H5
				window.open(that.FailUrl)
				// #endif
				// #ifdef MP-WEIXIN
				uni.showToast({
					title: "小程序无法转跳",
					icon: 'none'
				})
				// #endif
			},
			//自定义启动图广告相关
			toStartUrl() {
				if (localStorage.getItem('appStart')) {
					var imgData = JSON.parse(localStorage.getItem('appStart'));
					//如果线上的图片与本地缓存图片相同，就不再进行下载
					if (imgData.url) {
						var url = imgData.url;
						var type = imgData.urltype;
						if (url.indexOf("http") != -1) {
							// #ifdef APP-PLUS
							if (type == 1) {
								plus.runtime.openURL(url);
							}
							if (type == 0) {
								plus.runtime.openWeb(url);
							}
							// #endif
							// #ifdef H5
							window.open(url)
							// #endif

						} else {
							uni.navigateTo({
								url: url
							});
						}

					} else {
						return false
					}

				} else {
					return false
				}
			},
			toStart() {
				var that = this;
				that.isStart = true;
			},
			appStartImg() {

				var that = this;
				// #ifdef APP-PLUS
				if (localStorage.getItem('appStart')) {
					var imgData = JSON.parse(localStorage.getItem('appStart'));

					if (!imgData.localUrl || imgData.localUrl == "") {
						console.log("启动图文件本地不存在");
						localStorage.removeItem('appStart');
						that.isStart = true;
						return false;
					}
					var localUrl = imgData.localUrl;
					//在请求之前，先为了性能载入上次图片
					plus.io.resolveLocalFileSystemURL(imgData.localUrl, function(entry) {
						console.log("启动图文件本地存在");
						imgData.localUrl = localUrl;
						that.startImg = imgData;

						that.isStart = false;
					}, function(e) {
						console.log("启动图文件本地不存在");
						localStorage.removeItem('appStart');
						that.isStart = true;
					});
				} else {
					console.log("启动图未缓存")
				}
				if (localStorage.getItem('startAds')) {
					var data = JSON.parse(localStorage.getItem('startAds'));
					var adsNum = data.length;
					if (adsNum > 0) {

						var adsRand = Math.floor(Math.random() * adsNum);
						var appStartPic = data[adsRand].img;
						if (appStartPic != "") {
							appStartPic = appStartPic.replace(/[\r\n]/g, "");
							var imgData = data[adsRand];
							imgData.appStartPic = appStartPic;
							that.Download(imgData);
						}
					} else {
						console.log("广告信息不存在，删除缓存");
						localStorage.removeItem('appStart');
						that.isStart = true;
					}

				}
				// #endif
			},
			Download(startImg) {
				var that = this;
				// #ifdef APP-PLUS
				var url = startImg.appStartPic;
				if (localStorage.getItem('appStart')) {
					var imgData = JSON.parse(localStorage.getItem('appStart'));
					//如果线上的图片与本地缓存图片相同，就不再进行下载
					if (url == imgData.appStartPic) {
						console.log("启动图不更新");
						//但是链接可能变化，所以需要载入缓存
						var oldStartImg = imgData;
						localStorage.setItem('appStart', JSON.stringify(oldStartImg));
						return false;
					}
				}
				uni.downloadFile({
					url: url, //下载地址接口返回
					success: (data) => {
						if (data.statusCode === 200) {
							//文件保存到本地
							uni.saveFile({
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									// uni.showToast({
									// 	icon: 'none',
									// 	mask: true,
									// 	title: '文件已保存：' + res.savedFilePath, //保存路径
									// 	duration: 3000,
									// });

									startImg.localUrl = res.savedFilePath;
									localStorage.setItem('appStart', JSON.stringify(startImg));
									console.log("启动图已更新" + startImg.localUrl);

									that.startImg = startImg;
								}
							});
						}
					},
					fail: (err) => {
						console.log(err);
						// uni.showToast({
						// 	icon: 'none',
						// 	mask: true,
						// 	title: '失败请重新下载',
						// });
					},
				});
				// #endif
			},
			readAnnouncement() {
				var that = this;
				that.isAnnouncement = false;
				var timestamp = new Date().getTime();
				localStorage.setItem('isAnnouncement', timestamp);

			},
			unreadNum() {
				var that = this;
				var token = ""
				if (localStorage.getItem('userinfo')) {
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					token = userInfo.token;

				}
				that.$Net.request({

					url: that.$API.unreadNum(),
					data: {
						"token": token
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "get",
					dataType: 'json',
					success: function(res) {
						if (res.data.code == 1) {
							var noticeSum = res.data.data.total;
							localStorage.setItem('noticeSum', noticeSum);
						}
					},
					fail: function(res) {
						uni.showToast({
							title: "网络开小差了哦",
							icon: 'none'
						})
					}
				})
			},
			getUnreadNum() {
				var that = this;
				if(localStorage.getItem('noticeSum')){
					that.msgNoticeSum = Number(localStorage.getItem('noticeSum'));
				}
			},
		}
	};
</script>
<style lang="scss" scoped>
	.open-vip {
		width: 100%;
		height: 72rpx;
		background: linear-gradient(180deg, #F7E5B4 0%, #FFE6AF 2%, #EBC075 100%);
		border-radius: 49rpx;
		display: flex;
		align-items: center;
		margin-top: 36rpx;
		padding: 0 24rpx 0 34rpx;
		box-sizing: border-box;
	
		>image {
			width: 48rpx;
			height: 48rpx;
		}
	
		.text {
			flex: 1;
			font-size: 24rpx;
			line-height: 34rpx;
			margin-left: 14rpx;
		}
	
		.button {
			width: 128rpx;
			height: 42rpx;
			background: linear-gradient(90deg, #4D4D4D 0%, #151515 100%);
			border-radius: 22rpx;
			font-size: 22rpx;
			color: #FFDFA9;
			line-height: 42rpx;
			text-align: center;
		}
	}
	.mine {
		max-height: 100vh;
	}

	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 120rpx;
		height: calc(140rpx + env(safe-area-inset-bottom) / 2);
		height: calc(140rpx + constant(safe-area-inset-bottom));
	}

	.tn-color-cat {
		color: #1D2541;
	}

	.tn-bg-cat {
		background-color: #1D2541;
	}


	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 5rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			flex-basis: 5%;
			width: 100rpx;
			position: absolute;
		}
	}

	/* 自定义导航栏内容 end */


	/* 顶部背景图 end */


	/* 用户头像 start */
	.logo-image {
		width: 110rpx;
		height: 110rpx;
		position: relative;
		overflow: hidden;
		border-radius: 50%;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		box-shadow: 0rpx 0rpx 60rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 50%;
		overflow: hidden;
		// background-color: #FFFFFF;
	}

	/* 页面 start*/
	.about-shadow {
		border-radius: 30rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.about {

		&__wrap {
			position: relative;
			z-index: 1;
			margin: 20rpx 30rpx;
		}
	}

	/* 页面 end*/

	/* 图标容器15 start */
	.icon15 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;


				}
			}
		}
	}

	/* 图标容器12 start */
	.tn-three {
		position: absolute;
		top: 50%;
		right: 50%;
		bottom: 50%;
		left: 50%;
		transform: translate(-38rpx, -16rpx) rotateX(30deg) rotateY(20deg) rotateZ(-30deg);
		text-shadow: -1rpx 2rpx 0 #f0f0f0, -2rpx 4rpx 0 #f0f0f0, -10rpx 20rpx 30rpx rgba(0, 0, 0, 0.2);
	}

	.icon20 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url();
				}
			}
		}
	}



	.button-vip {
		width: 100%;
		height: 150rpx;
		border-radius: 15rpx;
		position: relative;
		z-index: 1;

		&::after {
			content: " ";
			position: absolute;
			z-index: -1;
			width: 100%;
			height: 100%;
			left: 0;
			bottom: 0;
			border-radius: inherit;
			opacity: 1;
			transform: scale(1, 1);
			background-size: 100% 100%;
			background-image: url(https://tnuiimage.tnkjapp.com/cool_bg_image/icon_bg.png);
		}
	}


	/* 图标容器12 start */
	.icon12 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 15rpx;
				height: 15rpx;
				font-size: 50rpx;
				border-radius: 50%;
				margin-bottom: 38rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;

				}
			}
		}
	}

	/* 图标容器1 start */
	.icon1 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 40rpx;
				height: 40rpx;
				font-size: 40rpx;
				border-radius: 50%;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url();
				}
			}
		}
	}

	/* 图标容器1 end */


	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;

		.backgroud-image {
			width: 100%;
			height: 450rpx;
			// z-index: -1;
		}
	}

	/* 顶部背景图 end */
	.text-1 {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.name-vip {
		color: #ff6c3e;
	}
.user-rz{
	position: relative;
	display: inline-block;
}
.user-rz-icon{
	position: absolute;
	left: 28upx;
	bottom: 20upx;
	padding: 0upx 6upx;
	line-height: 30upx;
}
.user-rz-icon-xcx{
	position: absolute;
	left: 30upx;
	bottom: 17upx;
	padding: 0upx 6upx;
	line-height: 32upx;
}
.border-white{
	border: 2upx solid #fff;
}


		.forum-post-btn-1 {
			position: fixed;
			z-index: 888;
			bottom: 200upx;
			right: 60upx;
			width: 90upx;
			height: 90upx;
			font-size: 40upx;
			color: #fff;
			border-radius: 50%;
			text-align: center;
			line-height: 90upx;
		}
		
		.forum-post-btn-2 {
			position: fixed;
			z-index: 888;
			bottom: 300upx;
			right: 60upx;
			width: 90upx;
			height: 90upx;
			font-size: 40upx;
			color: #fff;
			border-radius: 50%;
			text-align: center;
			line-height: 90upx;
		}
		.box-shadow-1 {
			box-shadow: 0 0 10upx #31C9E8bf;
		}
		.box-shadow-2 {
			box-shadow: 0 0 10upx #Ff9700bf;
		}
  
</style>
