<template>
	<view class="cashier">
		<view class="d-c d-b-c cashier-top">
			<view class="f24 gray3">{{ $t('w_0331') }}</view>
			<view class="f34 price-color fb">
				{{ currencyIcon() }}
				<text class="f54 fb">{{ formatNum(form.orderAmount) }}</text>
			</view>
			<view class="f24 gray9">
				{{ $t('w_0213') }}
				<text class="domation">{{ formatSeconds(form.payTime || 0) }}</text>
				{{ $t('w_0214') }}
			</view>
		</view>
		<view class="content-box">
			<view class="info-title">{{ $t('w_0215') }}</view>

			<template v-if="pay_type == 20">
				<view class="d-b-c pay-item" @click="changePayType(2, 2, '')">
					<image class="pay-icon" src="/static/icon/pay-wallet.png" mode=""></image>
					<view class="flex-1 f26">{{ $t('w_0226') }}</view>
					<view class="radio-check" :class="{ checked: payType == 2 && payChannel == 2 }"></view>
					<!-- <view class="domation fb f30">3</view> -->
					<view class="icon iconfont icon-jiantou" @click="openWX = !openWX" :class="{ checked: openWX }"></view>
				</view>
			</template>
			<template v-if="pay_type == 10">
				<view class="d-b-c pay-item" @click="changePayType(-1, -1, '')">
					<image class="pay-icon" src="/static/icon/pay-wallet.png" mode=""></image>
					<view class="flex-1 f26">{{ $t('w_0216') }}</view>
					<view class="radio-check" :class="{ checked: payType == -1 }"></view>
					<!-- <view class="domation fb f30">3</view> -->
					<view class="icon iconfont icon-jiantou" :class="{ checked: openZH }"></view>
				</view>
				<view style="padding-left: 24rpx;" class="autoBox" :class="{ open: openZH }">
					<view class="border-b" v-if="spendDetail.payAccount1 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0217') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account1) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount1) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount2 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0218') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account2) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount2) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount3 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0219') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account3) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount3) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount4 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0220') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account4) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount4) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount5 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0221') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account5) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount5) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount6 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0222') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account6) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount6) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount7 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0223') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account7) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount7) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount8 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_0224') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account8) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount8) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount9 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('ENU_ACCOUNT_9') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account9) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount9) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount10 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('ENU_ACCOUNT_9') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account10) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount10) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount12 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('w_1004') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6"></view>
							<!-- <view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account12) }}</view> -->
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount12) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount13 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('fn_049') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account13) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount13) }}</view>
						</view>
					</view>
					<view class="border-b" v-if="spendDetail.payAccount14 > 0">
						<view class="d-b-c  p-10-0 ">
							<view class="flex-1 f26">{{ $t('fn_020') }}</view>
						</view>
						<view class="d-b-c p-10-0">
							<view class="gray6">{{ currencyIcon() }}{{ formatNum(spendDetail.account14) }}</view>
							<view class="gray9">-{{ currencyIcon() }}{{ formatNum(spendDetail.payAccount14) }}</view>
						</view>
					</view>
				</view>
			<!-- 	<view class="d-b-c pay-item" @click="openZX = !openZX">
					<image class="pay-icon" src="/static/icon/pay-online.png" mode=""></image>
					<view class="flex-1 f26">{{ $t('w_0225') }}</view>
					<view class="icon iconfont icon-jiantou" :class="{ checked: openZX }"></view>
				</view> -->
				<!-- <view style="padding-left: 24rpx;" class="autoBox" :class="{ open: openZX }">
					<view class="">
						<view v-if="payConfig.pay12" class="d-b-c pay-item border-b" @click="changePayType(5, 2)">
							<image class="pay-icon wx" src="/static/icon/wx.png" mode=""></image>
							<view class="flex-1 f26">{{ $t('w_0229') }}</view>
							<view class="radio-check" :class="{ checked: payType == 2 && payChannel == 5 }"></view>
						</view>
						<view v-if="payConfig.pay13" class="d-b-c pay-item border-b" @click="changePayType(6, 2)">
							<image class="pay-icon wx" src="/static/icon/wx.png" mode=""></image>
							<view class="flex-1 f26">{{ $t('w_0230') }}</view>
							<view class="radio-check" :class="{ checked: payType == 2 && payChannel == 6 }"></view>
						</view>
						<view v-if="payConfig.pay15" class="d-b-c pay-item" @click="openHF = !openHF">
							<image class="pay-icon" src="/static/icon/pay-online.png" mode=""></image>
							<view class="flex-1 f26">{{ $t('w_0231') }}</view>
							<view class="icon iconfont icon-jiantou" :class="{ checked: openHF }"></view>
						</view>

						<view class="autoBox" :class="{ open: openHF }">
							<view class="d-b-c pay-item border-b" v-for="(item, index) in adaList" :key="index" @click="changePayType(6, 3, item.bindCode)">
								<view class="flex-1 f26">{{ item.bankName + '(' + item.bankNo + ')' }}</view>
								<view class="radio-check" :class="{ checked: bindCode == item.bindCode }"></view>
							</view>
							<view class="d-s-c pay-item border-b" @click="gotoPage('/pages/user/card/otherAdd?type=0')">
								<u-icon name="plus-circle" size="24rpx" color="#333"></u-icon>
								<text class="m-0-20 flex-1">{{ $t('w_0179') }}</text>
							</view>
						</view>
						<view v-if="payConfig.pay4" class="d-b-c pay-item" @click="openJD = !openJD">
							<image class="pay-icon" src="/static/icon/pay-online.png" mode=""></image>
							<view class="flex-1 f26">{{ $t('w_0234') }}</view>
							<view class="icon iconfont icon-jiantou" :class="{ checked: openJD }"></view>
						</view>
						<view class="autoBox" :class="{ open: openJD }">
							<view class="d-b-c pay-item border-b" v-for="(item, index) in jdList" :key="index" @click="changePayType(4, 3, item.bindCode)">
								<view class="flex-1 f26">{{ item.bankName + '(' + item.bankNo + ')' }}</view>
								<view class="radio-check" :class="{ checked: bindCode == item.bindCode }"></view>
							</view>
							<view class="d-s-c pay-item border-b" @click="gotoPage('/pages/user/card/otherAdd?type=1')">
								<u-icon name="plus-circle" size="24rpx" color="#333"></u-icon>
								<text class="m-0-20 flex-1">{{ $t('w_0179') }}</text>
							</view>
						</view>
					</view>
				</view> -->
			</template>
		</view>
		<!-- 注册 -->
		<register v-if="specialType == 1"></register>
		<!-- 升级 -->
		<upgrade v-if="specialType == 2"></upgrade>
		<!-- 复购 -->
		<repurchase v-if="specialType == 3"></repurchase>
		<!-- 嗨粉 -->
		<fans v-if="specialType == 4"></fans>
		<!-- 重消 -->
		<reCancellation v-if="specialArea == 10"></reCancellation>
		<!-- 福利 -->
		<welfare v-if="specialArea == 13"></welfare>
		<!-- 积分 -->
		<points v-if="specialArea == 11"></points>

		<view class="p-40-0">
			<button class="normal-sub-btn" @click="payFunc">{{ $t('w_0248') }}</button>
		</view>

		<Popup :show="isPopup" :width="665" :padding="0" @hidePopup="hidePopupFunc">
			<view class="d-e-c ww100">
				<view class="p20" @click="hidePopupFunc(true)"><text class="icon iconfont icon-guanbi" style="color: #999;font-size: 28rpx;"></text></view>
			</view>
			<view class="ww100 box-s-b pr" style="padding: 0 60rpx;">
				<view class="d-c-c" style="margin-bottom: 50rpx;">
					<u-icon name="checkmark-circle-fill" color="#333333" size="40rpx"></u-icon>
					<text class="ml20 f34 fb gray3">{{ $t('w_0158') }}</text>
				</view>
				<view class="f30 d-c-c mb30 " style="color: #FB3024;">
					<view class="fb pr">
						<!-- {{ $t('w_0159') }} -->
						<text class="gray9 f24 ml20 copy-text" @click="copy">{{ $t('MY_CK_27') }}</text>
					</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('CK_KS_14') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.memberName }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('MN_T_1') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.memberCode }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('w_0160') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.phone }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('w_0041') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.loginPassword }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('N_I_217') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.payPassword }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('w_0161') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.urlAddress }}</view>
				</view>
				<!-- <view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">{{ $t('APP_ADD_7') }}：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.gzh }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">APP({{ $t('APP_ADD_8') }})：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.ios }}</view>
				</view>
				<view class="res-item f28 gray3 line-h-2 d-b-c">
					<view class="res-item-name">APP({{ $t('APP_ADD_9') }})：</view>
					<view class="flex-1 res-item-name-r">{{ registerForm.android }}</view>
				</view> -->
				<view class="p-20-0">
					<button class="s-pop-btn" @click="hidePopupFunc(true)">{{ $t('ENU_P_TYPE4') }}</button>
				</view>
				<image v-if="showImg" class="gitImage" src="/static/bg/s1.gif" mode=""></image>
				<image v-if="showImg" class="gitImage2" src="/static/bg/s2.gif" mode=""></image>
			</view>
		</Popup>
		<popInput :title="$t('w_0251')" :password="true" :placeholder="payChannel == -1 ? $t('w_0316') : $t('w_0250')" :isShow="isPassword" @close="closePassword"></popInput>
		<view v-if="isQrcode">
			<view class="pop-bg" @click="isQrcode = false"></view>
			<view class="pop-success-s">
				<view class="d-c d-b-c hh100">
					<view class="d-e-c ww100" @click="isQrcode = false"><u-icon name="close" size="34rpx" color="#999"></u-icon></view>
					<view class="f30 gray3 fb tc mb20">{{ $t('w_0226') }}</view>
					<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
					<button class="pop-btn mt20" @click="isQrcode = false">{{ $t('w_0035') }}</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { pay } from '@/common/pay.js';
