<template>
	<view class="templist-box">
		<view class="list">
			<view class="item acea-row row-between-wrapper" v-for="(item,index) in tempList" :key="index" @tap="choseTemp(item)">
				<view class="temp-name">
					{{index + 1}}、{{item.name}}
				</view>
				<view class="handle-btn" @tap.stop="del(item)">
					<image src="../../../static/images/del-goods.png"></image>
				</view>
			</view>
		</view>
		<view class="btn-box" @tap.stop="toTemp">新增运费模板</view>
	</view>
</template>

<script>
	import { getTempList } from '@/api/user'
	export default{
		data(){
			return {
				tempList: []
			}
		},
		onShow(){
			this.getTempList()
		},
		mounted(){
			
		},
		methods:{
			choseTemp(item){
				console.log(item,'item')
				let pages = getCurrentPages();
				console.log(pages,'pages')
				let page = pages[pages.length -2]
				if(page.route == 'pages/life/addGoods/index'){
					page.$vm.temp = item.name
					page.$vm.tempId = item.id
					uni.navigateBack({
						delta: 1
					})
				}
			},
			del(item){
				
			},
			getTempList(){
				getTempList().then((res)=>{
					// console.log(res)
					this.tempList = res.data.content
				})
			},
			toTemp(){
				uni.navigateTo({
					url:'/pages/life/temp/index'
				})
			}
		}
	}
</script>

<style lang="less">
	.templist-box{
		width: 100%;
		min-height: 100vh;
		background: #F5F6F7;
		padding: 30rpx 20rpx 110rpx;
		position: relative;
		.list{
			width: 100%;
			padding-bottom: 60rpx;
			.item{
				width: 100%;
				background: #fff;
				padding: 24rpx;
				color: #000;
				font-size: 28rpx;
				margin-bottom: 12rpx;
				.temp-name{
					width: 80%;
					height: 50rpx;
					line-height: 50rpx;
				}
				.handle-box{
					width: 100%;
					height: 46rpx;
					border-top: 2rpx solid #F8F7F7;
					
				}
				.handle-btn{
					margin-left: 12rpx;
					image{
						width: 29rpx;
						height: 29rpx;
					}
				}
			}
		}
		.btn-box{
			width: 690rpx;
			height: 76rpx;
			line-height: 76rpx;
			text-align: center;
			font-size: 34rpx;
			font-weight: 500;
			border-radius: 40rpx;
			background: linear-gradient(134deg, #FFA782 0%, #FF6D31 100%);
			color: #fff;
			position: fixed;
			bottom: 30rpx;
			left: 30rpx;
		}
	}
</style>
