<template>
	<view class="container">
		<view class="page-block">
			<view class="page-title-block">
				<view class="title">合伙人等级详情</view>
			</view>
			<view class="content">

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>等级</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.shared_level}}级</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>等级名称</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.name}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>缴纳费用</text>
					</view>
					<view class="desc">
						<view class="input-box">￥{{info.money}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>直接佣金比例(%)</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.direct_commission}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>间接佣金比例(%)</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.indirect_commission}}</view>
					</view>
				</view>
				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>状态</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.status==1?'启用':'禁用'}}</view>
					</view>
				</view>


				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>显示位置</text>
					</view>
					<view class="desc">
						<view class="input-box">
							<block v-if="info.location == 1">仅微信</block>
							<block v-if="info.location == 2">仅支付宝</block>
							<block v-if="info.location == 3">微信和支付宝</block>
						</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>礼盒数量</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.gift}}</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>赠送积分</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.integral}}</view>
					</view>
				</view>

				<view class="cell flex flex-y-center">
					<view class="title-block">
						<text>赠送余额</text>
					</view>
					<view class="desc">
						<view class="input-box">{{info.balance}}</view>
					</view>
				</view>
			</view>
		</view>

		<view style="height:30rpx;"></view>
		<view class="footer-bar" style="height: 100rpx;">
			<view class="content flex flex-center" style="height: 100rpx;">
				<view class="detail-btn flex flex-center" @click="del" style="border-right: 2rpx solid #F4F5F7;">
					<image src="../static/images/icon_16.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#999999">删除合伙人等级</view>
				</view>
				<view class="detail-btn flex flex-center" @click="enit">
					<image src="../static/images/icon_17.png" mode="aspectFit" class="btn-icon"></image>
					<view style="color:#3387FF">重新编辑</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {},
				type: 2,
				store_id: '',
				id: '',
				admin_id: '',
				tableTypeList: [],
				shop_title: ''
			}
		},

		onLoad(e) {
			this.store_id = uni.getStorageSync("store_id");
			this.admin_id = uni.getStorageSync("admin_id");
			this.id = e.id;
			this.type = e.type || 2;
			this.getData(this.id)
			// this.shop_store_index();
		},

		methods: {
			shop_store_index() {
				this.request({
					url: 'Smdcshop/shop_store_index',
					data: {
						admin_id: this.admin_id,
					}
				}).then(res => {
					if (res.code == 200) {
						this.tableTypeList = res.data;
						this.getData(this.id)
					}
				})
			},

			enit() {
				let info = this.info;
				uni.redirectTo({
					url: `./addPartner?id=${info.id}`
				})
			},
			del() {
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2]; //上级页面
				uni.showModal({
					title: '提示',
					content: '是否要删除？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url: 'smdcshop/shared_level_delect',
								data: {
									id: this.id,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === 200 || res.code === "200") {
									uni.showToast({
										title: res.message,
										icon: "none",
									})
									prevPage.__data__.page = 1;
									prevPage.__data__.list = [];
									prevPage.$vm.getData(1)
									setTimeout(() => {
										uni.navigateBack()
									}, 2000)
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: "none",
								})
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getData(id) {
				this.request({
					url: 'smdcshop/shared_level_info',
					data: {
						id: id
					}
				}).then(res => {
					if (res.code == "200") {
						this.info = res.data;
						if (this.tableTypeList.length > 0) {
							for (let i of this.tableTypeList) {
								if (i.id == Number(res.data.storeid)) {
									this.shop_title = i.title;
								}
							}
						}


					}
				})
			}
		}
	}
</script>
<style>
	@import url("../static/css/common.css");

	page {
		background-color: #F4F5F7;
	}
</style>
