<template>
	<view>
		<!-- tabs栏 -->
		<view class="backcorfff width100">
			<QSTabs ref="tabs" :tabs="tabs" animationMode="line2" :current="current" @change="change"
				activeColor="#089bf5" lineColor="#089bf5" minWidth="374">
			</QSTabs>
		</view>

		<!-- 商户信息 -->
		<view class="mart15 width100 backcorfff" v-if="current == 0">
			<view class="notes">
				<view class="fcor666 width25">账号</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{merDesInfo.account.loginName}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">商户ID</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{merDesInfo.merNo}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">手机号</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{merDesInfo.regPhone}}</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">商户状态</view>
				<view class="font14 fcor333 text2 width75 fotrt" v-if="merDesInfo.account.status == 1">正常</view>
				<view class="font14 fcor333 text2 width75 fotrt" v-if="merDesInfo.account.status == 4">违规</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">联系人</view>
				<view class="font14 fcor333 text2 width75 fotrt">-</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">身份证号</view>
				<view class="font14 fcor333 text2 width75 fotrt">-</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">银行卡号</view>
				<view class="font14 fcor333 text2 width75 fotrt">-</view>
			</view>
			<view class="notes">
				<view class="fcor666 width25">所属银行</view>
				<view class="font14 fcor333 text2 width75 fotrt">-</view>
			</view>
		</view>
		<!-- 门店信息 -->
		<view class="mart15 width100" v-else>
			<view class="width94 backcorfff border-r mart15" v-for="(item,index) in storeList" :key="index"
				@click="jumpstoredes(item.id)">
				<view class="notes" style="border-bottom: 0px;">
					<image src="../../../static/img/store/store7.png" mode="widthFix" class="iconw40"></image>
					<view class="width65 margle">
						<view class="font14 fcor333">{{item.name}}</view>
						<view class="font12 fcor999">{{item.updateTime | timeFormat('yyyy-mm-dd hh:mm')}}
							{{item.updateTime | timeFormat('hh:mm')}}
						</view>
					</view>
					<view class="storestus" v-if="item.status == 1">
						正常
					</view>
					<view class="otstatucs" v-if="item.status == 2">
						停用
					</view>
				</view>
				<view class="conts" style="border-bottom: 0px;">
					<image src="../../../static/img/store/store8.png" mode="widthFix" class="iconw"></image>
					<view class="margle10 font14 fcor999">{{item.account.telephone}}</view>
				</view>
				<view class="conts" style="border-bottom: 0px;">
					<image src="../../../static/img/store/store9.png" mode="widthFix" class="iconw"></image>
					<view class="margle10 font14 fcor999">{{item.telephone}}</view>
				</view>
				<view class="conts" style="border-bottom: 0px;">
					<image src="../../../static/img/store/store10.png" mode="widthFix" class="iconw"></image>
					<view class="margle10 font14 fcor999 width90p">{{item.storeRegion.address}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import QSTabs from '../../../components/QS-tabs/QS-tabs.vue';
	import {
		getMerDetail,
		getStoreListByMer
	} from '../../../Utils/Api.js';
	export default {
		components: {
			QSTabs
		},
		data() {
			return {
				tabs: ["商户信息", "门店信息"],
				current: 0, // tabs默认值
				storeList: [], // 门店数据
				merid: '', // 商户id
				merDesInfo: '' // 门店信息

			}
		},
		onLoad(options) {
			this.merid = options.id;
			this.getMerDetail(this.merid);
		},
		methods: {
			//筛选
			change(index) {
				this.$refs.tabs.setFinishCurrent(index);
				this.current = index;
				if (index == 1) {
					this.getStoreListByMer();
				}
			},
			//查询商户信息
			getMerDetail(item) {
				uni.showLoading({
					title: '加载中...'
				})
				let datas = {
					merId: item
				}
				getMerDetail(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data) {
						this.merDesInfo = res.return_data;
					} else {
						uni.showToast({
							title: res.return_msg,
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
			//查询门店列表
			getStoreListByMer() {
				uni.showLoading({
					title: '加载中...'
				})
				let datas = {
					merId: this.merid,
					pageNum: 1,
					pageSize: 10
				}
				getStoreListByMer(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data.list) {
						this.storeList = res.return_data.list;
					} else {
						uni.showToast({
							title: res.return_msg,
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
			//跳转门店详情
			jumpstoredes(item) {
				uni.navigateTo({
					url: '../store-details/store-details?id=' + item
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.notes {
		width: calc(100% - 40rpx);
		display: flex;
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		border-bottom: 1px solid #f6f6f6;
	}

	.storestus {
		padding: 1px 5px;
		color: #91bb88;
		font-size: 14px;
		background-color: #e8fbe6;
	}

	.otstatucs {
		background-color: #fbeee4;
		color: #db8c73;
		font-size: 14px;
		padding: 1px 5px;
	}

	.conts {
		width: calc(100% - 60rpx);
		display: flex;
		align-items: center;
		padding: 0 30rpx 10rpx 30rpx;
	}
</style>
