<template>
	<view class="page">
		<view class="topBody">
			<view class="header">
				<view class="infoBg">
					<view class="left" @click="goPage('/pages/my/editInfo')">
						<image class="img" mode="aspectFill" :src="myinfo.avator"></image>
					</view>
					<view class="right" @click="goPage('/pages/my/editInfo')">
						<view class="nickname">
							<text>{{myinfo.nickname}}</text>
							<image src="../../static/me/icon_vip.png" mode="widthFix" v-if="myinfo.is_vip > 0" />
							<view class="siming" v-if="myinfo.is_idcheck > 1">已实名</view>
						</view>
						<view class="join_date">
							{{myinfo.join_name}}
							<image src="../../static/me/arrow_right.png" mode="widthFix" />
						</view>
					</view>
					<view class="dashang" @click="chkSel">
						<block v-if="false">
							<view class="sel" v-if="sel == 1">
								<view class="name">关闭<br />打赏</view>
								<view class="block"></view>
							</view>
							<view class="selno" v-else>
								<view class="blockGray"></view>
								<view class="name">开启<br />打赏</view>
							</view>
						</block>
					</view>
				</view>
			</view>
			<view class="myinfo">
				<view class="line"></view>
				<view class="numlist">
					<view class="item" @click="goPage('/pages/my/recordList?type=GUO')">
						<view class="num">
							<text style="color:#FF2A95;">{{myinfo.num_gmd}}</text>
							<view class="name">我的糖果</view>
						</view>
					</view>
					<view class="item" @click="goPage('/pages/my/recordList?type=GMM')">
						<view class="num">
							<text>{{myinfo.num_gmm}}</text>
							<view class="name">我的M币</view>
						</view>
					</view>
					<view class="item" v-if="myinfo.is_web3 > 0">
						<view class="num" @click="goPage('/pages/w3/ucenter')">
							<view class="name">WEB3.0</view>
						</view>
					</view>

				</view>
				<view class="numlist2" style="margin-top: 60rpx;">
					<!-- <view class="item" @click="goPage('/pages/my/idcheck')">
						<view class="num">
							<image class="icon" src="../../static/me/icon_list.png" mode="widthFix" />
							<view class="name">身份认证</view>
						</view>
					</view> -->
					<view class="item" v-for="(item,index) in menu_list" @click="goPage(item.path)">
						<view class="num">
							<image class="icon" :src="item.icon" mode="widthFix" />
							<view class="name">{{item.name}}</view>
						</view>
					</view>
				</view>

			</view>

			<view class="btn_submit" @click="onLogout()">退出登录</view>

			<view class="blankHeight"></view>
			<view class="blankHeight"></view>
		</view>


		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
		<tabbar-view :tabbars="tabbars" :currentIndex="4" ref="tabbar"></tabbar-view>
	</view>
</template>

