<template>
	<navBar title="支付账户签约" navbgClass="nav-bgXin" fontColor='#fff'></navBar>
	<navBgCar :activeNum='5'></navBgCar>
	<view class="content-value">
		<view @click="qianyueAction(item)" class="ul-item" v-for="(item, index) in state.list" :key="index">
			<image class="icon-tip" :src="item.icon"></image>
			<view class="content">
				<view class="title">
					{{ item.title }}
				</view>
				<view style="margin-top: 15rpx" class="flex">
					<view :class="item.tag">
						{{ item.tag1 }}
					</view>
					<view style="margin-left: 15rpx" :class="item.tag">
						{{ item.tag2 }}
					</view>
				</view>
				<view style="margin-top: 15rpx" class="tip">
					{{ item.tip }}
				</view>
			</view>
			<view class="action-btn">签约</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { onLoad } from "@dcloudio/uni-app";
	import { reactive } from "vue";
	import { etcQyList } from "@/utils/network/api.js";
	import { request, requestNew } from "@/utils/network/request.js";
	import { fileURL } from "@/datas/fileURL.js";
	import navBar from "@/components/nav-bar/nav-bar2.vue";
	import navBgCar from "./components/nav-bg-car1";
	const imgURL = `${fileURL}image/`;
	import {navTo} from "@/utils/utils";
	const qianyueAction = (val) => {
		console.log(val);
		// #ifdef MP-ALIPAY
		navTo(
			`/subpackage/orders/sign-up-ali?orderId=${state.orderId}&orderQuery=${state.orderQuery}`,
		);
		// #endif
		// #ifdef MP-WEIXIN
		navTo(
			`/subpackage/orders/sign-up?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}&orderQuery=${state.orderQuery}`,
		);
		// #endif

	};
	//解析URL获取参数
	const getRequest = (urlStr) => {
		if (typeof urlStr == "undefined") {
			// 获取url中"?"符后的字符串
			var url = decodeURI(location.search);
		} else {
			var url = "?" + urlStr.split("?")[1];
		}
		var theRequest = new Object();
		if (url.indexOf("?") != -1) {
			var str = url.substr(1);
			var strs = str.split("&");
			for (var i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
			}
		}
		return theRequest;
	};
	onLoad((option : any) => {
		if (option.q) {
			const q = decodeURIComponent(option.q); // 获取到二维码原始链接内容
			console.log(getRequest(q));
			state.orderId = getRequest(q)['orderId'];
		} else {
			state.orderId = option.orderId;
			state.orderQuery = option.orderQuery;
			state.clientFee = option.clientFee;
			state.id = option.id;
		}
		console.log("option---",option)
		var data = {};
		const options = {
			type: 2,
			data: data,
			method: "POST",
			showLoading: true,
		};
		requestNew(etcQyList, options).then((res) => {
			const data = res;
			// #ifdef MP-ALIPAY
			state.list = [
				{
					icon: imgURL + "issuance/zfb.png",
					title: "支付宝签约",
					// tip: "服务费是每笔交易金额的0.05%",
					tag1: "支付宝代付",
					tag2: "支付宝便捷支付",
					tag: "tag1",
					channelId: data.data[0].channelId,
				},
			]
			// #endif
			// #ifdef MP-WEIXIN
			state.list = [
				{
					icon: imgURL + "issuance/weixin.png",
					title: "微信签约",
					// tip: "服务费是每笔交易金额的0.05%",
					tag1: "微信代付",
					tag2: "微信便捷支付",
					tag: "tag1",
					channelId: data.data[0].channelId,
				},
			];
			// #endif
		});
	});

	const state = reactive({
		data: {
			show: false,
			src: imgURL + "applyCard/edit.png",
		},
		list: [],
		id: "",
		clientFee: "",
		orderId: "",
		orderQuery:"0"
	});
</script>

<style lang="scss" scoped>
	.content-value {
		position: absolute;
		top: 370rpx;
		width: 100%;
		min-height: calc(100% - 370rpx);
		box-sizing: border-box;
		padding: 0 30rpx 210rpx;
	}

	.flex {
		display: flex;
		align-items: center;
	}


	.action-btn {
		width: 124rpx;
		height: 50rpx;
		font-family: SourceHanSansSC, SourceHanSansSC;
		font-weight: 400;
		font-size: 24rpx;
		color: #FFFFFF;
		background: radial-gradient(at 0% 0%, #CCB375  0%, #E7D398 100%);
		border-radius: 25rpx;
		text-align: center;
		line-height: 50rpx;
		margin-top: 16rpx;
	
	}

	.tag1 {
		color: #CCB375;
		border-radius: 5rpx;
		border: 1rpx solid #CCB375;
		font-family: SourceHanSansSC, SourceHanSansSC;
		font-weight: 400;
		font-size: 20rpx;
		height: 30rpx;
		line-height: 30rpx;
		text-align: center;
		padding: 0 10rpx;
	}

	.tag3 {
		padding: 5rpx;
		background: rgba(139, 112, 228, 0.5);
		border-radius: 6rpx;
		font-size: 22rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: #ffffff;
	}

	.tag2 {
		padding: 5rpx;
		background: rgba(249, 97, 60, 0.5);
		border-radius: 6rpx;
		font-size: 22rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: #ffffff;
	}

	.ul-item {
		// padding: 5px 20rpx;
		display: flex;
		background-color: #fff;
		padding: 50rpx 30rpx 40rpx;
		border-radius: 12rpx;

		.content {
			margin-left: 23rpx;
			flex: 1 1 auto;

			.title {
				font-size: 30rpx;
				font-family: SourceHanSansSC, SourceHanSansSC;
				font-weight: 400;
				color: #111;

			}

			.tip {
				font-size: 24rpx;
				font-family: SourceHanSansSC, SourceHanSansSC;
				font-weight: 400;
				color: #999;

			}
		}


		.icon-tip {
			width: 80rpx;
			height: 80rpx;
			flex-shrink: 0;
		}

	}
</style>