import Popup from '@/components/uni-popup.vue';
import register from './part/register.vue';
import reCancellation from './part/reCancellation.vue';
import repurchase from './part/repurchase.vue';
import welfare from './part/welfare.vue';
import points from './part/points.vue';
import upgrade from './part/upgrade.vue';
import fans from './part/fans.vue';
import utils from '@/common/utils.js';
import popInput from '@/components/pop-input.vue';
/* 引入uQRCode */
import UQRCode from '@/uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
export default {
	components: {
		Popup,
		register,
		reCancellation,
		repurchase,
		welfare,
		points,
		upgrade,
		fans,
		popInput
	},
	data() {
		return {
			pay_type: 0,
			isPassword: false,
			businessType: 1,
			payChannel: -1,
			payType: -1,
			openHF: false,
			openJD: false,
			openZX: false,
			openWX: false,
			openZH: true,
			bindCode: '',
			type: 0,
			showUp: false,
			isPopup: false,
			orderCode: '',
			specialArea: '',
			spendDetail: {},
			form: {
				orderCode: '',
				orderAmount: '',
				payTime: 0,
				isToBePay: 0,
				memberName: '',
				postage: '',
				memberCode: '',
				pkGrade: 0,
				pkGradeVal: '',
				pkCountry: 1,
				recName: '',
				recPhone: '',
				recProvince: '',
				recCity: '',
				recCounty: '',
				recAddress: '',
				deliveryWayVal: '',
				transTypeVal: '',
				specialArea: 0,
				specialAreaVal: '',
				placeParent: '',
				placeDept: 1,
				placeDeptVal: '',
				phone: '',
				parent: '',
				parentName: '',
				placeParentName: '',
				source: 1,
				isPassword: false
			},
			jdList: [],
			adaList: [],
			payConfig: {
				pay4: false, //京东银行卡
				pay12: false, //宝付微信
				pay13: false, //汇付微信
				pay15: false, //汇付银行卡
				pay20: true //微信APP（true=显示，false=不显示）
			},
			time1: null,
			registerForm: {
				memberName: '',
				memberCode: '',
				phone: '',
				email: '',
				loginPassword: '',
				payPassword: '',
				urlAddress: ''
			},
			showImg: false,
			specialType: 0,
			isQrcode: false,
			payTime: false,
			userCountry: 0,
			pkSettleCountry: 1
		};
	},
	destroyed() {
		clearInterval(this.time1);
		this.time1 = null;
	},
	provide: function() {
		return {
			form: this.form
		};
	},
	watch: {
		showImg: function(n, o) {
			let self = this;
			if (n) {
				setTimeout(function() {
					self.showImg = false;
				}, 4000);
			}
		}
	},
	onLoad(e) {
		this.pkSettleCountry = e.pkSettleCountry || 1;
		this.orderCode = e.orderCode;
		this.specialArea = e.specialArea;
		// if (this.specialArea == 18 || this.specialArea == 19 || this.specialArea == 23) {
		// 	this.specialArea = 13;
		// }
		/* 注册权限 */
		if (this.specialArea == 1 || this.specialArea == 24|| this.specialArea == 101 || this.specialArea == 102) {
			this.specialType = 1;
		}
		/* 升级专区 */
		if (this.specialArea == 2 || this.specialArea == 25 || this.specialArea == 27 || this.specialArea == 201 || this.specialArea == 202) {
			this.specialType = 2;
		}
		/* 复购专区 */
		if (this.specialArea == 3 || this.specialArea == 12 || this.specialArea == 14 || this.specialArea == 22 || this.specialArea == 26|| this.specialArea == 30|| this.specialArea == 33) {
			this.specialType = 3;
		}
		/* 嗨粉分享专区 */
		if (this.specialArea == 7) {
			this.specialType = 4;
		}
		/* 福利专区 */
		if (this.specialArea == 13 || this.specialArea == 11 || this.specialArea == 10 || this.specialArea == 18 || this.specialArea == 19 || this.specialArea == 23) {
			this.specialType = 5;
		}
		if (e.businessType) {
			this.businessType = e.businessType || 1;
		}
		this.getGenerate();
		// #ifdef APP-PLUS
		// this.getPayType();
		// #endif
		// #ifndef APP-PLUS
		this.pay_type = 10;
		// #endif
		this.getData();
		this.getSpendDetails();
	},
	onShow() {
		// this.getPayconfig();
		// this.getJdFast();
		// this.getAdaFast();
		this.getInfo();
	},
	methods: {
		getInfo() {
			let self = this;
			self._get('member/api/member/get-info', {}, res => {
				/* 当前用户结算国家 */
				self.userCountry = res.data.pkSettleCountry;
			});
		},
		getQrcode(e) {
			console.log(e);
			let self = this;
			self.isQrcode = true;
			self.$nextTick(() => {
				// 获取uQRCode实例
				var qr = new UQRCode();
				// 设置二维码内容
				qr.data = e;
				// 设置二维码大小，必须与canvas设置的宽高一致
				qr.size = 200;
				// 调用制作二维码方法
				qr.make();
				// 获取canvas上下文
				var canvasContext = uni.createCanvasContext('qrcode', self); // 如果是组件，this必须传入
				console.log(canvasContext);
				// 设置uQRCode实例的canvas上下文
				qr.canvasContext = canvasContext;
				// 调用绘制方法将二维码图案绘制到canvas上
				qr.drawCanvas();
			});
		},
		closeCode() {
			this.isQrcode = false;
			this.payTime = false;
		},
		payStatus() {
			let self = this;
			let params = {
				payChannel: self.payChannel,
				businessCode: self.orderCode,
				businessType: self.businessType,
				payType: self.payType,
				bindCode: self.bindCode
			};
			let callback = function() {
				self._get('pay/status', params, res => {
					if (res.data == 1) {
						self.closeCode();
						self.money = '';
						self.payChannel = '';
						self.orderCode = '';
						self.payType = '';
						self.bindCode = '';
						uni.showModal({
							title: '$t("w_0034")',
							content: res.msg,
							showCancel: false,
							success() {
								self.gotoPage('/pages/user/index/index', 'reLaunch');
							}
						});
					} else {
						if (self.payTime) {
							self.payStatus();
						}
					}
				});
			};
			setTimeout(function() {
				callback();
			}, 5000);
		},
		getPayType() {
			let self = this;
			let url = this.config.yxyapi;
			uni.request({
				url: url+'/yiti.php',
				data: {
					type: 2,
					platform: self.getPlatform()
				},
				success: result => {
					console.log(result);
					var data = result.data;
					self.pay_type = data.pay_type;
				},
				error: error => {
					console.log('----------------error');
					console.log(error);
				}
			});
		},
		copy() {
			let self = this;
			let data = [
				{
					name: self.$t('CK_KS_14'),
					value: self.registerForm.memberName
				},
				{
					name: self.$t('MN_T_1'),
					value: self.registerForm.memberCode
				},
				{
					name: self.$t('CK_KS_14'),
					value: self.registerForm.phone
				},
				{
					name: self.$t('w_0041'),
					value: self.registerForm.loginPassword
				},
				{
					name: self.$t('N_I_217'),
					value: self.registerForm.payPassword
				},
				{
					name: self.$t('PER_DA_44'),
					value: self.registerForm.email
				},
				{
					name: self.$t('w_0161'),
					value: self.registerForm.urlAddress
				},
				// {
				// 	name: self.$t('APP_ADD_7'),
				// 	value: self.registerForm.gzh
				// },
				// {
				// 	name: 'APP(' + self.$t('APP_ADD_8') + ')',
				// 	value: self.registerForm.ios
				// },
				// {
				// 	name: 'APP(' + self.$t('APP_ADD_9') + ')',
				// 	value: self.registerForm.android
				// }
			];
			data = `${data.map(item => `${item.name} : ${item.value}`).join('\n')}`;
			uni.setClipboardData({
				data: data,
				showToast: false,
				success: function() {
					uni.showToast({
						title: '',
						icon: 'success'
					});
					console.log('success');
				}
			});
		},
		payFunc() {
			if (this.payType == -1) {
				this.getGenerate();
				this.isPassword = true;
			} else {
				this.zxPay();
			}
		},
		/* 生成token */
		getGenerate() {
			let self = this;
			self._get('system/api/idempotent/generate', {}, res => {
				uni.setStorageSync('token', res.msg);
			});
		},
		changePayType(payChannel, payType, bindCode) {
			if (payChannel == -1 && payType == -1 && bindCode == '') {
				this.openZH = !this.openZH;
			}
			this.payChannel = payChannel;
			this.payType = payType;
			this.bindCode = bindCode || '';
		},
		getData() {
			let self = this;
			self._post(
				'sale/api/order/query-order',
				{
					specialArea: self.specialArea,
					orderCode: self.orderCode,
					pkSettleCountry: self.pkSettleCountry
				},
				res => {
					console.log(self.form);
					console.log(res.data);
					utils.objForEach(self.form, (value, key) => {
						if (res.data[key]) {
							self.form[key] = res.data[key];
						}
					});
					self.form = res.data;
					console.log(self.form);
					if (!self.time1) {
						self.openAgreement();
					}
				}
			);
		},
		getSpendDetails() {
			let self = this;
			self._post(
				'sale/api/order/query-spend-details',
				{
					specialArea: self.specialArea,
					orderCode: self.orderCode,
					pkSettleCountry: self.pkSettleCountry
				},
				res => {
					self.spendDetail = res.data;
				}
			);
		},
		hidePopupFunc() {
			this.isPopup = false;
			uni.reLaunch({
				url: '/pages/order/myorder'
			});
		},
		/* 京东银行卡绑卡列表 */
		getPayconfig() {
			let self = this;
			self._get('pay/config', {}, res => {
				self.payConfig = res.data;
			});
		},
		/* 京东银行卡绑卡列表 */
		getJdFast() {
			let self = this;
			self._get('pay/jd-fast/list', {}, res => {
				self.jdList = res.data;
			});
		},
		/* 汇付银行卡绑卡列表 */
		getAdaFast() {
			let self = this;
			self._get('pay/ada-fast/list', {}, res => {
				self.adaList = res.data;
			});
		},
		//  秒数转化为时分秒
		formatSeconds(value) {
			//  秒
			let second = parseInt(value);
			//  分
			let minute = 0;
			//  小时
			let hour = 0;
			//  天
			//  let day = 0
			//  如果秒数大于60，将秒数转换成整数
			if (second > 60) {
				//  获取分钟，除以60取整数，得到整数分钟
				minute = parseInt(second / 60);
				//  获取秒数，秒数取佘，得到整数秒数
				second = parseInt(second % 60);
				//  如果分钟大于60，将分钟转换成小时
				if (minute > 60) {
					//  获取小时，获取分钟除以60，得到整数小时
					hour = parseInt(minute / 60);
					//  获取小时后取佘的分，获取分钟除以60取佘的分
					minute = parseInt(minute % 60);
					//  如果小时大于24，将小时转换成天
					//  if (hour > 23) {
					//    //  获取天数，获取小时除以24，得到整天数
					//    day = parseInt(hour / 24)
					//    //  获取天数后取余的小时，获取小时除以24取余的小时
					//    hour = parseInt(hour % 24)
					//  }
				}
			}

			let result = '' + parseInt(second) + this.$t('S_L_9');
			if (minute > 0) {
				result = '' + parseInt(minute) + this.$t('S_L_8') + result;
			}
			if (hour > 0) {
				result = '' + parseInt(hour) + this.$t('S_L_7') + result;
			}
			//  if (day > 0) {
			//    result = '' + parseInt(day) + '天' + result
			//  }
			return result;
		},
		// closePassword(e) {
		// 	this.isPassword = false;
		// 	if (this.specialType == 1 || this.specialType == 4) {
		// 		this.resPay(e);
		// 	} else {
		// 		this.zxPay(e);
		// 	}
		// },
		closePassword(e) {
			if (e) {
				if (this.payChannel == 4) {
					this.jdFast(e);
				} else if (this.payChannel == 6) {
					this.adaFast(e);
				} else if (this.payChannel == -1) {
					if (this.specialType == 1 || this.specialType == 4) {
						this.resPay(e);
					} else {
						this.yuePay(e);
					}
				}
			}
			this.isPassword = false;
		},
		adaFast(e) {
			let self = this;
			let params = {
				smsCode: e,
				bindCode: self.bindCode,
				orderCode: self.orderCode,
				pkSettleCountry: self.userCountry,
				specialArea: self.specialArea
			};
			uni.showLoading({
				title: 'Loading....'
			});
			self._post('pay/ada-fast/pay-confirm', params, res => {
				uni.hideLoading();
				uni.showModal({
					title: self.$t('w_0034'),
					content: res.msg,
					success() {
						self.money = '';
						self.payChannel = '';
						self.orderCode = '';
						self.payType = '';
						self.bindCode = '';
					}
				});
				self.payTime = true;
				self.payStatus();
			});
		},
		jdFast(e) {
			let self = this;
			let params = {
				smsCode: e,
				bindCode: self.bindCode,
				orderCode: self.orderCode,
				pkSettleCountry: self.userCountry,
				specialArea: self.specialArea
			};
			uni.showLoading({
				title: 'Loading....'
			});
			self._post('pay/jd-fast/pay-confirm', params, res => {
				uni.hideLoading();
				uni.showModal({
					title: self.$t('w_0034'),
					content: res.msg,
					success() {
						self.money = '';
						self.payChannel = '';
						self.orderCode = '';
						self.payType = '';
						self.bindCode = '';
					}
				});
				self.payTime = true;
				self.payStatus();
			});
		},
		zxPay() {
			let self = this;
			let params = {
				payChannel: self.payChannel,
				businessCode: self.orderCode,
				businessType: self.businessType,
				payType: self.payType,
				bindCode: self.bindCode
			};
			uni.showLoading({
				title: 'Loading....'
			});
			self._post('pay/unifiedorder', params, res => {
				if (res.code == 200) {
					/* 微信支付 */
					if (self.payType == 2) {
						self.getQrcode(res.data);
						self.payTime = true;
						self.payStatus();
					}
					if (self.payType != 2) {
						self.isPassword = true;
					}
				}

				console.log(res);
				uni.hideLoading();
			});
		},
		resPay(e) {
			let self = this;
			let params = {
				payPwd: e, //支付密码
				orderCode: self.orderCode, //订单编号
				specialArea: self.specialArea, //所属专区
				pkCountry: self.pkSettleCountry,
				pkSettleCountry: self.pkSettleCountry
			};
			uni.showLoading({
				title: 'Loading....'
			});
			self._post('sale/api/order/pay-reg-order', params, res => {
				uni.hideLoading();
				self.registerForm = res.data;
				self.isPopup = true;
			});
		},
		yuePay(e) {
			let self = this;
			let params = {
				pkCountry: self.pkSettleCountry,
				pkSettleCountry: self.pkSettleCountry,
				payPwd: e, //支付密码
				orderCode: self.orderCode, //订单编号
				specialArea: self.specialArea //所属专区
			};
			uni.showLoading({
				title: 'Loading....'
			});
			self._post('sale/api/order/pay-oth-order', params, res => {
				uni.hideLoading();
				self.gotoPage('/pages/order/myorder', 'reLaunch');
				// if(self.specialType !=2){
				// 	self.gotoPage('/pages/order/myorder', 'reLaunch');
				// }else{
				// 	self.showUp = true;
				// }
			});
		},
		openAgreement() {
			let self = this;
			self.time1 = setInterval(function() {
				if (self.form.payTime > 0) {
					self.form.payTime--;
				} else {
					clearInterval(self.time1);
					self.time1 = null;
				}
			}, 1000);
		}
	}
};
</script>

