<!--  -->
<template>
	<view class="content">
			<view style="width: 100%; height: 44px;"></view>
			<view class="top-heder">
				<view class="t-left" @click="getfan()">
					<uni-icons type="left" size="18"></uni-icons>
				</view>
				<view class="t-input">
					<uni-icons type="search" color="#BCBCBC" size="22"></uni-icons>
					<input type="text" v-model="goodsTitle" placeholder="优惠券">
				</view>
				<view class="sou" @click="getindex()">搜索</view>
			</view>
			<!-- <view class="top-tap">
				<view class="tap-box" v-for="(item,index) in taplist" :key="index" @click="gettapindex(index,item.id)">
					<text :class="{'lan':isListing == item.id}">{{item.Text}}</text>
					<view class="gang" v-if="isListing == item.id"></view>
				</view>

			</view> -->
			<view class="mub">
			<view class="top-ail">
				<view class="jsy" v-if="goodsList.length == 0">
					<image src="http://www.nuoyunr.com/lananRsc/detection/qs.png" mode=""></image>
				</view>
				<view class="a-box" v-for="(item,index) in goodsList" :key="index">
					<view class="t-box">
						<view class="s-img">
							<image src="../../static/detection/yhq.png" mode=""></image>
						</view>
						<view class="s-right">
							<view class="s-title">{{item.title || ''}}</view>
							<view class="hui">{{item.bindGoodsName||''}}</view>
							<view class="hui">{{item.startTime}}-{{item.expirationTime}}</view>
							<view class="s-ju">￥{{item.discount/100 || ''}}</view>
						</view>
						<view class="bottom-box" @click="deleteid(item.id)">
							<text>删除</text>
						</view>
					</view>

				</view>
			</view>
			</view>

		<!-- 底部 -->
		<view class="anniu" @click="couponadd()">
			<text>+ 新增</text>
		</view>

	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request';
	export default {
		data() {
			return {
				msg:'3',
			    goodsList:[],
				baseUrl:this.$baseUrl,
				partnerId:'',
				isListing:1,
				goodsTitle:"",
				taplist:[
					{Text:'已发布',id:1},
					{Text:'待上架',id:0},
				],
				pageNum: 1,//第几页
				pageSize: 10,//一页多少张
				totalPages: 0,//总数
			}
		},
		onLoad() {

		},
		onPullDownRefresh() {
					uni.showLoading()
					setTimeout(() => {
						uni.hideLoading()
						uni.stopPullDownRefresh()
					}, 500)
				},
		onReachBottom() {
					if (this.pageNum >= this.totalPages) {
						uni.showToast({
							title: '没有下一页数据',
							icon: 'none'
						})

					} else {
						this.pageNum++
						this.getindex()
					}
				},
		onShow() {
			// this.baseUrl = this.$baseUrl
			this.partnerId = uni.getStorageSync('partnerId')
			this.getindex()
		},
		methods: {
			async getindex(){
				// 首页信息
				let data = {
					partnerId:this.partnerId,
					searchValue:this.goodsTitle,
					pageSize:this.pageSize,
					pageNum:this.pageNum
				}
				let res = await request({

					url:'/partnerOwn/partner/listCoupon',
					method: 'get',
					params: data
				})
				if(res.code == 200){
						this.goodsList = res.rows
						let total =  res.total
						this.totalPages = Math.ceil(total / this.pageSize);
				}

			},
		async deleteid(id){
			let data = {
				partnerId :this.partnerId,
				id:id
			}
			let res = await request({
				url:'/partnerOwn/partner/delCoupon',
				method: 'post',
				params: data
			})
			if(res.code == 200 ){
				uni.showToast({
					title:'删除成功'
				})
			}
			this.getindex()
		},

			gettapindex(index,id){
				this.isListing = id
				this.getindex()
			},
			couponadd(){
			uni.navigateTo({
				url:'/pages/coupon/couponadd'
			})
			},
			getfan(){
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		box-sizing: border-box;
		width: 100%;
		height: calc(100vh);
		background: white;
	}

	.top-heder{
		width: 100%;
		height: 46px;
		background: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		padding: 5px 15px;
	}
	.t-left{
		width: 10%;
	}
	.t-input{
		width: 75%;
		height: 36px;
		background: #F0F0F0;
		border-radius: 50px;
		box-sizing: border-box;
		padding: 0 15px;
		display: flex;
		align-items: center;

	}
	.top-ail{
		width: 100%;
		box-sizing: border-box;
		padding: 15px;
		background-color: #F4F4F4;

	}
	.sou{
		width: 10%;
		margin-left: 5px;
	}
	.mub{
		background-color: #F4F4F4;
		height: calc(100vh);
	}
	.dix{
		display: flex;
		align-items: center;
	}
	.anniu{
		width: 90%;
		height: 40px;
		border-radius: 50px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #327DFB;
    color: white;
		position: fixed;
		bottom: 10px;
		  transform: translate(-50%);
		      left: 50%;
	}
	.top-tap{
		width: 100%;
		height: 44px;
		display: flex;
		justify-content: space-between;
		align-items: center;

	}
	.tap-box{
		width: 50%;
		height: 100%;
		text-align: center;
		font-size: 16px;
		font-weight: 400;
		color: #606266;
		box-sizing: border-box;
		padding-top: 10px;
	}
	.gang{
		width: 30px;
		height: 4px;
		background: #0D2E8D;
		border-radius: 4px;
		margin: 4px auto;
	}
	.a-box{
		width: 100%;
		border-radius: 8px;
		background-color: white;
		box-sizing: border-box;
		padding: 15px;
		margin-bottom: 10px;
	}
	.t-box{
		width: 100%;
		box-sizing: border-box;

		display: flex;
		// border-bottom:  1px solid #EEEEEE;
	}
	.s-img{
		width: 50px;
		height: 50px;
		margin-right: 10px;
		overflow: hidden;
		border-radius: 8px;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.s-right{
		width: 65%;
	}
	.s-title{
		font-size: 18px;
		font-weight: bold;
		color: #333333;
	}
	.s-hui{
		font-size: 15px;
		font-weight: 400;
		color: #999999;
		margin: 10px auto;
	}
	.hui{
		font-size: 15px;
		font-weight: 400;
		color: #999999;
	}
	.s-ju{
		font-size: 18px;
		font-weight: bold;
		color: #FF571A;
	}
	.d-bottom{
		width: 100%;
		box-sizing: border-box;
		padding-top: 10px;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	.bottom-box{
		width: 66px;
		height: 31px;
		background: #DAE1F8;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50px;
		font-size: 15px;
		font-weight: 400;
		color: #0D2E8D;
		margin-left: 5px;
	}
	.lan{
		color: #0D2E8D !important;
	}
	.jsy{
		width: 100%;
		margin-top: 20px;
		text-align: center;
		color: #0D2E8D !important;
	}
</style>