<script>
	import tabbarView from "@/components/tabbar/tabbar.vue";
	import pageNavbar from "@/components/page-navbar/page-navbar.vue";
	import wWaterfall from "@/components/w-waterfall/w-waterfall.vue";
	import tabbar from "@/mixins/tabbar";
	export default {
		components: {
			tabbarView,
		},
		mixins: [tabbar],
		data() {
			return {
				title: '',
				sel: 1,
				myinfo: {
					nickname: '王思思',
					join_name: '注册日期：2024年5月',
					num_1: 0,
					num_2: 0,
					num_3: 0,
					num_4: 0,
					is_login: 'no',
					num_history: 0,
					num_collection: 0,
					is_web3: 0
				},
				menu_list: []
			}
		},
		onLoad() {
			// if (this.$isWeb3 > 0) {
			// 	this.is_web3 = true;
			// } else {
			// 	this.is_web3 = false;
			// }
			// setTimeout(function() {
			// 	uni.setNavigationBarColor({
			// 		frontColor: '#ffffff',
			// 		backgroundColor: '#00000000',
			// 		animation: {
			// 			duration: 400,
			// 			timingFunc: 'easeIn'
			// 		}
			// 	})
			// }, 200);
		},
		onShow() {
			// this.loadAge();
			// this.loadData();
			// this.loadMenu();
		},
		methods: {
			onBack() {},
			chkSel() {
				if (this.sel == 1) {
					this.sel = 0;
				} else {
					this.sel = 1;
				}
			},
			goPage(page) {
				if (page == 'kefu') {
					let that = this;
					// #ifdef APP-PLUS
					plus.share.getServices(res => {
						const wechat = res.find(i => i.id === 'weixin')
						if (wechat) {
							wechat.openCustomerServiceChat({
								corpid: 'wwbc06aa8311b6ac08',
								// url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
								url: that.myinfo.wxkf
							}, src => {
								console.log("success:")
							}, err => {
								console.log("error:")
							})
						} else {
							uni.showToast({
								title: '没有检测到微信，请先安装',
								icon: "error"
							});
						}
					});
					// #endif

				} else if (page != '') {
					uni.navigateTo({
						url: page,
					})
				}
			},
			loadData() {
				console.log({
					uuid: getApp().globalData.uuid,
					skey: getApp().globalData.skey
				});
				uni.request({
					url: this.$apiHost + '/Web/getinfo',
					data: {
						uuid: getApp().globalData.uuid,
						skey: getApp().globalData.skey
					},
					header: {
						"content-type": "application/json",
						'sign': getApp().globalData.headerSign
					},
					success: (res) => {
						console.log("----:", res.data);
						if (res.data.need_login == "yes") {
							// getApp().globalData.skey = "";
							// getApp().globalData.uuid = "";
							uni.removeStorageSync("wapptoken");
							uni.redirectTo({
								url: '/pages/login/login'
							});
							return;
						}
						if (res.data.need_edit == "yes") {
							uni.navigateTo({
								url: '/pages/my/step'
							});
							return;
						}
						if (res.data.avator != "") {
							uni.setStorageSync("my_avator", res.data.avator);
						} else {
							uni.setStorageSync("my_avator", "/static/logo.png");
						}
						this.myinfo = res.data;
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},
			loadMenu() {
				console.log({
					uuid: getApp().globalData.uuid,
					skey: getApp().globalData.skey
				});
				uni.request({
					url: this.$apiHost + '/User/getinfo',
					data: {
						uuid: getApp().globalData.uuid,
						skey: getApp().globalData.skey
					},
					header: {
						"content-type": "application/json",
						'sign': getApp().globalData.headerSign
					},
					success: (res) => {
						console.log("----:", res.data);
						if (res.data.need_login == "yes") {
							// getApp().globalData.skey = "";
							// getApp().globalData.uuid = "";
							uni.removeStorageSync("wapptoken");
							uni.redirectTo({
								url: '/pages/login/login'
							});
							return;
						}
						this.menu_list = res.data.list01;
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},
			onLogout() {
				let that = this;
				this.$refs['DialogBox'].confirm({
					title: '提示',
					content: '确定退出吗？',
					DialogType: 'inquiry',
					btn1: '取消',
					btn2: '退出',
					animation: 0
				}).then((res) => {
					uni.request({
						url: that.$apiHost + '/My/logout',
						data: {
							uuid: getApp().globalData.uuid,
							skey: getApp().globalData.skey
						},
						header: {
							"content-type": "application/json",
							'sign': getApp().globalData.headerSign
						},
						success: (res) => {
							console.log("----:", res.data);
							// getApp().globalData.skey = "";
							// getApp().globalData.uuid = "";
							uni.removeStorageSync("wapptoken");
							uni.redirectTo({
								url: '/pages/login/login'
							})
						},
						complete: (com) => {
							// uni.hideLoading();
						},
						fail: (e) => {
							console.log("----e:", e);
						}
					});
				})
			},
			loadAge() {
				let that = this;
				uni.request({
					url: this.$apiHost + '/Member/checkAge',
					data: {
						uuid: getApp().globalData.uuid
					},
					header: {
						"content-type": "application/json",
						'sign': getApp().globalData.headerSign
					},
					success: (res) => {
						console.log("----:", res.data);
						if (res.data.need_xiuxi == "yes") {
							uni.redirectTo({
								url: '/pages/AboutUs/xiuxi'
							});
							return;
						}
						if (res.data.need_show_yong == 'yes') {
							that.showYong = true;
						}
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},
		}
	}
</script>

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