<style lang="scss">
.pop-bg {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 99;
	background-color: rgba(0, 0, 0, 0.65);
}

.upgrade-pop {
	position: fixed;
	left: 0;
	top: 300rpx;
	right: 0;
	z-index: 100;
	width: 600rpx;
	margin: auto;
}

.cashier {
	padding: 0 22rpx 0 23rpx;
}

.cashier-top {
	height: 309rpx;
	padding: 60rpx 0 76rpx 0;
	box-sizing: border-box;
}

.content-box {
	width: 704rpx;
	box-sizing: border-box;
	padding: 0 22rpx 0 22rpx;
	margin-bottom: 20rpx;
	background: #ffffff;
	border-radius: 20rpx;
	word-break: break-all;
	line-height: 1.5;
	padding-bottom: 86rpx;

	.info-title {
		padding-top: 39rpx;
		margin-bottom: 15rpx;
		font-weight: bold;
		font-size: 28rpx;
		color: #222;
	}
}

.pay-icon {
	width: 46rpx;
	height: 46rpx;
	margin-right: 11rpx;
}

.pay-icon.wx {
	width: 36rpx;
	height: 34rpx;
}

.pay-item {
	padding: 20rpx 0;
}

.radio-check {
	width: 32rpx;
	height: 32rpx;
	background: #ffffff;
	border: 2rpx solid #dddddd;
	border-radius: 50%;
	margin-right: 11rpx;
	margin-left: 20rpx;
	position: relative;
	box-sizing: border-box;
}

