<template>
	<view class="paddtop15">
		<view class="input-box">
			<view class="icon search"></view>
			<input placeholder="请输入商户名称" v-model="mersearchName" placeholder-style="color:#c0c0c0;"
				@input="getMerListBySalesman()" />
		</view>
		<view class="paddbotm10 width100 ">
			<view v-if="merchantlist == '' " class="mart60 fotct font14 fcor666">
				<image mode="widthFix" style="width: 70vw;" src="../../../static/img/noorder.png"></image>
			</view>
			<view class="width94 backcorfff border-r mart15" v-for="(item,index) in merchantlist" :key="index"
				@click="jumpmerdes(item.id)">
				<view class="notes">
					<image src="../../../static/img/merchantstu.png" mode="widthFix" class="iconw40 height40p"></image>
					<view class="width60 margle">
						<view class="font14 fcor333">{{item.merName}}</view>
						<view class="font12 fcor999">
							{{item.createTime | timeFormat('yyyy-mm-dd')}}
							{{item.createTime | timeFormat('hh:mm')}}
						</view>
					</view>
					<!-- <view class="statucs font14">正常</view> -->
				</view>
				<view class="notes" style="padding-top: 5px;padding-bottom: 5px;">
					<view class="width30 fcor333 font15">商户号</view>
					<view class="width30 fcor999 font15">{{item.merNo}}</view>
				</view>
				<view class="notes" style="padding-top: 5px;padding-bottom: 5px;">
					<view class="width30 fcor333 font15">联系人</view>
					<view class="width30 fcor999 font15" v-if="item.regName">{{item.regName}}</view>
					<view class="width30 fcor999 font15" v-else>-</view>
				</view>
				<view class="height45 width100 paddbotm10">
					<button class="btns mart10 margle10" @click.stop="openAccounts(item.id)">开通分账</button>
					<!-- <button class="btns mart10 margle10" @click.stop="bindMerchants(item.id)">分账接收方</button> -->
					<button class="btns mart10 margle10" @click.stop="jumpEquityActivity(item.id)">权益活动</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getMerListBySalesman,
	} from '../../../Utils/Api.js';
	export default {
		data() {
			return {
				merchantlist: [],
				pageNum: 1,
				pageSize: 10,
				isLoadMore: false, //是否加载中
				mersearchName: '' //搜索商户
			}
		},
		onShow() {
			this.merchantlist = [];
			this.pageNum = 1;
			this.isLoadMore = false;
			this.getMerListBySalesman();
		},
		onReachBottom() { //上拉触底函数
			this.getMerListBySalesman()
		},
		methods: {
			//查询商户列表
			getMerListBySalesman() {
				if(this.isLoadMore){
					return
				}
				uni.showLoading({
					title: '加载中'
				})
				let datas = {
					merStatus: 1,
					merName: this.mersearchName,
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}
				getMerListBySalesman(datas).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000' && res.return_data.list != '') {
						this.merchantlist = this.merchantlist.concat(res.return_data.list);
						if (res.return_data.pages == this.pageNum) {
							this.isLoadMore = true;
						} else {
							this.isLoadMore = false;
						}
						this.pageNum = this.pageNum+1;
					} else {
						this.merchantlist = [];
						this.isLoadMore = true;
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						})
					}
				});
			},
			//跳转详情
			jumpmerdes(ids) {
				uni.navigateTo({
					url: '/pages/index/merchant-details/merchant-details?id=' + ids
				})
			}, //开通分账
			openAccounts(item) {
				uni.navigateTo({
					url: '/pages/index/open-Divide_accounts/open-Divide_accounts?id=' + item
				})
			},
			
			//跳转权益活动
			jumpEquityActivity(item) {
				uni.navigateTo({
					url: '/pages/index/equity-activities/equity-activities?id=' + item
				})
			}
		}
	}
</script>

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

	.input-box {
		width: 90%;
		margin-left: 5%;
		// margin-top: 15px;
		margin-bottom: 15px;
		height: 70rpx;
		background-color: #fff;
		border-radius: 10rpx;
		position: relative;
		display: flex;
		align-items: center;

		.icon {
			display: flex;
			align-items: center;
			position: absolute;
			top: 2px;
			left: 5px;
			width: 60upx;
			height: 60upx;
			font-size: 34upx;
			color: #c0c0c0;
		}

		input {
			padding-left: 50upx;
			height: 28upx;
			font-size: 28upx;
			width: 100%;
		}
	}

	.notes {
		width: calc(100% - 40upx);
		display: flex;
		align-items: center;
		padding: 20upx 0 20upx 20upx;
	}

	//正常状态
	.statucs {
		background-color: #e9f9e5;
		color: #84b878;
		text-align: center;
		padding: 2px 5px;
	}

	.btns {
		width: 21%;
		float: left;
		height: 35px;
		line-height: 35px;
		background-color: #0083f5;
		color: #FFFFFF;
		font-weight: bold;
		font-size: 12px;
		padding: 0px;
	}
</style>