<template>
	<view class="shoppingFixation" style="z-index: 1000;">
		<view class="settleAccounts" style="z-index: 1000;">
			<view style="flex: 4;" class="dis-flex">
				<view style="flex: 1;position: relative;">
					<view class="shopping iconfont icon-gouwuche" :style="{'backgroundColor':(count>0 && is_business !== 0)?'#ff4444':'#666666'}" @click="pops"></view>
					<view class="commodity" v-if="count > 0 && is_business !== 0">
						{{count}}
					</view>
				</view>
				<view style="flex: 3;padding: 28upx 20upx;box-sizing: border-box;">
					<text class="dis-il-block f-34 f-w" :style="{'color':(count>0 && is_business !== 0)?'#ff4444':'#666666'}">
						¥{{totalPrices.toFixed(2)}}
						<text class="dis-il-block" v-if="deliveryprice !== 0 && (count>0 && is_business !== 0)">
							<text class="f-20" style="padding-left: 60upx;color: #6f6f6f;">{{packing}}:</text><text class="c-ff4444 f-20" style="padding-left: 10upx;">¥{{deliveryprice}}</text>
						</text>
					</text>
					
					<!-- <text class="dis-il-block f-24" style="text-decoration:line-through;color: #999999;padding-left: 10upx;" v-if="false">
						¥125.00
					</text> -->
				</view>
				
			</view>
			<view class="close" :style="{'backgroundColor':(count>0 && is_business !== 0)?'#17D117':'#666666'}" @click="goShopping">
				{{(is_business == 0)?'休息中':(languageStatus!=1?'去结算':'결재하기')}}
			</view>
		</view>
		
	</view>
</template>

<script>
	import App from '@/common/js/app.js';
	
	export default{
		data(){
			return{
				totalPrices:0,
				count:0,
				total:[],
				numberAndPricea:null,
				show:false,
				poststat:false,
				deliveryprice:0,
				packing:'包装费'
			}
		},
		mounted() {
			let _this = this;
			_this.packing = _this.languageStatus  !=1?'包装费':'포장비용'
			this.getShopNum();
			// debugger
			  uni.$on('STOREPRICES',function(data){
				  if(this.poststat){
				  	return
				  }
				  // debugger
					_this.getShopNum();
					
				})
				
		},
		onUnload() {
			uni.$off('STOREPRICES')
		},
		computed:{
		},
		props:{
			num: {
				type: Number,
				default: null
			},
			sid: {
				default: null
			},
			is_business: {
				default: null
			}
		},
		watch:{
			'numberAndPricea': {
				handler(newData, oldData) {
					console.log(newData)
					
				},
				deep: true
			},
			'num': {
				handler(newData, oldData) {
					console.log(newData)
					this.getShopNum();
				},
				deep: true
			}
		},
		methods:{
			// 下弹窗
			pops(){
				App._post_form(
					`&p=citydelivery&do=cartinfo`,
					{},
					res => {
						this.totalPrices = 0;
						this.count = 0;
						 let stotal = res.data.list;
						 stotal.map(item=>{
							 if(item.sid == this.sid){
								 this.total = item;
								 this.packing = item.bzftext;
								 this.packing = this.languageStatus  !=1?item.bzftext:'포장비용'
								 this.totalPrices = item.cartinfo.totalmoney;
								 this.deliveryprice = item.cartinfo.deliveryprice;
								 this.count = item.cartinfo.totalnum;
								 this.$emit('onShows',item);
							 };
						 })
					},
					false,
					() => {
						// _this.loadlogo = true
					}
				);
				
			},
			getShopNum(){
				
				this.poststat = true;
				App._post_form(
					`&p=citydelivery&do=cartinfo`,
					{},
					res => {
						this.totalPrices = 0;
						this.count = 0;
						 let stotal = res.data.list;
						 stotal.map(item=>{
							 if(item.sid == this.sid){
								 this.total = item;
								 this.totalPrices = item.cartinfo.totalmoney;
								 this.deliveryprice = item.cartinfo.deliveryprice;
								 this.count = item.cartinfo.totalnum;
							 };
						 })
						 uni.$emit('end','aa');
						 setTimeout(()=>{
							 this.poststat = false;
						 },500);
					},
					false,
					() => {
						// _this.loadlogo = true
					}
				);
			},
			goShopping(){
				if(this.is_business == 0){
					return
				}
				// debugger
				if(this.count){
					App.navigationTo({
						url:'pages/subPages2/businessCenter/foodOrder/foodOrder?id=' + this.sid
					})
					
					// uni.navigateTo({
					// 	url:'/pages/subPages2/businessCenter/foodOrder/foodOrder?item=' + encodeURIComponent(JSON.stringify(res.data)) + '&routers=foodShopping&param=' + param
					// })
				}else{
					uni.showToast({
					    title: '请选择要购买的商品',
					    duration: 2000,
						icon:'none'
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.close{
		flex: 2;
		background-color: #17D117;
		color: #FFFFFF;
		text-align: center;
		line-height: 100upx;
	}
	.settleAccounts{
		height: 100upx;
		width: 100%;
		position: fixed;
		bottom: 0;
		border-top: 1upx solid #ECECEC;
		background-color: #FFFFFF;
		display: flex;
		.shopping{
			display: inline-block;
			border-radius: 15upx;
			color: #FFFFFF;
			font-size: 44upx;
			font-weight: 700;
			padding: 15upx 20upx;
			position: absolute;
			right: 0;
			top: -20%;
		}
		.commodity{
			border-radius: 60rpx;
			background-color: #FF4444;
			color: #FFFFFF;
			border: 1rpx solid #FFFFFF;
			position: absolute;
			right: -15%;
			top: -37%;
			text-align: center;
			font-size: 26rpx;
			padding: 5rpx 15rpx;
		}
	}
</style>