.radio-check.checked {
	border: none;
	background-color: #fb3024;
}

.radio-check.checked::after {
	content: '';
	position: absolute;
	z-index: 1;
	width: 16rpx;
	height: 16rpx;
	background: #ffffff;
	border-radius: 50%;
	left: 8rpx;
	top: 8rpx;
}

.icon.icon-jiantou {
	font-size: 26rpx;
	color: #999;
	font-weight: bold;
	margin-left: 10rpx;
	transition: transform 0.4s;
}

.icon.icon-jiantou.checked {
	transform: rotate(90deg);
}

.progress-box {
	width: 507rpx;
	height: 24rpx;
	background: #ffffff;
	border-radius: 12rpx;
	position: relative;
	margin: 30rpx auto;
}

.progress-box-item {
	width: 20%;
	position: absolute;
	left: 0;
	top: 0;
	height: 24rpx;
	background: #fb3024;
	border-radius: 12rpx;
}

.copy-text {
	position: absolute;
	left: 140rpx;
	top: 0;
	bottom: 0;
	margin: auto;
	padding-left: 20rpx;
	white-space: nowrap;
	line-height: 1;
	display: flex;
	align-items: center;
	font-weight: 400;
}

.res-item {
	min-height: 78rpx;
	border-bottom: 1px solid #eee;
	border-radius: 0;
}

