<template>
	<view class="page flex-col">
		<view class="group_1 flex-col">
			<view class="group_2 flex-row">

				<view class="group_3 flex-col">

					<view class="block_1 flex-row" style="">
						<!-- 	<view class="block_1 flex-row" v-if="user.isLogin"  @tap="go('个人信息')">
						<view class="block_1 flex-row" v-else > -->
						<image v-if="user.isLogin" class="single-avatar_1 flex-col"
							:src=" $wanlshop.oss(user.avatar, 52, 52, 2, 'avatar')"></image>
						<view v-else class="single-avatar_1 flex-col"></view>

						<view class="text-wrapper_1 flex-col justify-between">
							<text class="text_2" v-if="user.isLogin">{{ user.nickname }}</text>
							<text class="text_2" v-else @tap="tologin()">登录 / 注册</text>
							<text class="text_3" v-if="vip">{{vip}}</text>
							<text class="text_3" v-else>暂未开通会员</text>
						</view>
						<image class="icon_1" referrerpolicy="no-referrer" style="" @tap="go('个人信息')"
							src="/static/lanhu_gerenzhongxin/29e52e66e76c7758ef4e51c94fcae5b1.png" />
					</view>


					<view class="block_2 flex-row">
						<image class="icon_2" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/e496466b587ab27078060452caa8959f.png" />
						<text class="text_4">开通会员，享更多特权</text>

						<button class="button_1 flex-col" v-if="vip">
							<text class="text_5" style="">{{vip}}</text>
						</button>
						<button class="button_1 flex-col" @tap="go('开通会员')" v-else="vip">
							<text class="text_5">立即开通</text>
						</button>
					</view>
				</view>
			</view>
			<view class="group_4 flex-col" style="border: none;height: auto;">
				<view class="block_3 flex-row justify-between">
					<text class="text_6">我的订单</text>
					<view class="image-text_1 flex-row justify-between">
						<text class="text-group_1" @tap="go('全部订单')">全部</text>
						<image class="label_1" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/fc6da6d9470cc5ecfc25e0702030cfaa.png" />
					</view>
				</view>
				<view class="block_4 flex-row justify-between">
					<view class="group_5 flex-col justify-between" @tap="go('待付款')">
						<image class="icon_3" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/ab22b5e16fce620db29996940328b46a.png" />
						<text class="text_7">待付款</text>
					</view>
					<view class="image-text_2 flex-col justify-between" @tap="go('待发货')">
						<image class="icon_4" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/1a12c2acbfe3578cbd913a46ed86f334.png" />
						<text class="text-group_2">待发货</text>
					</view>
					<view class="image-text_3 flex-col justify-between" @tap="go('已完成')">
						<image class="icon_5" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/aa16a5b91eed1e5d033f40aa42ef8d7b.png" />
						<text class="text-group_3">已完成</text>
					</view>
				</view>

				<view class="block_5 flex-row justify-between" @tap="go('课程订单')">
					<view class="image-text_4 flex-row justify-between">
						<image class="icon_6" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/b881de850a7461d57323d0ca928f6fcc.png" />
						<text class="text-group_4">课程订单</text>
					</view>
					<image class="icon_7" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_2" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/41abba1deaab581af648218e4083bce1.png" />


				<view class="block_6 flex-row justify-between" @tap="go('资金提现')">
					<view class="image-text_5 flex-row justify-between">
						<image class="icon_8" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/952fac7724ed7e6d7c2cda2a80faa7e6.png" />
						<text class="text-group_5">资金提现</text>
					</view>
					<image class="icon_9" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_3" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/71b300aaa297f9f014d86e9ddc863666.png" />


				<view class="block_7 flex-row justify-between" @tap="go('我的收藏')">
					<view class="image-text_6 flex-row justify-between">
						<image class="icon_10" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/64f0653206d6cc32f65ddcdaf886c5fc.png" />
						<text class="text-group_6">我的收藏</text>
					</view>
					<image class="icon_11" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_4" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/79f1cf72c5b140263edbacae5442c1be.png" />


				<view class="block_8 flex-row justify-between" @tap="go('我的学习')">
					<view class="image-text_7 flex-row justify-between">
						<image class="icon_12" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/8fdee511a567e9604022e6fa7c1acab3.png" />
						<text class="text-group_7">我的学习</text>
					</view>
					<image class="icon_13" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_5" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/48fda0dba5573fc06a430770760e8ca3.png" />


				<view class="block_9 flex-row justify-between" @tap="go('帮助中心')">
					<view class="image-text_8 flex-row justify-between">
						<image class="icon_14" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/d0ce0a01d8368fca75623e245340de89.png" />
						<text class="text-group_8">帮助中心</text>
					</view>
					<image class="icon_15" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_6" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/37fe32a83abe3634f2bd80488578107e.png" />

				<view class="block_10 flex-row justify-between" @tap="go('用户反馈')">
					<view class="image-text_9 flex-row justify-between">
						<image class="icon_16" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/bd689923e0dbc4850c4c0bd891aa5d59.png" />
						<text class="text-group_9">用户反馈</text>
					</view>
					<image class="icon_17" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_7" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/69997aea8f7fa881a51a91ce86985f90.png" />



				<view class="block_10 flex-row justify-between" @tap="go('关于我们')">
					<view class="image-text_9 flex-row justify-between">
						<image class="icon_16" referrerpolicy="no-referrer"
							src="/static/lanhu_gerenzhongxin/cb6dd7b6431fed8ae636937232a80102.png" />
						<text class="text-group_9">关于我们</text>
					</view>
					<image class="icon_17" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>
				<image class="image_7" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/69997aea8f7fa881a51a91ce86985f90.png" />


				<view class="block_11 flex-row justify-between">
					<image class="icon_18" src="/static/lanhu_gerenzhongxin/69838aa65fae36bb3514e0cdda76c0cb.png" />
					<button class="image-text_10 flex-row justify-between" plKain="true" open-type="contact"
						@contact="contact"
						style="border:none;text-align: center;position:sticky;width: 90%;margin-left: 10rpx;">

						<text class="text-group_10" style="text-align: left;">联系客服</text>

					</button>

					<image class="icon_19" referrerpolicy="no-referrer" src="/static/lanhu_gerenzhongxin/11.png" />
				</view>

				<image class="image_7" referrerpolicy="no-referrer"
					src="/static/lanhu_gerenzhongxin/69997aea8f7fa881a51a91ce86985f90.png" />

				<view class="text-wrapper_2 flex-col">
					<text class="text_8">{{count.daizhifu}}</text>
				</view>

				<view class="text-wrapper_2 flex-col" style="left:400rpx">
					<text class="text_8">{{count.daifahuo}}</text>
				</view>

				<view class="text-wrapper_2 flex-col" style="left:650rpx">
					<text class="text_8">{{count.yiwancheng}}</text>
				</view>

			</view>


			<view class="group_7 flex-col">


				<view class="box_7 flex-row">
					<view class="section_4 flex-col"></view>
					<view class="section_5 flex-col"></view>
					<view class="section_6 flex-col"></view>
				</view>
			</view>

		</view>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				vip: '',
				count: [],
				constants: {}
			};
		},
		onLoad(option) {
			if(option.fenxiangid){
				uni.setStorageSync('fenxiangid', option.fenxiangid);
			}
		
			uni.setNavigationBarColor({
					backgroundColor: '#802931', // 背景颜色
					frontColor: '#ffffff' // 前景颜色（包括标题、返回图标等）
				}),
				this.getVip()
		},
		onShow() {
			// 页面展示时刷新数据
			this.getVip()
		},
		computed: {
			...mapState(['user', 'statistics', 'common'])
		},
		methods: {
			callCustomerService() {
				uni.navigateBackMiniProgram({
					extraData: {
						appId: 'wx8a3308bdea928be3'
					},
					success(res) {
						// 唤起成功的回调函数
						console.log('唤起微信客服成功', res)
					},
					fail(error) {
						// 唤起失败的回调函数
						console.log('唤起微信客服失败', error)
					}
				})
			},

			getVip() {
				if (this.user.id) {
					this.$api.get({
						url: '/wanlshop/data/getVip',
						data: {
							id: this.user.id
						},
						success: res => {
							this.vip = res
						}
					});
					this.$api.get({
						url: '/wanlshop/data/getCount',
						data: {
							id: this.user.id
						},
						success: res => {
							this.count = res
							console.log(4445, res)
						}
					});

				}
			},
			// 第三方登录
			tologin() {
				let provider = {
					id: "weixin",
					name: "wlIcon-WeChat",
					platform: "mp_weixin"
				}
				console.log(444, provider)

				uni.showLoading({
					title: '登录中'
				});
				// #ifndef H5
				uni.login({
					provider: provider.id,
					// #ifdef MP-ALIPAY
					scopes: 'auth_user', //支付宝小程序需设置授权类型
					// #endif
					success: (loginRes) => {
						this.$api.post({
							url: '/wanlshop/user/third',
							data: {
								platform: provider.platform,
								loginData: loginRes,
								client_id: uni.getStorageSync("wanlshop:chat_client_id") ? uni
									.getStorageSync("wanlshop:chat_client_id") : null
							},
							success: res => {
								uni.hideLoading();
								if (res.binding == 0) {
									this.$wanlshop.to(
										`/pages/user/auth/perfect?third_id=${res.third_id}&platform=${provider.platform}&url=${this.pageroute}`
									);
								} else {
									this.$store.dispatch('user/login', res);
									this.$store.dispatch('cart/login');
									this.$store.dispatch('chat/get');
									uni.reLaunch({
										url: decodeURIComponent(this.pageroute)
									});
								}
							}
						});
						// 隐藏键盘
						uni.hideKeyboard();
					},
					fail: err => {
						this.$wanlshop.msg(err.msg);
					}
				});
				// #endif
				// #ifdef H5
				this.$api.post({
					url: '/wanlshop/user/third_web',
					data: {
						platform: provider.platform,
						client_id: uni.getStorageSync("wanlshop:chat_client_id") ? uni.getStorageSync(
							"wanlshop:chat_client_id") : null
					},
					success: res => {
						uni.hideLoading();
						this.$store.dispatch('user/login', res);
						this.$store.dispatch('cart/login');
						this.$store.dispatch('chat/get');
						// 返回页面
						uni.reLaunch({
							url: decodeURIComponent(this.pageroute)
						});
					}
				});
				// #endif
			},
			go(tab) {
				console.log(233, this.user)
				if (!this.user.id) {
					this.$wanlshop.msg('请先登录');
					return false
				}
				console.log(tab)
				if (tab == '开通会员') {
					uni.navigateTo({
						url: '/pages/lanhu_goumaihuiyuan/index'
					});
				}

				if (tab == '全部订单') {
					// uni.navigateTo({
					// 	url: '/pages/lanhu_wodedingdan/index'
					// });
					uni.navigateTo({
						url: '/pages/user/order/order'
					});
				}

				if (tab == '待付款') {
					uni.navigateTo({
						url: '/pages/user/order/order?state=1'
					});
				}
				if (tab == '待发货') {
					uni.navigateTo({
						url: '/pages/user/order/order?state=2'
					});
				}
				if (tab == '已完成') {
					uni.navigateTo({
						url: '/pages/user/order/order?state=3'
					});
				}

				if (tab == '课程订单') {
					uni.navigateTo({
						url: '/pages/lanhu_kechengdingdan/index'
					});
				}


				if (tab == '资金提现') {
					uni.navigateTo({
						url: '/pages/user/money/withdraw'
					});
				}

				if (tab == '我的收藏') {
					uni.navigateTo({
						url: '/pages/lanhu_shoucang/index'
					});
				}

				if (tab == '我的学习') {
					uni.navigateTo({
						url: '/pages/lanhu_xuexi/index'
					});
				}

				if (tab == '我的收藏') {
					uni.navigateTo({
						url: '/pages/lanhu_shoucang/index'
					});
				}

				if (tab == '帮助中心') {
					uni.navigateTo({
						url: '/pages/user/help'
					});
				}

				if (tab == '用户反馈') {
					uni.navigateTo({
						url: '/pages/user/feedback/feedback'
					});
				}

				if (tab == '联系客服') {

					// uni.navigateTo({
					// 	url: '/pages/user/service'
					// });
				}

				if (tab == '关于我们') {
					uni.navigateTo({
						url: '/pages/lanhu_guanyuwomen/index'
					});
				}

				if (tab == '个人信息') {
					uni.navigateTo({
						url: '/pages/user/setting/user'
					});
				}



			}
		}
	};
</script>
<style lang='css'>
	@import '../common/common.css';
	@import './assets/style/index.rpx.css';

	button[plain] {
		border: 0
	}

	button::after {
		border: none;
	}

	uni-button:after {

		border: none
	}
</style>