<template>
	<div class="app-content pay-wrap">
		<div class="delivery-wrap">
			<div class="btn-wrap">
				<!-- #ifdef H5 -->
				<button class="button-com red" @click="go()" v-if="hasRenew == 1">正在打开支付宝...</button>
				<view style="margin-top:50upx;font-size:40upx;font-weight:bold;text-align: center;" v-if="hasRenew == 0">商家还未开通此功能</view>
				<!-- #endif -->
			</div>
		</div>
	</div>
</template>
<script>
import { purchaseClearAliPay } from '@/api/purchase'
export default {
    name: 'alipay',
    components: {
    },
    mixins: [],
    data() {
        return {
			payUrl:'',
			hasRenew:1
        }
    },
    computed: {
    },
    onLoad(options) {
        let orderSn = options.orderSn ? options.orderSn:''
        this.payInit(orderSn)
    },
    mounted() {},
    methods: {
        init(){

        },
		go(){
			if(this.hasRenew == 1){
				window.location.href = this.payUrl
			}
		},
        payInit(orderSn) {
            if (orderSn==''){
                uni.showToast({title: '没有找到订单号',icon: 'none',duration: 1500})
                return false
            }
            purchaseClearAliPay({orderSn:orderSn}).then(res=>{
                if(res.code == 0){
                    uni.showToast({title: res.msg,icon: 'none',duration: 1500})
                    return false
                }
				this.hasRenew = res.data.hasRenew?res.data.hasRenew:0
				if(res.data.hasRenew && res.data.hasRenew == 1){
					this.payUrl = res.data.payUrl
					window.location.href = this.payUrl
				}
            })
        }
    }
}
</script>
<style lang="scss">
	.app-content {
		min-height: calc(100vh - 20upx);
		padding-top: 20upx;
	}
	.tabs-wrap {
		position: fixed;
		top: 0;
		width: 100%;
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		background-color: #fff;
		font-size: 30upx;
		box-shadow: 4upx 4upx 10upx #eee;
	}
	.pay-wrap {
		.pay-input-wrap {
			background-color: #fff;
			border-top-left-radius: 20upx;
			border-top-right-radius: 20upx;
			padding: 50upx 80upx 28upx;
			margin-bottom: 0 !important;
			.balance {
				margin-top: 30upx;
				color: #666666;
			}
			.btn-wrap {
				width: 100%;
				margin-top: 64upx;
				.button-com {
					display: block;
					margin-bottom: 20upx;
					padding-top: 30upx;
					padding-bottom: 30upx;
				}
			}
		}
	}

	// 我要配送
	.delivery-wrap {
		.module-com {
			margin-bottom: 20upx;
			background-color: #fff;
			.module-tit {
				padding: 20upx 18upx;
				font-size: 28upx;
				font-weight: 600;
				border-bottom: 1upx solid #eee;
			}
			.module-det {
				padding: 0 30upx;
			}
		}
		// 金额
		.pay-input-wrap {
			padding: 50upx 36upx 38upx;
			.balance {
				margin-top: 30upx;
				color: #666666;
			}
		}
		.shop-logo-wrap {
			padding-bottom: 20upx;
			.logo-img {
				width: 100%;
				margin: 10upx auto;
				align-items: center;
				.logo {
					width: 100upx;
					height:100upx;
					border-radius: 10upx;
					margin-left:10upx;
					float: left;
				}
				.title{
					margin-left:20upx;
					float:left;
					width:600upx;
					height:100upx;
					line-height:100upx;
					font-size:38upx;
					font-weight: bold;
				}
			}
		}
		// 可选优惠
		.discount-wrap {
			.module-det {
				padding-top: 20upx;
				padding-bottom: 20upx;
			}
		}
		// 匿名派送
		.none-name-delivery {
			// padding-left: 30upx;
			padding: 26upx 30upx;
			// margin-top: 40upx;
			margin-bottom: 20upx;
			background-color: #fff;
			.none-name-text {
				margin-left: 14upx;
				color: #666666;
			}
		}
		// 按钮
		.btn-wrap {
			width: calc(100% - 60upx);
			margin: 64upx auto 0;
			padding-bottom: 20upx;
			.button-com {
				display: block;
				margin-bottom: 20upx;
				padding-top: 30upx;
				padding-bottom: 30upx;
				&:last-child {
					margin-bottom: 0;
				}
			}
		}

		// 查看更多
		.view-more {
			width: auto;
			padding-bottom: 20upx;
			margin-bottom: 20upx;
			font-size: 28upx;
			background-color: #fff;
			color: #666565;
			justify-content: flex-start;
			z-index:9999999;
			.view-more-text {
				margin-right: 14upx;
			}
			padding-left:40upx;
			i {
				font-size: 30upx;
				font-weight: 600;
			}
			.fill-get-man{
				color:red;
				margin-left:10upx;
				font-weight:600;
				text-decoration:underline;
			}
			.pack-up{
				margin-left:20upx;
				font-weight:600;
				color:red;
				text-decoration:underline;
			}
			&.open {
				i {
					transform: rotate(180deg);
				}
			}
		}
	}
</style>