.res-item-name {
	width: 240rpx;
	// padding-left: 55rpx;
	flex-shrink: 0;
	box-sizing: border-box;
	color: #999;
	font-size: 24rpx;
}

.res-item-name-r {
	flex-shrink: 0;
	word-break: break-all;
}

.s-pop-btn {
	width: 508rpx;
	height: 72rpx;
	background: #fb3024;
	border-radius: 36rpx;
	font-size: 30rpx;
	font-family: SourceHanSansCN;
	font-weight: 400;
	word-break: break-all;
	padding: 0 20rpx;
	box-sizing: border-box;
	color: #f9f9f9;
	line-height: 1.5;
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 20rpx auto;
}

.autoBox {
	height: 0;
	overflow: hidden;
	transition: all 0.3s ease;
}

.autoBox.open {
	height: auto;
}

.gitImage {
	position: absolute;
	z-index: 2;
	left: 0;
	top: 0;
	bottom: 0;
	width: 600rpx;
	height: 600rpx;
	margin: auto;
}

.gitImage2 {
	position: absolute;
	z-index: 1;
	left: 0;
	top: 0;
	bottom: 0;
	width: 600rpx;
	height: 600rpx;
	margin: auto;
}

.pop-success-s {
	position: fixed;
	z-index: 99;
	width: 664rpx;
	background: #ffffff;
	border-radius: 10px;
	padding: 50rpx 20rpx;
	box-sizing: border-box;
	left: 0;
	top: 20%;
	right: 0;
	margin: auto;
}
</style>
