<template>
	<view class="page">

		<!-- #ifdef H5-->
		<uni-nav-bar v-if="!$isWxBrowser()" :fixed="true" background-color="#FFE05C" :border="false" :statusBar="false"
			title="首页" />
		<!-- #endif -->

		<manager v-if="isManager == '1'" :height="height"></manager>
		<attach v-else-if="isManager == '0' && (roleTag == '0' || roleTag ==  '2')"></attach>
		<view :style="{height:height}" v-else-if="isManager == '0' && roleTag == '1'" class="flex-col justify-center">
			<view class="flex-row justify-center">
				<text>合作伙伴相关功能正在建设中...</text>
			</view>
		</view>
<!--		<manager></manager>-->
<!--		<attach></attach>-->
	</view>
</template>

<script>
	import manager from "./manager/manager";
	import attach from "./attach/attach";
	export default {
		components: {
			manager,
			attach
		},
		data() {
			return {
				isManager: '',
				roleTag: '',
				height: '',
				ruleList: [],
				roleList: [],
				roleBindRuleParam: {},
				userInfo: {}
			}
		},
		onLoad() {
			let sysInfo = uni.getSystemInfoSync()
			this.height = sysInfo.windowHeight + 'px'


		},
		onShow() {
			this.userInfo = uni.getStorageSync('spreadUserInfo')
			console.log('时间戳', new Date().getTime())

			this.userInfo = uni.getStorageSync('spreadUserInfo')
			this.isManager = this.userInfo.isManager
			this.roleTag = this.userInfo.roleTag

		},
		methods: {
			// 微信支付
			wechatPay() {
				const that = this;
				// 用户信息
				this.$api.service.wechatPay({
					orderNo: 'CZ20240223125943175'
				}).then((res) => {
					var param = res.data.data;
					uni.requestPayment({
						appId: param.appid,
						timeStamp: param.timestamp + "",
						nonceStr: param.noncestr,
						package: "prepay_id=" + param.prepayid,
						signType: "RSA",
						paySign: param.sign,
						success: res => {
							uni.showToast({
								title: '支付成功!'
							});
							// 刷新用户信息
							that.getUserInfo()
						},
						fail: res => {
							uni.showModal({
								content: '支付失败',
								showCancel: false
							});
						}
					});
				})
			},

		}
	}
</script>

<style scoped lang="scss">
	@import './index.rpx.css';
</style>
