<template>
	<view class="page">
		<view class="timsg">
			<view class="msgtitle">您正在成都锦江绿道有限公司支付金额</view>
			<view class="price">
				<u-icon name="rmb" style="font-size: 24rpx;" />
				{{allPay}}
			</view>
		</view>
		<view style="height: 120rpx;"></view>
		<view class="page-footer">
			<u-button style="width: 100%;border-radius: 15px;" type="success"  @click="submit">支付</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				receivedMsg:[],
				allPay:0
				}
		},
		onLoad(options) {
		 if(options.msg){
			let receivedMsg = JSON.parse(options.msg)
			this.receivedMsg = receivedMsg
			receivedMsg.map(item=>{
				this.allPay += item.paymentAmount
			})
		 }
		},
		onShow() {
				const isLogin = uni.getStorageSync('token');
				if (isLogin == '') {
					// 如果未登录，跳转到登录页面
					uni.navigateTo({
						url: '/pages/login/login'
					})
				} else {
		
					this.$http.sendRequest('/cerePlatformMerchant/queryByPage', 'POST',{"pageSize":10,pageNumber:0,phone:uni.getStorageSync('user').phone}).then(res => {
						 if(res.data.code == '20004' || res.data.code == '20003'){
							 uni.navigateTo({
							 	url: '/pages/login/login'
							 })
						 }
					})
				}
		
			},
				methods: {
					submit(){
						
						let arr = []
						this.receivedMsg.map(item=>{
							let obj = {
								orderId:item.tenementOrder,
								money:item.paymentAmount,
							}
							arr.push(obj)
						})
						
						// return
						this.$http.sendRequest('/order/rentAggregatePayment','POST',arr,3).then(res => {
							console.log(JSON.parse(res.data.data).data.codeUrl)
							 if(res.data.data){
								 uni.redirectTo({
								 	url: `/pagesA/rentPay/webView?urls=${JSON.parse(res.data.data).data.codeUrl}`
								 })
							 }
						})
					
					}
				}
}				
	
</script>

<style scoped lang="scss">
	.page{
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		padding: 0 20rpx;
	}
	.timsg{
		height:20vh;
		text-align: center;
		padding: 50px 0;
		.msgtitle{
			margin-bottom: 20px;
			font-size: 30rpx;
			color: #A4A4A4;
		}
		.price {
			color: #0FBB59;
			font-size: 50rpx;
			font-weight: 700;
		}
	}
	.page-footer{
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		
		background-color: #FFFFFF;
		padding: 20rpx 20rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 999;
		
			}
</style>