detail.vue 3.2 KB
Newer Older
潘永坪's avatar
潘永坪 committed
1 2
<template>
	<!-- 详情 -->
潘永坪's avatar
潘永坪 committed
3
	<u-popup  :show="showPop" :round="20" @close="showPop = false">
潘永坪's avatar
潘永坪 committed
4 5
		<view class="son-wrap">
			<view class="title">
潘永坪's avatar
潘永坪 committed
6 7 8 9
				<view style="flex: 1; text-align: center">
					明细
				</view>
				<u-icon name="close" @click="showPop = false"></u-icon>
潘永坪's avatar
潘永坪 committed
10
			</view>
潘永坪's avatar
潘永坪 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24
			<view style="flex: 1;overflow-y: scroll;">
				<view class="middle">
					<view class="merchantlist" v-for="(item,index) in merchantList" :key="index">
						<view class="merchant-title">
							{{item.merchantName}}
						</view>
						<view class="productlist" v-for="(items,a) in item.productlist" :key='a'>
							<text>
								{{items.name}}
							</text>
							<text style="font-weight: bold;">
								¥{{items.sellingPrice}}
							</text>
						</view>
潘永坪's avatar
潘永坪 committed
25
					</view>
潘永坪's avatar
潘永坪 committed
26 27 28 29 30 31 32 33 34 35
				</view>
					
				<view class="bottom">
					<view class="bottom-left">
						合计:¥ 
						<text style="font-weight: bold;font-size: 40rpx;">{{priceTotal}}</text> 
					</view>
					<view class="bottom-right">
						<text class="btn" @click="goFillorder()">
							去预订
潘永坪's avatar
潘永坪 committed
36 37 38
						</text>
					</view>
				</view>
潘永坪's avatar
潘永坪 committed
39 40 41
			</view>
		</view>
	</u-popup>
潘永坪's avatar
潘永坪 committed
42 43 44
</template>

<script>
潘永坪's avatar
潘永坪 committed
45
export default {
潘永坪's avatar
潘永坪 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
  props: ['chooseProduct'],
  data() {
    return {
      showPop: false, //控制弹窗显示隐藏
      priceTotal:0,//总价
      merchantList:[],//商家列表
    }
  },
  watch: {
    //选中产品的数量变化
    chooseProduct: { 
      handler(newValue, oldValue){
        this.priceTotal=0
        this.chooseProduct.forEach((item)=>{
          this.priceTotal+=item.sellingPrice
        })
        this.priceTotal=parseFloat(this.priceTotal.toFixed(2))
        this.merchantList=[]
        this.chooseProduct.forEach(item=>{
				  if(!this.merchantList.find(item2=>item2.merchantId==item.merchantId)){
				    this.merchantList.push({
				      merchantName:item.merchantName,
				      merchantId:item.merchantId,
				      productlist:[]
				    })
				  }
        })
        //一级数组转化成二级数组
        this.merchantList.forEach(item=>{
				  this.chooseProduct.forEach(item2=>{
				    if(item.merchantId==item2.merchantId){
				      item.productlist.push(item2)
				    }
				  })
        })
      },
      deep:true,
      immediate: false
    },
  },
  methods: {
潘永坪's avatar
潘永坪 committed
87 88 89 90
    //---跳转填写订单页面
    goFillorder(){
      this.$parent.goFillorder()
    }
潘永坪's avatar
潘永坪 committed
91
  }
潘永坪's avatar
潘永坪 committed
92
}
潘永坪's avatar
潘永坪 committed
93 94
</script>

潘永坪's avatar
潘永坪 committed
95 96 97
<style scoped="scoped" lang="scss">
.son-wrap{
	position: relative;
潘永坪's avatar
潘永坪 committed
98 99 100 101
	height:80vh;
	display: flex;
	flex-direction:column;
}
潘永坪's avatar
潘永坪 committed
102
.title{
潘永坪's avatar
潘永坪 committed
103
	display: flex;
潘永坪's avatar
潘永坪 committed
104 105
	font-size: 32rpx;
	font-weight: bold;
潘永坪's avatar
潘永坪 committed
106
	padding: 30rpx;
潘永坪's avatar
潘永坪 committed
107
	background: #fff;
潘永坪's avatar
潘永坪 committed
108
	border-radius: 20rpx 20rpx 0 0;
潘永坪's avatar
潘永坪 committed
109 110
}
.middle {
潘永坪's avatar
潘永坪 committed
111
	padding:0 24rpx 100rpx 24rpx;
潘永坪's avatar
潘永坪 committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
}
.merchantlist{
	border-bottom:2rpx solid #ececec;
	padding-bottom: 40rpx;
	margin-top: 24rpx;
}
.merchant-title{
	font-size: 36rpx;
	font-weight: bold;
	color: #191919;
}
.productlist{
	display: flex;
	justify-content: space-between;
	font-size: 32rpx;
	margin-top: 20rpx;
}
.bottom {
	display: flex;
	justify-content: space-between;
	padding: 0 24rpx;
	height: 100rpx;
	align-items: center;
	position: fixed;
	bottom: 0;
	width: 100%;
	z-index: 9;
	background: #FFFFFF;
	box-sizing: border-box;
}
.bottom-left{
	color:$red;
潘永坪's avatar
潘永坪 committed
144
	font-size: 32rpx;
潘永坪's avatar
潘永坪 committed
145 146 147
}
.btn{
	font-size: 32rpx;
潘永坪's avatar
潘永坪 committed
148
	width: 200rpx;
潘永坪's avatar
潘永坪 committed
149
}
潘永坪's avatar
潘永坪 committed
150
</style>