<template>
	<view>
		<view style="color: #000000;">
			<tn-nav-bar backgroundColor="#ffffff" :bottomShadow="false">{{commission_alias}}</tn-nav-bar>
			<view :style="{height: tobheight+'px'}"></view>
		</view>
		<view style="width:100%;height: 100%;">

			<view class="commission-wrap" :class="{ blur: !hasAuth }">
				<!-- 用户资料 -->
				<view class="user-card">
					<view class="card-top u-flex u-row-between">
						<view class="u-flex">
							<view class="head-img-box">
								<image class="head-img" :src="userInfo.avatar?userInfo.avatar:'/static/images/head.jpg'"
									mode=""></image>
							</view>
							<view class="u-flex-col">
								<view class="user-name">{{ userInfo.nickname }}</view>
								<view class="user-info-box u-flex">
									<view class="tag-box u-flex">
										<!-- <image v-if="commissionLv.image" class="tag-img" :src="commissionLv.image" mode=""></image> -->
										<text class="tag-title">{{ commissionLv.name }}</text>
										<!-- <view v-show="showLv" class="u-iconfont uicon-arrow-right" style="color: #fff;font-size: 28rpx;"></view> -->
									</view>
								</view>
							</view>
						</view>
						<view class="u-flex-col">
							<view class="u-flex-col u-col-center">
								<button class="u-reset-button log-btn u-m-b-20" @tap="toTeam">明细</button>
								<button class="u-reset-button look-btn" @tap="showMoney = !showMoney">
									<!-- <view class="u-iconfont" :class="showMoney ? 'uicon-eye-fill' : 'uicon-eye-off'" style="color: #fff;font-size: 50rpx;"></view> -->
									<u-icon :name="showMoney ? 'eye-fill':'eye-off'" color="#fff" size="22"></u-icon>
								</button>
							</view>
						</view>
					</view>
					<!-- 收益 -->
					<view class="card-bottom u-flex">
						<view class="u-flex-1 ">
							<view class="item-title">累计收入</view>
							<view class="item-detail">{{showMoney? money_total || 0.00:'****'}}</view>
						</view>
						<view class="u-flex-1 u-col-center">
							<view class="item-title">待入账佣金</view>
							<view class="item-detail">{{showMoney? on_cashout_money || 0.00:'****'}}</view>
						</view>
					</view>
				</view>

				<!-- 滚动明细 -->
				<view class="commission-log">
					<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box log-scroll">
						<view class="log-item-box u-flex u-row-between" v-for="item in commissionLog" :key="item.id"
							@tap="$u.toast(item.remark)">
							<view class="log-item-wrap">
								<view class="log-item u-flex u-ellipsis-1 u-col-center">
									<view class="u-flex u-col-center ">
										<!-- <image
											class="log-img"
											:src="item.oper_type !== 'user' ? logMap[item.oper_type] : item.oper ? item.oper.avatar : logMap['admin']"
											mode=""
										></image> -->
										<image class="log-img" :src="appInfo.site_logo_path" mode=""></image>
									</view>
									<view class="log-text u-ellipsis-1">{{ item.remark }}</view>
								</view>
							</view>
							<text class="log-time">{{ item.createtime }}</text>
						</view>
						<!-- 更多 -->
						<!-- <view class="loadmore-wrap" v-if="commissionLog.length"><u-loadmore :status="loadStatus" icon-type="flower" color="#f6f6f6" /></view> -->
					</scroll-view>
				</view>

				<!-- 功能菜单 -->
				<view class="menu-box u-flex">
					<view class="menu-item u-flex-col u-col-center" v-for="(menu, index) in menuList"
						v-if="!menu.isAgentFrom" :key="index" @tap="jump(menu.path)">
						<image class="item-img" :src="menu.img" mode=""></image>
						<view class="item-title">{{ menu.title }}</view>
					</view>
					<!-- #ifdef H5 -->
					<view @click="createPoster" class="menu-item u-flex-col u-col-center">
						<image class="item-img" src="https://file.shopro.top/imgs/commission/commission_icon5.png"
							mode=""></image>
						<view class="item-title">分享海报</view>
					</view>


					<view @click="sharelink" class="menu-item u-flex-col u-col-center">
						<image class="item-img" src="https://file.shopro.top/imgs/commission/commission_icon7.png"
							mode=""></image>
						<view class="item-title">分享链接</view>
					</view>
					<!-- #endif -->
				</view>
				<!-- #ifdef H5 -->
				<!-- <view class="bill">
					<u-button @click="createPoster" color="#ffc107" type="primary" shape="circle" text="推广海报"></u-button>
				</view> -->
				<!-- #endif -->


			</view>

			<!-- 佣金中心权限验证 -->
			<u-popup class="auth-box" :mask="false" v-model="showAuthModal" mode="center" :mask-close-able="false"
				close-icon-pos="top-left" border-radius="20">
				<view class="notice-box">
					<view class="img-wrap">
						<image class="notice-img" :src="authNotice.img" mode=""></image>
					</view>
					<view class="notice-title">{{ authNotice.title }}</view>
					<view class="notice-detail">{{ authNotice.detail }}</view>
					<button class="u-reset-button notice-btn"
						@tap="onAuthBtn(authNotice.btnPath)">{{ authNotice.btnText }}</button>
					<button class="u-reset-button back-btn" @tap="$Router.back()" v-if="!authNotice.hideBtn">返回</button>
					<button class="u-reset-button back-btn" @tap="hasAuth = true" v-else>取消</button>
				</view>
			</u-popup>

			<!-- 成为分销商条件 -->
			<u-popup v-if="showTerm" class="into-agent-modal" :bgStyle="{
					background: 'none'
				}" v-model="showTerm" mode="center" :mask="false" :mask-close-able="false">
				<view class="condition-box u-flex u-row-center u-col-center">
					<!-- 金额人数 -->
					<view class="goods-condition u-flex u-row-between" v-if="showMoneyTerm">

						<view class="btn-box u-flex-col u-p-20 u-col-center">
							<button class="u-reset-button buy-btn u-m-b-10" @tap="$Router.back()">知道了</button>
							<view class="tips">* 满足指定消费金额即可成为分销商</view>
						</view>
					</view>
				</view>
			</u-popup>
		</view>
		<!-- <wike-loading-page :isLoading="isLoading"></wike-loading-page> -->
		<!-- <u-popup :show="showPoster" mode="bottom" :round="10" @close="close">
			<view class="poster">
				<wike-painter :board="posterObj" @success="posterSuccess" ref="painter"></wike-painter>
				<view class="footer-btn">
					<view class="" @click="showPoster = false">退出</view>
					<view class="save" @click="toSave">保存/分享</view>
				</view>
			</view>
		</u-popup> -->
		<u-popup :show="showPoster" mode="bottom" @close="showPoster = false">
			<!-- <view :style="{height: tobheight+'px'}"></view> -->
			<scroll-view scroll-y="true" :style="{maxHeight: posterheight +'px'}">

				<wike-painter :board="posterObj" @done="posterSuccess" ref="painter"></wike-painter>
				<view style="height: 78px;"></view>
				<view class="dygbhg">
					<view class="whole" @click="showPoster = false">取消</view>
					<view class="distinguish" @click="toSave">保存/分享</view>
				</view>
			</scroll-view>


		</u-popup>
		<wike-loading-page :isLoading="isLoading"></wike-loading-page>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				isLoading: true,
				tobheight: 45,
				platform: this.$platform.get(),
				showAuthModal: true,
				empty: false,
				team: [{
					headimg: 'https://dev.iduomi.cc/attachment/headimg_2.jpg?time=1673514485',
					nickname: '多级火箭好',
					times: '2020/12/24'
				}, {
					headimg: 'https://dev.iduomi.cc/attachment/headimg_2.jpg?time=1673514485',
					nickname: '多级火箭好',
					times: '2020/12/24'
				}, {
					headimg: 'https://dev.iduomi.cc/attachment/headimg_2.jpg?time=1673514485',
					nickname: '多级火箭好',
					times: '2020/12/24'
				}],
				pages: 1,
				currentTab: 0,
				navbar: [{
						name: "下一级",
						type: 'shareuid'
					}, {
						name: "下下级",
						type: 'shareuid_grandpa'
					},
					// {
					// 	name: "下三级",
					// 	type:'shareuid_great_grandpa'
					// },
				],
				showShare: false, //是否显示分享海报
				showMoney: true, //是否显示金额
				hasAuth: true, //是否有权限
				commissionLv: {
					name: '合伙人'
				},
				//合伙人等级
				commissionWallet: null, //合伙人钱包
				agentFrom: null, //是否显示我的资料
				showLv: true,
				commissionLog: [{
					id: 1,
					oper_type: 'gf',
					oper: 'https://file.shopro.top/imgs/commission/commission_icon1.png',
					remark: '恭喜您成为了合伙人',
					createtime: 1676428876
				}], //动态
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 1,
				lastPage: 1,
				logMap: {
					system: this.$IMG_URL + '/imgs/commission/commission_base_notice.png',
					admin: this.$IMG_URL + '/imgs/commission/commission_base_avatar.png'
				},
				showTerm: true, //条件弹窗
				showGoodsTerm: false, //商品条件
				showMoneyTerm: false, //金额条件
				goodsTermList: [],
				moneyTermNum: 0,
				authNotice: {},
				menuList: [
					//menu
					{
						img: 'https://file.shopro.top/imgs/commission/commission_icon1.png',
						title: '我的团队',
						path: '/pages/user/commission/team'
					},
					{
						img: 'https://file.shopro.top/imgs/commission/commission_icon2.png',
						title: '佣金明细',
						path: '/pages/user/commission/commission-log'
					},
					{
						img: 'https://file.shopro.top/imgs/commission/commission_icon4.png',
						title: '推广套餐',
						path: '/pages/user/commission/goods',

					},
					{
						img: 'https://file.shopro.top/imgs/commission/commission_icon3.png',
						title: '提现佣金',
						path: '/pages/user/commission/withdraw',

					},


					// {
					// 	img: 'https://file.shopro.top/imgs/commission/commission_icon6.png',
					// 	title: '排行榜',
					// 	path: '/pages/user/commission/rankings'
					// },
					{
						img: 'https://file.shopro.top/imgs/commission/commission_icon8.png',
						title: '提现记录',
						path: '/pages/user/commission/withdraw-log',

					},
					// {
					// 	img: 'https://file.shopro.top/imgs/commission/commission_icon5.png',
					// 	title: '分享海报',
					// 	path: '/pages/user/commission/withdraw',
					// },
					// {
					// 	img: 'https://file.shopro.top/imgs/commission/commission_icon7.png',
					// 	title: '分享记录',
					// 	path: '/pages/app/commission/share-log',

					// }
				],
				money_total: '0.00',
				on_cashout_money: '0.00',
				showPoster: false,
				posterObj: {},
				posterfff: '您好，我是AI语言模型，可以帮助你做很多事情。例如:\n- 回答你的问题\n- 给你提供某些信息\n- 帮你搜索网页\n- 聊天和闲聊\n- 玩一些小游戏\n- 计算数学题\n- 翻译语言\n- 生成文本\n等等.....\n如果你有任何问题或需要帮助，请随时告诉我。',
				spmplatform: 0,
				is_examine: 1,
				commission_price: 0,
				info: {},
				posterheight: 0,
                poster_bg_img_path:'',
				commission_alias:''
			}
		},
		computed: {
			...mapGetters(['appInfo', 'isLogin', 'userInfo'])
		},
		onLoad() {
			// this.getInviteList()

			const that = this;

			if (this.platform == 'wxMiniProgram') {
				var menumtop = uni.getMenuButtonBoundingClientRect().top - uni.getSystemInfoSync().statusBarHeight
				var paddingtop = uni.getSystemInfoSync().statusBarHeight + menumtop
				this.tobheight = (menumtop + paddingtop + uni.getMenuButtonBoundingClientRect().height)
			}
			this.posterheight = uni.$u.sys().windowHeight - this.tobheight
			this.spmplatform = ['H5', 'wxOfficialAccount', 'wxMiniProgram', 'App'].indexOf(this.platform) + 1;

			this.commonqrcodePath()
			// console.log('http://vmoushivideomerge.oss-cn-shanghai.aliyuncs.com/20230422/96f1f662dcfc68cb3eff1dcbf660ed92.jpg');
			// that.$base64.imageUrlToBase64('http://vmoushivideomerge.oss-cn-shanghai.aliyuncs.com/20230422/96f1f662dcfc68cb3eff1dcbf660ed92.jpg')

		},
		onShow() {

			this.islogin();
		},
		methods: {
			islogin() {
				var that = this;
				if (!this.isLogin) {
					uni.navigateTo({
						url: '../user/signin'
					});
				} else {
					this.commission()
					// this.getCheck()
				}

			},
			commission() {
				let that = this;
				that.$http('conf.getGroupConf', {
					group: 'system.commission'
				}).then(res => {
					if (res.code === 0) {
						that.info = res.data
						that.commission_alias = res.data.commission_alias?res.data.commission_alias:'分销中心'
						if (res.data.is_examine) {
							that.is_examine = res.data.is_examine
							// console.log(that.is_examine);
						}
						if (res.data.commission_price) {
							that.commission_price = res.data.commission_price
						}
						if (res.data.is_ranking == 1) {
							if (that.menuList.length == 5) {
								let obj = {
									img: 'https://file.shopro.top/imgs/commission/commission_icon6.png',
									title: '排行榜',
									path: '/pages/user/commission/rankings'
								};
								that.menuList.splice(2, 0, obj);
							}
						}
						that.getCheck()
					}
				});
			},
			commonqrcodePath() {
				let spm = this.userInfo.id + '.1.0.' + this.spmplatform + '.1';
				// console.log(spm);
				this.$http('common.qrcodePath', {
					spm: spm
				}).then(res => {
					if (res.code == 0) {
						this.qrcode = res.data;

					}
				});
			},
			sharelink() {
				let spm = this.userInfo.id + '.1.0.' + this.spmplatform + '.1';
				// #ifdef MP-WEIXIN
				let url = '/pages/index/index?' + 'spm=' + spm
				uni.setClipboardData({
					data: url,
					success: function() {
						uni.showToast({
							title: '复制链接成功'
						});
					}
				});
				// #endif
				// #ifdef H5
				let uniacid = uni.getStorageSync('uniacid');
				if (uniacid) {
					let url = window.location.href.split('/h5')[0] + '/h5/?uniacid=' + uniacid + '&spm=' + spm;
					uni.setClipboardData({
						data: url,
						success: function() {
							uni.showToast({
								title: '复制链接成功'
							});
						}
					});
				} else {
					uni.showToast({
						title: '复制链接失败',
						icon: 'none'
					})
				}
				// #endif

			},
			getdownload(e){
				return new Promise((resolve, reject) => {
				uni.request({
				                        url: e,
				                        method:'GET',
				                        responseType:'arraybuffer',
				                        success: ress => {
				                            let base64 = wx.arrayBufferToBase64(ress.data); 
				                            base64 = 'data:image/jpeg;base64,' + base64
											resolve(base64);
				                        },
										fail: (e) => {
				                            resolve('fail');
				                        }
				                    })
				});
			},
			posterSuccess(){
				uni.hideLoading();
			},
			async createPoster(e) {
				let that = this;
				let httpsurl = '';
				uni.showLoading({
					title: '海报渲染中'
				});
				
				if(that.info.poster_bg_img_path.indexOf("https") < 0){
					httpsurl = await that.getdownload(that.info.poster_bg_img_path.replace("http:", "https:"));
				}else{
					httpsurl = await that.getdownload(that.info.poster_bg_img_path);
				}
				if(httpsurl == 'fail'){
					uni.hideLoading();
					uni.showToast({
						title:'生成失败',
						icon:'none'
					})
					return;
				}
				let proportionally = this.info.poster_bg_width / uni.$u.sys().windowWidth;
				// console.log(this.info.poster_bg_width,(this.info.poster_bg_width / proportionally));
				// console.log(this.info.poster_bg_height,(this.info.poster_bg_height / proportionally));
				// console.log(this.info.poster_qrcode_x,(this.info.poster_qrcode_x / proportionally));
				// console.log(this.info.poster_qrcode_y,(this.info.poster_qrcode_y / proportionally));
				// console.log(this.info.poster_qrcode_width,(this.info.poster_qrcode_width / proportionally));
				(this.posterObj = {
					width: (this.info.poster_bg_width / proportionally) + 'px',
					height: (this.info.poster_bg_height / proportionally) + 'px',
					background: '#fff',
					borderRadius: '16rpx',

					views: [{
							src: httpsurl,
							type: "image",
							css: {
								width: (this.info.poster_bg_width / proportionally) + 'px',
								height: (this.info.poster_bg_height / proportionally) + 'px',
							}
						},
						// {
						// 	src: this.userInfo.avatar ? this.userInfo.avatar : '/static/images/head.jpg',
						// 	type: "image",
						// 	css: {
						// 		width: '100rpx',
						// 		height: '100rpx',
						// 		borderRadius: '50%',
						// 		position:'fixed',
						// 		left: '286rpx',
						// 		top: '258rpx',
						// 		objectFit:'cover'
						// 	}
						// },
						{
							type: 'view',
							css: {
								left: (this.info.poster_qrcode_x / proportionally) + 'px',
								top: (this.info.poster_qrcode_y / proportionally) + 'px',
								position: 'fixed',

							},
							// #ifdef H5
							views: [{
								type: 'qrcode',
								text: this.qrcode,
								css: {
									width: (this.info.poster_qrcode_width / proportionally) + 'px',
									height: (this.info.poster_qrcode_width / proportionally) + 'px',
									background: '#fff'
								}
							}],
							// #endif
							// #ifdef MP-WEIXIN
							views: [{
								type: 'image',
								src: this.qrcode,
								css: {
									width: (this.info.poster_qrcode_width / proportionally) + 'px',
									height: (this.info.poster_qrcode_width / proportionally) + 'px',
									background: '#fff'
								}
							}]
							// #endif
						}
					]

					// views: [
					// 	{
					// 		type: 'view',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			paddingLeft: '10rpx',
					// 			display: 'flex'
					// 		},
					// 		views: [
					// 			{
					// 				type: 'image',
					// 				src: this.userInfo.avatar ? this.userInfo.avatar : '/static/images/head.jpg',
					// 				css: {
					// 					marginTop: '10rpx',
					// 					marginLeft: '10rpx',
					// 					borderRadius: '16rpx',
					// 					width: '80rpx',
					// 					height: '80rpx',
					// 					border: '2rpx solid #fff',
					// 					objectFit: 'cover'
					// 				}
					// 			},
					// 			{
					// 				type: 'view',
					// 				css: {
					// 					marginTop: '10rpx',
					// 					marginLeft: '20rpx'
					// 				},
					// 				views: [
					// 					{
					// 						type: 'view',
					// 						views: [
					// 							{
					// 								type: 'text',
					// 								text: this.userInfo.nickname?this.userInfo.nickname:'提问者',
					// 								css: {
					// 									marginTop: '10rpx',
					// 									fontSize: '28rpx',
					// 									fontWeight: 'bold',
					// 									color: '#1A2033',
					// 									lineHeight: '28rpx'
					// 								}
					// 							}
					// 						]
					// 					},
					// 					{
					// 						type: 'view',
					// 						views: [
					// 							{
					// 								type: 'text',
					// 								text: '我的提问',
					// 								css: {
					// 									marginTop: '15rpx',
					// 									fontSize: '22rpx',
					// 									color: '#999',
					// 									lineHeight: '25rpx'
					// 								}
					// 							}
					// 						]
					// 					}
					// 				]
					// 			}
					// 		]
					// 	},
					// 	{
					// 		type: 'view',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			width: '610rpx',
					// 			padding: '10rpx',
					// 			background: '#d2f8d3',
					// 			borderRadius: '16rpx',
					// 			marginLeft: '20rpx',
					// 			marginRight: '10rpx'
					// 		},
					// 		views: [
					// 			{
					// 				type: 'text',
					// 				text: 'hello！你可以帮我做些什么呢？',
					// 				css: {
					// 					fontSize: '28rpx',
					// 					color: '#1A2033',
					// 					lineHeight: '45rpx',
					// 					lineClamp: 2,
					// 					paddingLeft: '10rpx',
					// 					paddingRight: '10rpx',
					// 					width: '590rpx'
					// 				}
					// 			}
					// 		]
					// 	},
					// 	{
					// 		type: 'view',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			paddingLeft: '10rpx',
					// 			display: 'flex'
					// 		},
					// 		views: [
					// 			{
					// 				type: 'image',
					// 				src: this.appInfo.page_template == 3?'/static/images/open1.png':'/static/images/open.png',
					// 				css: {
					// 					marginTop: '10rpx',
					// 					marginLeft: '10rpx',
					// 					borderRadius: '16rpx',
					// 					width: '80rpx',
					// 					height: '80rpx',
					// 					border: '2rpx solid #fff',
					// 					objectFit: 'cover'
					// 				}
					// 			},
					// 			{
					// 				type: 'view',
					// 				css: {
					// 					marginTop: '10rpx',
					// 					marginLeft: '20rpx'

					// 				},
					// 				views: [
					// 					{
					// 						type: 'view',
					// 						views: [
					// 							{
					// 								type: 'text',
					// 								text: this.appInfo.site_name,
					// 								css: {
					// 									marginTop: '10rpx',
					// 									fontSize: '28rpx',
					// 									fontWeight: 'bold',
					// 									color: '#1A2033',
					// 									lineHeight: '28rpx'
					// 								}
					// 							}
					// 						]
					// 					},
					// 					{
					// 						type: 'view',
					// 						views: [
					// 							{
					// 								type: 'text',
					// 								text: '回答结果',
					// 								css: {
					// 									marginTop: '15rpx',
					// 									fontSize: '22rpx',

					// 									color: '#999',
					// 									lineHeight: '25rpx'
					// 								}
					// 							}
					// 						]
					// 					}
					// 				]
					// 			}
					// 		]
					// 	},
					// 	{
					// 		type: 'view',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			width: '610rpx',
					// 			padding: '10rpx',
					// 			background: '#f5f6f8',
					// 			borderRadius: '16rpx',
					// 			marginLeft: '20rpx',
					// 			marginRight: '10rpx'
					// 		},
					// 		views: [
					// 			{
					// 				type: 'text',
					// 				text: uni.$u.trim(that.posterfff),
					// 				css: {
					// 					fontSize: '28rpx',
					// 					color: '#1A2033',
					// 					lineHeight: '45rpx',
					// 					lineClamp: 11,
					// 					width: '590rpx',
					// 					padding: '10rpx'
					// 				}
					// 			}
					// 		]
					// 	},
					// 	{
					// 		type: 'view',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			width: '100%',
					// 			textAlign: 'center'
					// 		},
					// #ifdef H5
					// views: [
					// 	{
					// 		type: 'qrcode',
					// 		text: this.qrcode,
					// 		css: {
					// 			width: '200rpx',
					// 			height: '200rpx'
					// 		}
					// 	}
					// ],
					// #endif
					// #ifdef MP-WEIXIN
					// views: [
					// 	{
					// 		type: 'image',
					// 		src: this.qrcode,
					// 		css: {
					// 			width: '200rpx',
					// 			height: '200rpx'
					// 		}
					// 	}
					// ]
					// #endif
					// 	},
					// 	{
					// 		type: 'text',
					// 		text: '————  ' + '长按识别 | 欢迎使用' + '  ————',
					// 		css: {
					// 			marginTop: '20rpx',
					// 			width: '100%',
					// 			textAlign: 'center',
					// 			fontSize: '24rpx',
					// 			color: '#989FB3',
					// 			lineHeight: '33rpx'
					// 		}
					// 	}
					// ]
				}),
				(this.showPoster = true);
			},
			toSave() {
				uni.showLoading({
					title: '海报生成中'
				});
				this.$refs.painter.canvasToTempFilePathSync({
					// 在nvue里是jpeg
					fileType: 'jpg',
					quality: 1,
					success: res => {
						// this.path = res.tempFilePath;
						// this.$refs.posterImg.open();
						// this.show_poster = true;

						// console.log(res.tempFilePath);
						// 非H5 保存到相册
						// H5 提示用户长按图另存
						// #ifdef MP-WEIXIN
						// uni.saveImageToPhotosAlbum({
						// 	filePath: res.tempFilePath,
						// 	success: function() {
						// 		uni.showToast({
						// 			title: '保存成功'
						// 		});
						// 		that.showPoster = false;
						// 	}
						// });

						wx.showShareImageMenu({
							path: res.tempFilePath
						})
						this.showPoster = false;
						uni.hideLoading();
						// #endif
						// #ifdef H5
						this.showPoster = false;
						uni.hideLoading();
						uni.showModal({
							confirmColor: '#26B3A0',
							confirmText: '查看图片',
							title: '提示',
							content: '查看图片后长按图片即可保存或分享',
							success(src) {
								if (src.confirm) {
									uni.previewImage({
										urls: [res.tempFilePath]
									});
								} else if (src.cancel) {
									this.showPoster = true;
								}
							}
						});
						// #endif
					}
				});
			},
			getCheck() {
				var that = this;
				that.$http('commission.auth').then(res => {
					if (res.code == 0) {
						this.isLoading = false
						uni.setNavigationBarTitle({
							title: this.appInfo.site_name
						});

						that.money_total = res.data.money_total > 0 ? res.data.money_total : '0.00'
						that.on_cashout_money = res.data.on_cashout_money > 0 ? res.data.on_cashout_money : '0.00'
						that.commissionLog[0].createtime = res.data.create_time

						// console.log(res.data.paid,this.commission_price);
						// console.log(Number(this.commission_price));

						// if(Number(this.commission_price)>0&&res.data.paid == 0){
						// 	uni.redirectTo({
						// 		url:'/pages/user/commission/apply'
						// 	})
						// }

						// console.log(res.data.status,that.is_examine);
						if (res.data.status == 0 && that.is_examine == 1) {
							uni.showModal({
								confirmText: '确定',
								showCancel: false,
								confirmColor: '#5e49c3',
								content: '分销商申请已提交，等待后台审核通过',
								title: '提示',
								success(res) {
									if (res.confirm) {
										uni.navigateBack()
									}
								}
							})
						}
						if (res.data.status == 2) {
							uni.showModal({
								confirmText: '联系客服',
								confirmColor: '#5e49c3',
								content: '已被禁用，有疑问请咨询客服',
								title: '提示',
								success(res) {
									if (res.confirm) {
										uni.navigateTo({
											url: '/pages/user/public/kefu'
										})
									} else if (res.cancel) {
										uni.navigateBack()
									}
								}
							})
						}
					} else {
						// uni.showModal({
						// 	confirmText:'申请',
						// 	confirmColor:'#5e49c3',
						// 	content:'立即申请成为合伙人',
						// 	title:'提示',
						// 	success(res) {
						// 		if(res.confirm){
						// 			that.commissionapply()
						// 		}else if(res.cancel){
						// 			uni.navigateBack()
						// 		}
						// 	}
						// })
						uni.redirectTo({
							url: '/pages/user/commission/apply'
						})
					}
				});
			},
			commissionapply() {
				var that = this;
				that.$http('commission.apply').then(res => {
					if (res.code == 0) {
						uni.showToast({
							title: '申请成功'
						})
						that.getCheck()
					} else {
						uni.showModal({
							confirmText: '重新申请',
							confirmColor: '#5e49c3',
							content: '合伙人申请失败',
							title: '提示',
							success(res) {
								if (res.confirm) {
									that.commissionapply()
								} else if (res.cancel) {
									uni.navigateBack()
								}
							}
						})
					}
				});
			},
			// 我的团队
			getInviteList() {
				var that = this;
				that.$api('distribution.ulist', {
					uid: this.userInfo.id,
					type: this.navbar[this.currentTab].type
				}).then(res => {
					// console.log(res)
					if (res.data.length > 0) {
						if (that.team.length > 0) {
							var dd = this.team;
							this.team = dd.concat(res.data);
							this.pages++;
						} else {
							this.team = res.data;
							this.pages++;
						}
					} else {
						// this.empty = true
					}
				});
			},
			jump(e) {
				uni.navigateTo({
					url: e
				})
			},
			change(index) {
				this.currentTab = index;
				this.team = [];
				this.pages = 1;
				this.getInviteList()
			},
			toTeam() {
				// uni.navigateTo({
				// 	url:'/pages/user/commission/team'
				// })
				uni.navigateTo({
					url: '/pages/user/commission/commission-log'
				})
			}
		},
		onPullDownRefresh() {
			var that = this;
			// setTimeout(function() {
			// 	this.pages = 1;
			// 	this.team = [];
			// 	that.getInviteList();
			// 	uni.stopPullDownRefresh();
			// }, 1000);
		},
		onReachBottom() {
			// this.getInviteList();
		},
	}
