<template>
	<view>
		<!-- 头部 -->
		<view class="width100 height120 backcorfff">
			<image :src="gasOrderList.gasimg" class="flleft conImg mart10 margle10"></image>
			<view class="conCont paddtop15">
				<view class="font20 fontwig6 fcor333 text1 paddtright10">{{gasOrderList.gasname}}</view>
				<view class="font14 fcor999 text2 paddtop5 paddtright10">{{gasOrderList.gasaddress}}</view>
				<view class="font20 fontwig6 fcoreb5 paddtop5">￥{{gasOrderList.highChildOrderList[0].gasPriceVip}}
					<text class="margle10 slogan font14">￥{{gasOrderList.highChildOrderList[0].gasPriceGun}}</text>
				</view>
			</view>
		</view>
		<!-- //订单详情 -->
		<view class="mart10 heightl60 paddleft10 fcor333 fontwig6 font18 width100 backcorfff">订单详情</view>
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				油号\油枪
			</view>
			<view class="flright width40 fotct">
				{{gasOrderList.highChildOrderList[0].gasOilNo}}#/{{gasOrderList.highChildOrderList[0].gasGunNo}}号
			</view>
		</view>
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				加油金额
			</view>
			<view class="flright width40 fotct">
				¥{{orderList.oilingPrice}}
			</view>
		</view>
		<!-- 新增 -->
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				加油升数
			</view>
			<view class="flright width40 fotct">
				{{orderList.oilLiters}}L
			</view>
		</view>
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				平台折扣
			</view>
			<view class="flright width40 fotct" v-if="orderList.discount != 1">
				{{(orderList.discount * 100).toFixed(2)}}折
			</view>
			<view class="flright width40 fotct" v-else>
				无
			</view>
		</view>
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				每升优惠
			</view>
			<view class="flright width40 fotct" v-if="!memDiscountId">
				¥{{orderList.litersPreferences}}
			</view>
			<view class="flright width40 fotct" v-else>
				¥0
			</view>
		</view>
		<view class="line1"></view>
		<view class="heightl60 paddleft10 fcor666  font16 width100 backcorfff">
			<view class="flleft width50">
				本次优惠
			</view>
			<view class="flright width40 fotct" v-if="!memDiscountId">
				¥{{orderList.totalPreferences}}
			</view>
			<view class="flright width40 fotct" v-else>
				¥0
			</view>
		</view>

		<view class="width100 backcorfff mart10">
			<view class="width96 alijusstart height50 font14 fcor666">
				<view class="width40 fcor333 fontwig6 font16">邀请码</view>
				<input class="width60 fotrt font15" style="padding-right: 6%;" v-model="identificationCode"
					placeholder="请输入邀请码" />
			</view>
		</view>

		<!-- //优惠券，积分抵扣 -->
		<view class="width100 concont mart10 backcorfff">
			<view class="height50 width100 paddtop5 backcorfff" @click="showPopup()">
				<view class="width50 flleft fcor333 fontwig6 font16" style="padding-left: 2%;">
					优惠抵扣<text class="yhqky">{{OrderPreList.length}}张可用</text>
				</view>
				<view class="width40 flright fotrt paddtright15 font15 fontwig6 fcor666 alijun"
					style="align-items: center;" v-if="deductionPrice == 0">
					未使用
					<image style="width: 40rpx;height: 40rpx;" src="../../../static/img/jt.png"></image>
				</view>
				<view class="width40 flright fotrt paddtright15 font15 fontwig6 fcoreb5 alijun"
					style="align-items: center;" v-else>
					-￥{{deductionPrice}}
					<image style="width: 40rpx;height: 40rpx;" src="../../../static/img/jt.png"></image>
				</view>
			</view>
			<view class="width94 line1 mart5 marb5"></view>
			<view class="Bubble alijusstart font14 fcor999">
				选取: <text class="tests fotct font14 colorc3 paddleft5 paddtright5">{{priceValue[1]}}</text> 分
			</view>
			<view class="width94 alijusstart paddtop10">
				<view class="width30 fcor333 font16">
					积分抵扣
				</view>
				<view class="cj-slider">
					<view class="flleft fotct font14 fcor666" style="width: 15%;">0</view>
					<cj-slider style="width: 60%; float:left;" v-if="isDiscount" v-model="priceValue" :min="0"
						:max="availIntegal" :step="1" :blockWidth="40" @start="blockStart" @moving="blockMoving"
						@end="blockEnd" />
					<view class="flright fotrt font14 fcor666" style="width: 25%;">{{availIntegal}}</view>
				</view>
			</view>
			<view class="width94 line1 mart15 marb5"></view>
			<view class="height50 width100 backcorfff">
				<view class="width70 flleft fcor666 font16 text1" style="padding-left: 2%;">
					抵扣金额
				</view>
				<view class="width20 flright fotrt paddtright15 font15 fcor666 alijun" style="align-items: center;">
					¥{{priceValue[1] / 100}}
				</view>
			</view>
			<view class="width94 line1 mart5 marb5"></view>
			<view class="height40 width100 backcorfff" v-if="Integrastu == 1">
				<view class="width40 flleft fcor666 font15 fontwig6 text1 alijusstart" style="padding-left: 2%;">
					<image src="../../../static/img/rebate.png" mode="widthFix" style="width: 25px;"></image>
					<text>下单返积分</text>
				</view>
				<view class="width50 flright fotrt paddtright15 font15 colore95 alijun" style="align-items: center;">
					返{{rebateIntegral}}积分
				</view>
				<!-- <view class="width50 flright fotrt paddtright15 font15 colore95 alijun" style="align-items: center;"
					v-if="Integrastu == 2">
					{{rebateIntegral}}
				</view> -->
			</view>
			<view class=" width100 backcorfff alijusstart paddbotm10" style="padding-left: 2%;">
				<image src="../../../static/img/sigh.png" mode="widthFix" class="icon20"></image>
				<text class="fcor999 font13">积分抵扣与优惠券抵扣不同享</text>
			</view>
		</view>

		<!-- //支付方式 -->
		<view class="mart10 heightl60 paddleft10 fcor333 fontwig6 font18 width100 backcorfff">支付方式:</view>
		<view class="line1"></view>
		<view class="width100 backcorfff" v-for="(item,index) in paytypeList" :key="index">

			<view class="line1" v-if="item == 2"></view>
			<view class="heightl60 paddleft10 fcor666 width100 backcorfff" v-if="item == 2" @tap="paytype='2'">
				<view class="width60 flleft font16">
					微信支付
				</view>
				<view class="flright width30 fotct" v-if="isUse">
					<radio :checked="paytype=='2'" color="#0083f5" />
				</view>
			</view>

			<view class="line1" v-if="item == 6"></view>
			<view class="heightl60 paddleft10 fcor666 width100 backcorfff" v-if="item == 6" @tap="paytype='6'">
				<view class="width60 flleft font16">
					油卡支付<text class="font14 fcor666 margle">余额: {{oilPirce}}元</text>
				</view>
				<view class="flright width30 fotct" v-if="isUse">
					<radio :checked="paytype=='6'" color="#0083f5" />
				</view>
			</view>

			<view class="line1" v-if="item == 3"></view>
			<view class="heightl60 paddleft10 fcor666 width100 backcorfff" v-if="item == 3" @tap="paytype='3'">
				<view class="width60 flleft font16">
					汇联通工会卡<text class="font14 fcor666 margle">余额: {{tongCardPrice}}元</text>
				</view>
				<view class="flright width30 fotct" v-if="isUse">
					<radio :checked="paytype=='3'" @click="changeRiado()" color="#0083f5" />
				</view>
			</view>
			<view class="line1" v-if="item ==7"></view>
			<view class="heightl60 paddleft10 fcor666 width100 backcorfff" v-if="item ==7" @tap="paytype='7'">
				<view class="width60 flleft font14">
					车队油卡<text class="font14 fcor666 margle">余额: {{oilUserNoPrice}}元</text>
				</view>
				<view class="flright width30 fotct" v-if="isUse">
					<radio :checked="paytype=='7'" color="#0083f5" />
				</view>
			</view>
		</view>



		<view v-if="paytype=='7'" class="backcorfff">
			<view class="heightl60 paddleft10 fcor333 fontwig6 font16 width100 backcorfff flleft">车队油卡列表</view>
			<view class="line1"></view>
			<view class="heightl60 paddleft10 fcor666 width100 backcorfff" v-for="(item,index) in oilUserCardlist"
				:key="index">
				<view class="width60 flleft font14">
					{{item.cardNo}}({{item.contactName}})
				</view>
				<view class="flright width30 fotct">
					<radio :checked="oilUserno==item.cardNo" @click="changeRiado1(item)" color="#0083f5" />
				</view>
			</view>

			<view class="username">
				<view class="namecont font15">车牌号</view>
				<input style="width: 70%;" placeholder="输入车牌号" class="font15" v-model="cardNoNumber">
				<!-- <view class="date text1" >{{cardNoNumber}}</view> -->
				<!-- </view> -->
				<picker mode="selector" style="width: 20%;" :range="UserCard" range-key="carLicensePlate"
					@change="bindUserCard">
					<view class="date text1" style="color: white;position: absolute;margin-top: -2px;min-width: 100px;">
						11111{{cardNoNumber}}</view>
				</picker>
				<image class="flright" style="width: 15px;height: 15px;" src="../../../static/img/downj.png">
				</image>
			</view>
		</view>

		<view class="width100 mart15 fcor333 font16 fontwig6 paddleft10">重要说明</view>
		<view class="width95 paddleft10 font14 fcor999	 mart5">1.<text
				class="fcor089 fontwig6">请先加油后下单</text>,即您到站后,与工作人员确认油号,枪号后再付款。</view>
		<view class="width95 paddleft10 font14 fcor999  mart5">
			2.请勿先付款后加油,若您已下单付款。请于24小时内到加油站完成加油;若您48小时内未完成加油,请及时发起退单;逾期退单可能会退单失败。</view>
		<view class="height80 width100"></view>
		<!-- 底部按钮 -->
		<view class="footer">
			<view class="width50 flleft fcoreb5 padleft15 font15">
				合计: ￥<text class="font24">{{payPrice}}</text>
			</view>
			<button class="reBtn flright" @click="create">去支付</button>
		</view>


		<wybPopup ref="popup" type="bottom" width="500" :scrollY="true" radius="6" :showCloseIcon="true">
			<view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view>
			<view class="width92 height110 tccs mart10 alijus" v-for="(items, index) in OrderPreList" :key="index"
				@click="radioChanges(items)">
				<image mode="widthFix" :src="imageUrl+items.discountImg"></image>
				<view class="alijus width60 margle10">
					<view class="width80p">
						<view class="font16 fontwig6 fcor333 text1">{{items.discountName}}</view>
						<view class="font13 fcor999 mart5">
							有效期:{{items.useEndTime | timeFormat('yyyy-mm-dd hh:mm:ss')}}
						</view>
					</view>
					<view class="width20 fotrt">
						<view>
							<radio v-if="items.discountCondition && orderPrice >= items.discountCondition"
								color="#c72a20" :checked="items.id == memDiscountId" />
							<radio v-if="items.discountCondition && orderPrice < items.discountCondition"
								color="#c72a20" disabled="true" :checked="items.id == memDiscountId" />

							<radio v-if="!items.discountCondition" color="#c72a20"
								:checked="items.id == memDiscountId" />
						</view>
					</view>
				</view>
			</view>
		</wybPopup>

		<ssPaymentPassword ref="paymentPassword" :mode="1" @submit="submitHandle" />
	</view>
