<style lang="scss" scoped>
	.admin-button-com {
		margin-bottom: 20px;
		width: 100%;
	}
	.flowers-list-box{
		width: 100%;
		.title{
			height: 80rpx;
			border-top: 1px solid #dcdcdc;
			font-size: 28rpx;
			font-weight: 700;
		}
		.flowers-list{
			padding: 15rpx 0;
			.flowers-name{}
			.flowers-val{
				padding-left: 70rpx;
				input{
					width: 160rpx;
					height: 50rpx;
					padding: 0 20rpx;
					margin-right: 20rpx;
					border: 1px solid #d4d4d4;
					text-align: center;
				}
			}
			.flowers-btn{
				width: 100rpx;
				height: 50rpx;
				color: #FFFFFF;
				background: #6699ff;
				border-radius: 10rpx;
			}
		}
	}
</style>
<template>
  <appResult :title="title?title:'成功'">
			<view class="flowers-list-box">
				<view class="flex title">以下花材售价已变更，如需要请修改：</view>
				<view class="flex-space flowers-list" v-for="(res,i) in flowersList" :key="i">
					<view class="flowers-name">{{res.name}}</view>
					<view class="flex flowers-val">
						<input type="text" v-model="res.price"> 元
					</view>
					<view class="flex-center 	flowers-btn" @tap="changePriceFun(res.id,res.price)">修改</view>
				</view>
			</view>
  </appResult>
</template>
<script>
	import { getAllProductDataApi } from "@/api/product/index";
	import { changePriceByIdApi } from '@/api/product/index'
import appResult from "@/components/app-result";
export default {
  name: "pageSuccess",
  components: {
    appResult
  },
	data() {
		return {
			title:'',
			flowersItemInfo:'',
			flowersList:[],
		};
	},
	onShow(){
  	this.flowersItemInfo  = uni.getStorageSync('flowersItemInfo');
		this.getList();
	},
	onLoad(e){
  	this.title = e.title
	},
	onUnload(){
		uni.removeStorageSync('flowersItemInfo');
		uni.navigateBack({delta:2})
	},
		methods: {
    closeLayer() {
					uni.navigateBack({delta: 3});
    },
				getList(){
    	let productIdArr = '';
				this.flowersItemInfo.forEach((ele)=>{
					productIdArr += ele.productId+','
				})
				getAllProductDataApi({ids : productIdArr.substring(0, productIdArr.lastIndexOf(',')),}).then((res)=>{
						console.log(res)
					this.flowersList = res.data.list;
				});
			},
			changePriceFun(id,price){
				changePriceByIdApi({
					productId: id,
					price: price
				}).then(res => {
						uni.showToast({title:'修改成功'})
				})
			},

  },
};
</script>