</script>

<style lang="scss" scoped>
	.commission-wrap {
		background: url('http://file.shopro.top/imgs/commission/commission_bg1.jpg') no-repeat;
		background-size: cover;
		height: 100%;
		width: 100%;
		position: absolute;
		background-position: 50%;
		transition: all 0.3s ease-in-out 0s;
		overflow: hidden;
	}

	// 进度条
	.progress-box {
		.progress-tip {
			font-size: 24rpx;
			font-weight: 500;
			color: #c7b2ff;
		}

		.progress-num {
			font-size: 24rpx;
			position: absolute;
			color: #c7b2ff;
			bottom: -30rpx;
			white-space: nowrap;
		}

		.round-wrap {
			width: 30rpx;
			height: 30rpx;
			border: 2rpx solid #5c3cff;
			background: linear-gradient(0deg, #a36fff 0%, #846fff 100%);
			border-radius: 50%;
			position: absolute;
			bottom: -6rpx;
			transform: translateY(-50%);
			left: 0;
			margin-left: -15rpx;

			.round-inner {
				width: 20rpx;
				height: 20rpx;
				border: 2rpx solid #5c3cff;
				background: linear-gradient(0deg, #a36fff 0%, #846fff 100%);
				border-radius: 50%;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}
		}
	}

	// 佣金中心权限验证蒙层
	.blur {
		filter: blur(20rpx);
		transition: all 0.3s ease-in-out 0s;
	}

	.auth-box {
		width: 100%;
		height: 100%;
		background: none;

		.notice-box {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			background-color: #fff;
			width: 612rpx;
			min-height: 658rpx;
			background: #ffffff;
			padding: 30rpx;
			border-radius: 20rpx;

			.img-wrap {
				margin-bottom: 50rpx;

				.notice-img {
					width: 180rpx;
					height: 170rpx;
				}
			}

			.notice-title {
				font-size: 35rpx;
				font-weight: bold;
				color: #46351b;
				margin-bottom: 28rpx;
			}

			.notice-detail {
				font-size: 28rpx;
				font-weight: 400;
				color: #999999;
				line-height: 36rpx;
				margin-bottom: 50rpx;
			}

			.notice-btn {
				width: 492rpx;
				line-height: 70rpx;
				background: linear-gradient(-90deg, #a36fff, #5336ff);
				box-shadow: 0px 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
				border-radius: 35rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #ffffff;
				margin-bottom: 10rpx;
			}

			.back-btn {
				width: 492rpx;
				line-height: 70rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #c5b8fb;
				background: none;
			}
		}
	}

	// 成为分销商
	.into-agent-modal {
		.condition-box {
			width: 640rpx;
			height: 786rpx;
			background: url('http://file.shopro.top/imgs/commission/into_commission.png') no-repeat;
			background-size: 100% 100%;
		}

		.goods-condition {
			width: 484rpx;
			height: 580rpx;
			padding: 80rpx 0 30rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			position: relative;

			.card-wrap {
				width: 484rpx;
				height: 460rpx;
				padding: 10rpx;
				padding-bottom: 30rpx;
			}

			.modal-progress {
				.progress-tip {
					font-size: 24rpx;
				}

				.progress-box {
					margin-right: 10rpx;

					.cu-progress {
						width: 200rpx;
						position: relative;

						.round-wrap {
							width: 20rpx;
							height: 20rpx;
						}

						.round-inner {
							width: 10rpx;
							height: 10rpx;
						}
					}
				}
			}

			.card-box {
				background: rgba(#c3b6ff, 0.3);
				padding: 10rpx;
				border-radius: 10rpx;

				.img-wrap {
					background: #fff;
					width: 110rpx;
					height: 110rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;

					.goods-img {
						width: 110rpx;
						height: 110rpx;
						border-radius: 10rpx;
					}
				}

				.detail {
					height: 110rpx;
					width: 280rpx;
					align-items: flex-start;

					.title {
						font-size: 20rpx;
						font-weight: 500;
						color: #333333;
						line-height: 35rpx;
						text-align: left;
					}

					.sub {
						font-size: 16rpx;
						font-weight: 500;
						color: #9281e2;
						text-align: left;
						width: 280rpx;
					}
				}
			}

			.filter-card {
				filter: grayscale(100%);
				filter: gray;
			}

			.btn-box {
				background-color: #fff;
				width: 100%;
				position: absolute;
				bottom: 0;

				.buy-btn {
					width: 390rpx;
					line-height: 60rpx;
					background: linear-gradient(-90deg, #a36fff, #5336ff);
					box-shadow: 0px 7rpx 11rpx 2rpx rgba(124, 103, 214, 0.34);
					border-radius: 35rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #ffffff;
				}

				.tips {
					font-size: 20rpx;
					font-weight: 500;
					color: #9281e2;
				}
			}
		}
	}

	// 用户资料卡片
	.user-card {
		width: 690rpx;
		min-height: 350rpx;
		border-radius: 14rpx;
		margin: 30rpx;
		background: url('http://file.shopro.top/imgs/commission/commission_card_bg.png') no-repeat;
		background-size: 100% 100%;
		padding-top: 10rpx;

		.card-top {
			padding: 40rpx 40rpx 30rpx;
			margin-bottom: 30rpx;
			border-bottom: 1px solid rgba(#fff, 0.12);

			.user-name {
				font-size: 26rpx;
				font-weight: 500;
				color: #ffffff;
				line-height: 30rpx;
				margin-bottom: 20rpx;
			}

			.log-btn {
				width: 86rpx;
				line-height: 41rpx;
				border: 1rpx solid rgba(#ffffff, 0.33);
				border-radius: 32rpx;
				font-size: 22rpx;
				font-weight: 400;
				color: #ffffff;
			}

			.look-btn {
				color: #fff;
				font-size: 40rpx;
			}
		}

		.head-img-box {
			margin-right: 26rpx;
			width: 76rpx;
			height: 76rpx;
			border-radius: 50px;
			position: relative;
			background: #fff;
			padding: 10rpx;
			background-clip: padding-box;

			.head-img {
				width: 66rpx;
				height: 66rpx;
				border-radius: 50%;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}
		}

		.user-info-box {
			.tag-box {
				background: rgba(0, 0, 0, 0.2);
				border-radius: 21rpx;
				line-height: 38rpx;

				.tag-img {
					width: 36rpx;
					height: 36rpx;
					border-radius: 50%;
				}

				.tag-title {
					font-size: 20rpx;
					padding: 0 10rpx;
					font-weight: 500;
					color: rgba(255, 255, 255, 1);
					line-height: 36rpx;
				}
			}
		}

		.card-bottom {
			margin: 0 40rpx 40rpx;

			.item-title {
				font-size: 24rpx;

				font-weight: 400;
				color: #ffffff;
				line-height: 30rpx;
			}

			.item-detail {
				font-size: 40rpx;
				font-family: DIN;
				font-weight: 500;
				color: #fefefe;
				line-height: 30rpx;
				margin-top: 30rpx;
			}
		}
	}

	// 滚动明细
	.commission-log {
		min-height: 400rpx;
		padding: 0 30rpx;
		margin-top: 60rpx;

		.log-scroll {
			height: 380rpx;

			.log-item-box {
				height: 78rpx;

				.log-time {
					margin-left: 30rpx;
					font-size: 22rpx;
					font-weight: 500;
					color: #fefefe;
					text-align: right;
				}
			}

			.loadmore-wrap {
				line-height: 80rpx;
			}

			.log-item {
				height: 48rpx;
				background: rgba(#5e49c3, 0.4);
				border-radius: 24rpx;
				padding-left: 6rpx;
				padding-right: 20rpx;

				.log-img {
					width: 40rpx;
					height: 40rpx;
					border-radius: 50%;
					margin-right: 10rpx;
				}

				.log-text {
					font-size: 22rpx;
					font-weight: 500;
					color: #fefefe;
					max-width: 480rpx;
				}
			}
		}
	}

	// 功能菜单
	.commission-bottom-bg {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 6;
	}

	.menu-box {
		flex-wrap: wrap;
		margin: 30rpx;
		// position: fixed;
		// width: 750rpx;
		bottom: 0;
		z-index: 10;

		.menu-item {
			width: (690rpx/4);
			margin-bottom: 50rpx;

			.item-img {
				width: 68rpx;
				height: 68rpx;
			}

			.item-title {
				font-size: 24rpx;
				font-weight: 600;
				color: #fff;
				line-height: 30rpx;
				margin-top: 16rpx;
			}
		}
	}

	.bill {
		margin: 30rpx;
		font-weight: bold;
	}

	.u-flex-col {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
	}

	.poster {
		padding: 24rpx 40rpx;

		.footer-btn {
			margin-top: 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			view {
				width: 319rpx;
				height: 66rpx;
				border-radius: 40rpx;
				border: 1px solid #4070ff;
				font-size: 26rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #4070ff;
				line-height: 66rpx;
				text-align: center;
			}

			.save {
				background: #4070ff;
				color: #ffffff;
			}
		}
	}

	.dygbhg {
		background: #ffffff;
		border-radius: 15rpx 15rpx 0 0;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-shadow: 0px 0px 10px #00000024;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
	}

	.whole {
		width: 45%;
		height: 88rpx;
		display: flex;
		color: #ffffff;
		align-items: center;
		justify-content: center;
		background: #f3f3f3;
		font-weight: bold;
		border-radius: 60rpx;
		color: #3d7eff;
	}

	.distinguish {
		width: 45%;
		height: 88rpx;
		display: flex;
		color: #ffffff;
		align-items: center;
		justify-content: center;
		background: #3d7eff;
		font-weight: bold;
		border-radius: 60rpx;
		margin: 38rpx 0;
		margin-left: 4%;
	}
</style>