</template>

<script>
	import {
		wechatPay,
		getHuiLianTongCardBalance,
		cardPay,
		findUser,
		getUserOrderPreList,
		canUseDiscount,
		create,
		cancel,
		oilPriceDiscountCompute,
		getRebateIntegral,
		getThirdPartyByDetail,
		getUserCardList,
		getCardListByCardNo
	} from '../../../Utils/Api.js';
	import ssPaymentPassword from '../../../components/sanshui-payment-password/index.vue';
	import wybPopup from '../../../components/wyb-popup/wyb-popup.vue';
	import cjSlider from '@/components/cj-slider/cj-slider.vue';
	let app = getApp();
	// #ifdef H5
	var jweixin = require('jweixin-module');
	// #endif
	export default {
		components: {
			ssPaymentPassword,
			wybPopup,
			cjSlider
		},
		data() {
			return {
				orderNo: '',
				orderList: '',
				tongCardPrice: 0,
				imageUrl: app.globalData.imgUrl,
				oilPirce: 0, //油卡余额
				user: '',
				paytype: '2',
				PaymentPassword: '',
				orderPrice: '', //原价
				deductionPrice: '0.00', //优惠金额
				OrderPreList: [], //优惠券数据
				isUse: true, // 是否禁用状态
				payPrice: 0, //支付价格
				isDiscount: true, //刷新组件
				memDiscountId: '', //优惠券id
				priceValue: [0, 0], // 积分可以指定默认值
				availIntegal: 0, // 可用积分
				gasOrderList: '', //存的订单信息
				rechargeDes: '', // 支付详情
				rebateIntegral: '', //返回积分
				Integrastu: 1, //返积分状态
				paytypeList: [], //支付方式
				identificationCode: '', //渠道商
				oilUserCardlist: '', //油卡列表
				oilUserno: '', //油卡卡号
				contactName: '', //油卡联系人
				oilUserNoPrice: '', //油卡余额
				UserCard: '', //车牌号列表
				cardNoNumber: '', // 车牌号
			}
		},
		onLoad(e) {
			this.gasOrderList = app.globalData.pelletoilList;
			this.orderPrice = this.gasOrderList.highChildOrderList[0].goodsPrice;
			// #ifdef H5
			this.identificationCode = app.globalData.staffCode;
			// #endif
			// #ifdef MP
			this.identificationCode = app.globalData.identificationCode;
			// #endif
		},
		onShow() {
			let that = this;
			that.findUser();
			this.priceValue[1] = 0;
			this.reload();
			this.calculatepayPrice();
			this.getUserCardList();
		},
		methods: {

			//查询支付方式
			getThirdPartyByDetail() {
				// #ifdef H5
				this.showType = 2;
				// #endif
				// #ifdef MP
				this.showType = 1;
				// #endif
				let datas = {
					platformId: this.showType,
					"companyId": app.globalData.companyId,
					productType: 6
				}
				getThirdPartyByDetail(datas).then(res => {
					if (res.return_code == '000000') {
						this.rechargeDes = res.return_data;
						this.paytypeList = res.return_data.productPayType.split(',');
						this.paytypeList = this.paytypeList.slice(0, this.paytypeList.length - 1);
						let zkprice = parseFloat(res.return_data.integralDiscount / 100).toFixed(2);
						let pprice = parseFloat(this.payPrice * 100).toFixed(0)
						let payprice = parseFloat(this.payPrice * 100 * zkprice).toFixed(
							0);
						if (payprice > this.user.gold) {
							this.availIntegal = this.user.gold;
						} else {
							this.availIntegal = payprice;
						}
					}
				});
			},
			//查询我的资料
			findUser() {
				let params;
				findUser(params).then(res => {
					if (res.return_code == '000000') {
						app.globalData.userInfo = res.return_data;
						this.user = res.return_data;
						if (res.return_data.oilCard) {
							this.oilPirce = res.return_data.oilCard.amount;
						}
						this.canUseDiscount();
						this.oilPriceDiscountCompute();
						this.getHuiLianTongCardBalance();
						uni.setStorage({
							key: "user",
							data: res.return_data
						})
					}
				});
			},
			//查询油卡包列表
			getUserCardList() {
				let datas = {
					type: 3
				}
				getUserCardList(datas).then(res => {
					if (res.return_code == '000000' && res.return_data != '') {
						this.oilUserCardlist = res.return_data;
						this.oilUserno = res.return_data[0].cardNo;
						this.contactName = res.return_data[0].contactName;
						this.oilUserNoPrice = res.return_data[0].balance;
						this.getCardListByCardNo(res.return_data[0].cardNo);
					}
				});
			},
			//查询车牌号列表
			getCardListByCardNo(item) {
				let datas = {
					cardNo: item
				}
				getCardListByCardNo(datas).then(res => {
					if (res.return_code == '000000' && res.return_data != '') {
						this.UserCard = res.return_data;
						this.cardNoNumber = res.return_data[0].carLicensePlate;
					} else {
						this.UserCard = '';
						this.cardNoNumber = '';
					}
				});
			},
			//选择车牌号
			bindUserCard(e) {
				this.cardNoNumber = this.UserCard[e.target.value].carLicensePlate;
			},
			//支付返利积分
			getRebateIntegral() {
				if (!this.payPrice) {
					return;
				}
				let datas = {
					"companyId": app.globalData.companyId,
					"price": this.payPrice,
					"type": 6,
				}
				getRebateIntegral(datas).then(res => {
					if (res.return_code == '000000') {
						this.rebateIntegral = res.return_data;
						this.Integrastu = 1;
					} else {
						this.rebateIntegral = res.return_msg;
						this.Integrastu = 2;
					}
				})
			},
			//查询优惠券
			canUseDiscount() {
				let params = {
					"goodsType": "3",
					"goodsId": this.gasOrderList.highChildOrderList[0].goodsId,
					"goodsPrice": this.gasOrderList.highChildOrderList[0].goodsPrice
				}
				canUseDiscount(params).then(res => {
					if (res.return_code == '000000') {
						this.OrderPreList = res.return_data;
					}
				});
			},

			//计算价格
			oilPriceDiscountCompute() {
				let datas = {
					"price": this.gasOrderList.highChildOrderList[0].goodsPrice,
					"goodsId": this.gasOrderList.highChildOrderList[0].goodsId,
					"oilNo": this.gasOrderList.highChildOrderList[0].gasOilNo,
					"isTyAgent": this.gasOrderList.isTyAgent
				}
				oilPriceDiscountCompute(datas).then(res => {
					if (res.return_code == '000000') {
						this.orderList = res.return_data;
						this.payPrice = res.return_data.payPrice;
						this.getRebateIntegral();
						this.getThirdPartyByDetail();
					}
				})
			},

			//弹出优惠券
			showPopup() {
				this.$refs.popup.show();
			},
			//选择优惠券
			radioChanges(item) {
				this.rechangeload();
				if (this.memDiscountId == item.id) { // 如果已经选中，则取消选中
					this.memDiscountId = '';
					this.deductionPrice = '0.00';
					this.priceCaluc(this.orderList.payPrice);

				} else { // 否则进行选中赋值
					if (item.discountType == 1) {
						if (this.orderPrice >= item.discountCondition) {
							this.memDiscountId = item.id;
							//满减价格
							this.deductionPrice = item.discountPrice;
							let oldprice = this.orderPrice - this.deductionPrice;
							this.priceCaluc(oldprice);
						} else {
							uni.showToast({
								title: '请满' + item.discountCondition + '使用此券',
								icon: 'none',
								duration: 2000
							})
						}
					}
					if (item.discountType == 2) {
						this.memDiscountId = item.id;
						//抵扣价格
						this.deductionPrice = item.discountPrice;
						let oldprice = this.orderPrice - this.deductionPrice;
						this.priceCaluc(oldprice);
					}
					if (item.discountType == 3) {
						this.memDiscountId = item.id;
						// 打折
						this.deductionPrice = parseFloat(this.orderPrice - (this.orderPrice * item.discountPrice)).toFixed(2);
						let oldprice = parseFloat(this.orderPrice * item.discountPrice).toFixed(2);
						this.priceCaluc(oldprice);

					}
				}
				this.$refs.popup.hide();
			},
			//计算价格
			priceCaluc(item) {
				// let zkprice = 0.9;
				// parseFloat(this.rechargeDes.integralDiscount / 100).toFixed(2);
				// let pprice = parseFloat(item * 100).toFixed(0);
				let payprice = parseFloat(item * 100).toFixed(0);
				if (payprice > this.user.gold) {
					this.availIntegal = this.user.gold;
					this.priceValue[1] = 0;
				} else {
					this.availIntegal = payprice;
					this.priceValue[1] = 0;
				}
				this.reload();
				this.calculatepayPrice();
			},
			//计算支付价格
			calculatepayPrice() {
				if (this.deductionPrice == 0) {
					this.payPrice = Math.abs(parseFloat(this.orderList.payPrice - (parseFloat(this.priceValue[1] / 100)
							.toFixed(
								2)))
						.toFixed(2));
				} else {
					this.payPrice = Math.abs(parseFloat(this.orderPrice - (parseFloat(this.priceValue[1] / 100).toFixed(
							2)) - this
						.deductionPrice).toFixed(2));
				}
				this.getRebateIntegral();
			},
			rechangeload() {
				this.isUse = false;
				this.$nextTick(() => (this.isUse = true))
			},
			//刷新组件
			reload() {
				this.isDiscount = false;
				this.$nextTick(() => (this.isDiscount = true))
			},

			//滑动开始
			blockStart() {},
			blockMoving() {
				// console.log('正在滑动中')
			},
			//滑动结束
			blockEnd() {
				this.isDiscount = 1;
				if (this.deductionPrice == 0) {
					this.payPrice = Math.abs(parseFloat(this.orderList.payPrice - parseFloat(this.priceValue[1] / 100)
							.toFixed(2))
						.toFixed(2));
				} else {
					this.payPrice = Math.abs(parseFloat(this.orderPrice - parseFloat(this.priceValue[1] / 100).toFixed(2) -
						this.deductionPrice).toFixed(2));
				}
				if (this.payPrice == 0) {
					this.isUse = false;
					this.paytype = '';
				} else {
					this.isUse = true;
				}
				this.getRebateIntegral();
			},

			//密码支付完成
			submitHandle(e) {
				this.PaymentPassword = e.value;
				if (this.PaymentPassword == '') {
					uni.showToast({
						title: '请勿手动关闭弹窗',
						icon: 'none',
						duration: 2000
					})
					return;
				}
				uni.showLoading({
					title: '支付中...'
				})
				if (this.payPrice == 0 && !this.orderNo) {
					let goods = {
						"childOrderList": [{
							"gasGunNo": this.gasOrderList.highChildOrderList[0].gasGunNo,
							"gasOilNo": this.gasOrderList.highChildOrderList[0].gasOilNo,
							"isTyAgent": this.gasOrderList.isTyAgent,
							"goodsId": this.gasOrderList.highChildOrderList[0].goodsId,
							"goodsPrice": this.gasOrderList.highChildOrderList[0].goodsPrice,
							"goodsType": 3,
							"saleCount": 1,
						}],
						"payGold": this.priceValue[1],
						"promoteCode": this.identificationCode,
						"payPwd": this.PaymentPassword
					}

					create(goods).then(res => {
						uni.hideLoading();
						if (res.return_code == '000000') {
							if (app.globalData.gasKey) {
								app.globalData.gasKey = '';
								app.globalData.staffCode = '';
								uni.removeStorage({
									key: 'gasKey'
								})
								uni.removeStorage({
									key: 'staffCode'
								})

							}
							this.orderNo = res.return_data.orderNo;
							uni.reLaunch({
								url: '../../user/order_details/order_details?id=' +
									this.orderNo
							})
							return;
						}
						if (res.return_code == '102130') {
							uni.navigateTo({
								url: '../../login/updatePas/updatePas'
							})
							return;
						}
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						});

					})
					return;
				}
				if (this.paytype == '3' || this.paytype == '6' || this.paytype == '7') {
					let cardNo;
					if (this.paytype == 3) {
						cardNo = this.user.hltCardNo.cardNo;
					}
					if (this.paytype == 6) {
						cardNo = this.user.oilCard.cardNo;
					}
					if (this.paytype == 7) {
						cardNo = this.oilUserno;
					}
					let params = {
						"orderNo": this.orderNo,
						"cardNo": cardNo,
						"password": this.PaymentPassword,
						"carLicensePlate": this.cardNoNumber
					}
					cardPay(params).then(res => {
						uni.hideLoading();
						if (res.return_code == '000000') {
							uni.showToast({
								title: '支付成功'
							})
							uni.reLaunch({
								url: '../../user/order_details/order_details?id=' +
									this.orderNo
							})
							return;
						}
						if (res.return_code == '102130') {
							this.cancel();
							uni.navigateTo({
								url: '../../login/updatePas/updatePas'
							})
							return;
						}
						if (res.return_code == '102132') {
							this.cancel();
							uni.showToast({
								title: res.return_msg,
								icon: 'none'
							})
							return;
						}
						uni.navigateBack({})
						uni.showToast({
							title: res.return_msg,
							icon: 'none'
						})
					})
					return;
				}

			},
			//取消订单
			cancel() {
				let params = {
					orderNo: this.orderNo
				}
				cancel(params).then(res => {
					if (res.return_code == '000000') {
						this.orderNo = '';
					}
				})

			},
			//车队油卡
			changeRiado1(item) {
				this.oilUserno = item.cardNo;
				this.contactName = item.contactName;
				this.oilUserNoPrice = item.balance;
				this.getCardListByCardNo(item.cardNo);
			},
			//获取选择支付方式
			changeRiado() {
				if (!this.user.setHltCard) {
					uni.showToast({
						icon: 'none',
						title: '当前账号还未绑定,前往绑定',
						duration: 2000,
						success() {
							setTimeout(() => {
								uni.navigateTo({
									url: '../../user/bindingCard/bindingCard'
								})
							}, 1000)
						}
					});
					return;
				}
			},
			//查询工会卡余额
			getHuiLianTongCardBalance() {
				let params = {
					cardNo: this.user.hltCardNo.cardNo
				}
				getHuiLianTongCardBalance(params).then(res => {
					if (res.return_code == '000000') {
						this.tongCardPrice = res.return_data.balance;
					}

				});
			},
			//下单
			create() {
				if (this.payPrice == 0) {
					this.$refs.paymentPassword.modalFun('show');
					return;
				}

				if (this.paytype == '') {
					uni.showToast({
						title: '请选择支付方式',
						icon: 'none',
						duration: 2000
					})
					return;
				}

				if (this.paytype == '7') {
					let that = this;
					uni.showModal({
						title: '温馨提示',
						content: '是否使用当前 ' + that.contactName + ' 车队油卡',
						success: function(res) {
							if (res.confirm) {
								that.addorders();
							}
						}
					})
					return;
				}
				this.addorders();
			},
			//下单整合
			addorders() {
				uni.showLoading({
					title: '提交订单中...'
				})
				let goods = {
					"childOrderList": [{
						"gasGunNo": this.gasOrderList.highChildOrderList[0].gasGunNo,
						"gasOilNo": this.gasOrderList.highChildOrderList[0].gasOilNo,
						"isTyAgent": this.gasOrderList.isTyAgent,
						"goodsId": this.gasOrderList.highChildOrderList[0].goodsId,
						"goodsPrice": this.gasOrderList.highChildOrderList[0].goodsPrice,
						"goodsType": 3,
						"saleCount": 1,
					}],
					"payGold": this.priceValue[1],
					"promoteCode": this.identificationCode,
					"payPwd": this.PaymentPassword,
					"companyId": app.globalData.companyId,
					"memDiscountId": this.memDiscountId
				}

				create(goods).then(res => {
					uni.hideLoading();
					if (res.return_code == '000000') {
						if (app.globalData.gasKey) {
							app.globalData.gasKey = '';
							app.globalData.staffCode = '';
							uni.removeStorage({
								key: 'gasKey'
							})
							uni.removeStorage({
								key: 'staffCode'
							})
						}
						this.orderNo = res.return_data.orderNo;
						this.wechatPay();
					} else {
						uni.showToast({
							title: res.return_msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			//获取订单数据
			wechatPay() {
				let that = this;
				if (that.paytype == '') {
					uni.showToast({
						title: '请选择支付方式',
						icon: 'none',
						duration: 2000
					})
					return;
				}
				if (that.paytype == '2') {
					// #ifdef H5
					let params = {
						"orderNo": that.orderNo,
						"openId": app.globalData.openId,
						"openIdType": 2
					}
					// #endif
					// #ifdef MP
					let params = {
						"orderNo": that.orderNo,
						"openId": app.globalData.openId,
						"openIdType": 1
					}
					// #endif
					wechatPay(params).then(res => {
						if (res.return_code == '000000') {
							// #ifdef MP
							uni.showLoading({
								title: '支付中...'
							})
							uni.requestPayment({
								"appId": res.return_data.appId,
								"nonceStr": res.return_data.nonceStr,
								"package": res.return_data.package,
								"paySign": res.return_data.sign,
								"signType": "MD5",
								"timeStamp": res.return_data.timeStamp,
								success: function(res) {
									uni.hideLoading();
									uni.showToast({
										title: '支付成功'
									})
									uni.reLaunch({
										url: '../../user/order_details/order_details?id=' +
											that.orderNo
									});
								},
								fail: function(err) {
									uni.hideLoading();
									uni.navigateBack({})
								},
							});
							// #endif

							//判断是否是公众号
							// #ifdef H5
							//判断微信浏览器
							that.payRequest(res);
							// #endif

						} else {
							that.cancel();
							uni.showToast({
								title: res.return_msg,
								icon: 'none'
							})
						}
					})
					return;
				}
				if (that.paytype == '3') {
					if (!that.user.isSetPayPwd) {
						uni.navigateTo({
							url: '../../login/updatePas/updatePas'
						})
						return;
					}
					if (!that.user.setHltCard) {
						uni.showToast({
							icon: 'none',
							title: '当前账号还未绑定,前往绑定',
							duration: 2000,
							success() {
								setTimeout(() => {
									uni.navigateTo({
										url: '../../user/bindingCard/bindingCard'
									})
								}, 1000)
							}
						});
						return;
					}
					that.$refs.paymentPassword.modalFun('show');
				}

				if (that.paytype == '7') {
					if (!that.user.isSetPayPwd) {
						uni.navigateTo({
							url: '../../login/updatePas/updatePas'
						})
						return;
					}
					that.$refs.paymentPassword.modalFun('show');
				}
				if (that.paytype == '6') {
					if (!that.user.isSetPayPwd) {
						uni.navigateTo({
							url: '../../login/updatePas/updatePas'
						})
						return;
					}
					if (!that.user.isSetOilCard) {
						uni.showToast({
							icon: 'none',
							title: '当前账号还未绑定,前往绑定',
							duration: 2000,
							success() {
								setTimeout(() => {
									uni.navigateTo({
										url: '../../user/bindingCard/bindingCard'
									})
								}, 1000)
							}
						});
						return;
					}
					that.$refs.paymentPassword.modalFun('show');
				}


			},
			payRequest: function(self) {
				let that = this;
				uni.showLoading({
					title: '支付中...'
				})
				jweixin.config({
					// debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					appId: self.return_data.appId, // 必填，公众号的唯一标识
					timestamp: self.return_data.timeStamp, // 必填，生成签名的时间戳
					nonceStr: self.return_data.nonceStr, // 必填，生成签名的随机串
					signature: self.return_data.sign, // 必填，签名，见附录1
					jsApiList: ['chooseWXPay'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
				});
				uni.hideLoading();
				jweixin.ready(function() {
					jweixin.checkJsApi({
						jsApiList: ['chooseWXPay'], // 需要检测的JS接口列表，所有JS接口列表见附录2,
						success: function(res) {},
						fail: function(res) {}
					});
					jweixin.chooseWXPay({
						appId: self.return_data.appId,
						timestamp: self.return_data
							.timeStamp, // 支付签名时间戳，注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
						nonceStr: self.return_data.nonceStr, // 支付签名随机串，不长于 32 位
						package: self.return_data
							.package, // 统一支付接口返回的prepay_id参数值，提交格式如：prepay_id=***）
						signType: 'MD5', // 签名方式，默认为'SHA1'，使用新版支付需传入'MD5'
						paySign: self.return_data.sign, // 支付签名
						success: function(res) {
							// 支付成功后的回调函数
							uni.showToast({
								title: '支付成功'
							})
							uni.reLaunch({
								url: '../../user/order_details/order_details?id=' +
									that.orderNo
							});
						},
						cancel: function(r) {
							uni.navigateBack({})
						},
						fail: function(res) {
							uni.navigateBack({})
						},
						complete: function(res) {

						}
					});
				});

				jweixin.error(function(res) {
					uni.showToast({
						icon: 'none',
						title: '支付失败了',
						duration: 4000
					});
					// config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
					/*alert("config信息验证失败");*/
				});
			},

		}
	}
</script>

<style lang="less">
	page {
		background-color: #f7f7f7;
	}

	.conImg {
		width: 100px;
		height: 100px;
		border-radius: 8px;
	}

	.conCont {
		margin-left: 115px;
	}

	.slogan {
		color: #807c87;
		text-decoration: line-through;
	}

	.footer {
		position: fixed;
		bottom: 0upx;
		width: 100%;
		height: 100rpx;
		color: #FFFFFF;
		border-top: solid 1upx #eee;
		background-color: #FFFFFF;
		z-index: 2;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.reBtn {
			width: 120px;
			background-color: #089bf5;
			color: #FFFFFF;
			text-align: center;
			padding: 0;
			font-size: 16px;
			border-radius: 0px;
			height: 50px;
			line-height: 50px;
			position: absolute;
			right: 0px;
		}
	}


	.concont {
		border-radius: 12px;
	}

	.Bubble {
		margin-left: 50%;
		padding-top: 15px;
	}

	.tests {
		border-radius: 15px;
		height: 22px;
		line-height: 22px;
	}

	.cj-slider {
		width: 100%;
		align-items: center;
		display: flex;
	}

	.yhqky {
		background: #ff0034;
		color: #ffffff;
		font-size: 14px;
		padding-left: 5px;
		padding-right: 5px;
		margin-left: 8px;
		padding-top: 2px;
		padding-bottom: 2px;
	}

	.yhprice {
		margin-top: -30px;
	}

	.contrig {
		margin-left: 180rpx;
	}

	.tccs {
		box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, 0.2);
		border: 1px solid #f6f6f6;
		border-radius: 8px;

		image {
			// float: left;
			width: 160rpx;
			max-height: 160rpx;
			// margin-left: 10px;
		}
	}

	.username {
		width: calc(100% - 100upx);
		height: 100upx;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #f6f6f6;
		padding: 8upx 20upx;

		.namecont {
			color: #666666;
			width: 28%;
		}
	}
</style>
