<!-- 编辑-->
<template>

	<view class="content">
			<view style="width: 100%; height: 44px;"></view>
			<view class="top-heder">
				<view class="t-left" @click="getback()">
					<uni-icons type="left" size="18"></uni-icons>
				</view>
				<view class="t-title">
					<text>编辑价格</text>
				</view>
				<view class="t-you"></view>
			</view>
			<!-- 	<view class="top-heder">
					<view class="t-left" @click="getback()">
						<uni-icons type="left" size="18"></uni-icons>
					</view>
					<view class="t-title">
						<text>商品价格</text>
					</view>
					<view class="t-you"></view>
				</view> -->
				
				<u-collapse  accordion :value="'0'"   style="margin-top: 15px;">
						<u-collapse-item  :name="index"  :title="item.skuName" v-for="(item, index) in releasebox.skuList" :key="index">
							<view class="list-box">
							<view class="l-left">代办价格</view>
							<view class="l-right">
								<input type="number" v-model="item.dbPrice" placeholder="请输入代办价格">
							</view>
							</view>
							<view class="list-box">
							<view class="l-left">单位管理员价格</view>
							<view class="l-right">
								<input type="number" v-model="item.dwPrice" placeholder="请输入单位管理员价格">
							</view>
							</view>
							<view class="list-box">
							<view class="l-left">员工价格</view>
							<view class="l-right">
								<input type="number" v-model="item.ygPrice" placeholder="请输入员工价格">
							</view>
							</view>
						</u-collapse-item>
				</u-collapse>				
				<view class="dlanniu" @click="getgoods()" >
					<text>提交</text>
				</view>
			
	</view>
</template>

<script>
	import config from '@/config';
	import request from '../../utils/request';
	import upload from '@/utils/upload.js'
	export default {
		data() {
			return {
				baseUrl:this.$baseUrl,
				goodsId:'',
				one:false,
				two:false,
				three:false,
				show:false,
				guige:false,
				msg:'3',
				tapnum:0,
				value5:'',
				tian:{
					skuName:'',//规格名称
					price:''//规格价格
				},
				fileList4:[],
				fileList6:[],
				taplist:[
					{Text:'已发布'},
					{Text:'待上架'},
				],
				fenlist:[],
				ftitle:null,
				releasebox:{
					id:'',
					partnerId:'',//合作商id
					skuList:[
					{skuName:'安检',price:''},
					{skuName:'环检',price:''},
					{skuName:'安检+环检',price:''},	
					]
				}
			}
		},
		onLoad(option) {
			this.releasebox.id = option.id
		},
		mounted() {
			this.releasebox.partnerId = uni.getStorageSync('partnerId')
			this.getindex()
			
		},
		
		methods: {
			async getindex(){
				// 回显
				let resx = await request({
					url:'/partnerOwn/partner/goodsDetail?goodsId='+this.releasebox.id,
					method: 'get',
				})
				
				console.log(resx);
				this.releasebox = resx.data
				this.releasebox.skuList.forEach(it=>{
					it.dbPrice = it.dbPrice/100
					it.ygPrice = it.ygPrice/100
					it.dwPrice = it.dwPrice/100
				})
	
			},
			async getgoods(){
		
		
			let reqData = 	JSON.parse(JSON.stringify(this.releasebox))
			reqData.skuList.forEach(it=>{
				it.dbPrice = it.dbPrice*100
				it.ygPrice = it.ygPrice*100
				it.dwPrice = it.dwPrice*100
			})
				let res = await request({
					url:'/partnerOwn/partner/editSkuPrice',
					method: 'post',
					data : reqData
				})
				if(res.code == 200){
					uni.showToast({
						title:"修改成功"
					})
					setTimeout(() => {
					  uni.navigateBack()
					}, 1000);
				}
				
			},
		
			getback(){
				uni.navigateBack()
			},
			
							
		}
	}
</script>

<style scoped lang="scss">
	/deep/.u-cell__title-text{
	    font-size: 17px !important;
	    line-height: 22px;
	    color: #303133;
	    font-weight: bold !important;
	}
	.content {
		box-sizing: border-box;
		width: 100%;
		height: calc(100vh);
		background: white;
	}
	
	.top-heder{
		width: 100%;
		height: 46px;
		background: white;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 5px 15px;
	}
	.t-title{
		font-size: 17px;
		font-weight: bold;
		color: #333333;
	}
	.t-left{
		width: 10%;
	}
	.t-you{
		height: 100%;
		background-color: white;
		width: 20%;
	}
	.t-input{
		width: 80%;
		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;
		// height: calc(100vh);
	}
	.mub{
		background-color: #F4F4F4;
		height: calc(100vh);
	}
	.dix{
		display: flex;
		align-items: center;
	}
	.upimg{
		width: 100%;
		height: 126px;
		border-radius: 8px;
		box-sizing: border-box;
		
		background-color: white;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.box-list{
		width: 100%;
		border-radius: 8px;
		box-sizing: border-box;
		padding: 10px;
		background-color: white;
		margin: 10px auto;
	}
	.list-box{
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 15px 5px;
		border-bottom: 1px solid #EEEEEE;
	}
	.l-left{
		font-size: 16px;
		font-weight: 400;
		color: #333333;
	}
	.l-right{
		font-size: 16px;
		font-weight: 400;
		color: #999999;
		text-align: right;
	}
	.xiaolan{
		// width: 109px;
		// height: 30px;
		background: #E2EAFF;
		border-radius: 50px;
		display: flex;
		align-content: center;
		justify-self: center;
		box-sizing: border-box;
		padding: 5px;
		font-size: 14px;
		font-weight: 400;
		color: #0D2E8D;
	}
	.xiaohui{
		// width: 141px;
		// height: 30px;
		box-sizing: border-box;
		padding: 0px 10px;
		background: #F7F7F7;
		border-radius: 50px ;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 10px ;
	
	}
	.hui-right{
		border-left:1px solid #DDDDDD;
		padding: 5px;
		margin-left: 5px;
	}
	.wrap-box{
		width: 100%;
		box-sizing: border-box;
		display: flex;
		flex-wrap: wrap;
	}
	.bottom-di{
		width: 100%;
		height: 56px;
		background: #FFFFFF;
		border-radius: 8px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		padding: 0px 20px;
		margin-bottom: 10px;
	}
	.thui{
		font-size: 16px;
		font-weight: 400;
		color: #666666;
		margin-top: 10px;
		margin-left: 8px;
	}
	.imgs{
		box-sizing: border-box;
		margin-top: 20px;
	}
	.p-box{
		border-radius: 10px;
		overflow: hidden;
		box-sizing: border-box;
		padding: 20px;
		width: 100%;
		background-color: white;
	}
	.p-top{
		width: 100%;
		text-align: center;
		font-size: 17px;
		font-weight: bold;
		color: #000000;
		margin-bottom: 20px;
	}
	.on-input{
		width: 100%;
		display: flex;
		align-items: center;
		box-sizing: border-box;
	
	}
	.ipt-kuang{
		width: 70%;
		height: 30px;
		background: #FFFFFF;
		border-radius: 8px 8px 8px 8px;
		opacity: 1;
		border: 1px solid #DDDDDD;
		display: flex;
		align-items: center;
		margin: 10px auto;
		box-sizing: border-box;
		padding: 0px 10px;
	}
	.t-left{
		width: 20%;
		font-size: 14px;
		font-weight: 400;
		color: #000000;
	}
	.dlanniu{
		width: 80%;
		height: 45px;
		background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%);
		border-radius: 50px;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 20px auto;
		color: white;
	}
	.da{
		font-size: 16px;
	}
</style>
