123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <template>
- <view>
- <u-modal
- v-model="payWayPop"
- :title-style="{ color: '#404040' }"
- title="选择支付方式"
- width="550rpx"
- :show-confirm-button="false"
- :show-cancel-button="false"
- >
- <view class="pay-content">
- <view class="pay-list">
- <radio-group>
- <view class="pay-list-item">
- <view class="pay-list-item-image">
- <image class="image" src="/static/img/wechat-icon-new.png" mode="aspectFit" />
- <view>微信支付</view>
- </view>
- <view class="radioBox">
- <radio color="#2DCF8C" value="1" :checked="1 === radioCurrent" />
- </view>
- </view>
- <view class="pay-list-item">
- <view class="pay-list-item-image">
- <image class="image" src="/static/img/gy-icon-new.png" mode="aspectFit" />
- <view>贵州银行</view>
- </view>
- <view class="radioBox">
- <radio color="#2DCF8C" value="2" :checked="2 === radioCurrent" />
- </view>
- </view>
- <view class="pay-list-item">
- <view class="pay-list-item-image">
- <image class="image" src="/static/img/juhe-icon-new.png" mode="aspectFit" />
- <view>聚合支付</view>
- </view>
- <view class="radioBox">
- <radio color="#2DCF8C" value="3" :checked="3 === radioCurrent" />
- </view>
- </view>
- </radio-group>
- </view>
- </view>
- </u-modal>
- <u-toast ref="uToast" />
- </view>
- </template>
- <script>
- import { getEnvIsWx } from '@/utils/judgEnvironment.js';
- import $wxPay from '@/utils/wxPay.js';
- export default {
- props: {
- // 弹框显示
- payWayPop: {
- type: Boolean,
- default: true
- },
- // 订单数组
- curOrderList: {
- type: Array,
- default: null
- },
- // 设备编号
- deviceNo: {
- type: String,
- default: null
- },
- // 地磁支付需要字段
- payeeId: {
- type: String,
- default: undefined
- },
- // 地磁支付需要字段
- payeeName: {
- type: String,
- default: undefined
- },
- // 扫码支付需要字段
- sanPay: {
- type: Boolean,
- default: false
- },
- // 追缴类型
- pursueType: {
- type: String,
- default: undefined
- },
- // 车牌号
- vehicleNo: {
- type: String,
- default: undefined
- },
- // 跳转页面
- jumpUrl: {
- type: String,
- default: null
- },
- // 出口扫码 接口不一样
- exportFlag: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- wxEnv: true,
- radioCurrent: 1
- };
- },
- created() {
- this.wxEnv = getEnvIsWx();
- },
- methods: {
- /**
- * 贵阳银行支付
- * @param {Array} orderList 需要支付的订单号组成的数组
- * @param {String} deviceNo 设备编号(只有车位锁部分有)
- * */
- gyBankPay() {
- const params = {
- orderList: this.curOrderList,
- deviceNo: this.deviceNo,
- jumpUrl: this.jumpUrl,
- payeeId: this.payeeId,
- payeeName: this.payeeName,
- pursueType: this.pursueType,
- vehicleNo: this.vehicleNo,
- sanPay: this.sanPay
- };
- if (this.exportFlag == true) {
- this.$u.api
- .quickPayExportApi(params)
- .then((res) => {
- if (res.data.needPay) {
- let payUrl = res.data.url;
- location.href = payUrl;
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.reload();
- }, 1000);
- }
- })
- .catch((err) => {
- this.$refs.uToast.show({
- title: err.msg,
- type: 'error'
- });
- });
- } else {
- this.$u.api
- .payGzbank(params)
- .then((res) => {
- if (res.data.needPay) {
- let payUrl = res.data.url;
- location.href = payUrl;
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.reload();
- }, 1000);
- }
- })
- .catch((err) => {
- this.$refs.uToast.show({
- title: err.msg,
- type: 'error'
- });
- });
- }
- },
- /**
- * 聚合支付
- * */
- juhePay() {
- this.getWXPayByJava(this.curOrderList, this.deviceNo);
- },
- /**
- * 微信支付
- */
- wechatPay() {
- const params = {
- orderList: this.curOrderList,
- openid: this.vuex_wxinfo.openId,
- deviceNo: this.deviceNo || undefined,
- payeeId: this.payeeId || undefined,
- payeeName: this.payeeName || undefined,
- vehicleNo: this.vehicleNo,
- sanPay: this.sanPay
- };
- if (this.exportFlag) {
- this.$u.api.parkingWechatPayApi(params).then((res) => {
- if (res.code === 200) {
- if (res.data.needPay) {
- $wxPay.wexinPay(res.data.wx).then((r) => {
- switch (Number(r.code)) {
- case 0: // 成功
- //#ifdef H5
- window.location.reload();
- //#endif
- break;
- case 1: // 取消
- this.$refs.uToast.show({
- title: '已取消支付',
- type: 'info'
- });
- window.location.reload();
- break;
- case 2: // 支付失败
- this.$refs.uToast.show({
- title: '支付失败,请检查!',
- type: 'error'
- });
- break;
- }
- });
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.reload();
- }, 1000);
- }
- }
- });
- } else {
- this.$u.api.wechatPayApi(params).then((res) => {
- if (res.code === 200) {
- if (res.data.needPay) {
- $wxPay.wexinPay(res.data.wx).then((r) => {
- switch (Number(r.code)) {
- case 0: // 成功
- //#ifdef H5
- window.location.reload();
- //#endif
- break;
- case 1: // 取消
- this.$refs.uToast.show({
- title: '已取消支付',
- type: 'info'
- });
- window.location.reload();
- break;
- case 2: // 支付失败
- this.$refs.uToast.show({
- title: '支付失败,请检查!',
- type: 'error'
- });
- break;
- }
- });
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.reload();
- }, 1000);
- }
- }
- });
- }
- },
- /**
- * 直接通过后台获取贵阳银行微信支付地址
- * @param {Array} list 需要支付的订单组合数组
- * @param {Number} deviceNo 设备编号(在停车锁部分需要)
- * */
- getWXPayByJava(orderList, deviceNo) {
- let params = {
- orderList: orderList,
- openid: this.vuex_wxinfo.openId,
- jumpUrl: this.jumpUrl,
- deviceNo: deviceNo ? deviceNo : null,
- payeeId: this.payeeId,
- payeeName: this.payeeName,
- pursueType: this.pursueType,
- vehicleNo: this.vehicleNo,
- sanPay: this.sanPay
- };
- if (this.exportFlag) {
- this.$u.api
- .polyPayExportApi(params)
- .then((res) => {
- if (res.code === 200) {
- if (res.data.needPay) {
- localStorage.setItem('jumpUrl', this.jumpUrl);
- location.href = res.data.qrCodeUrl;
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.href = this.jumpUrl;
- }, 1000);
- }
- } else {
- uni.hideLoading();
- }
- })
- .catch((err) => {
- this.$refs.uToast.show({
- title: '无法调起微信支付!',
- type: 'error'
- });
- });
- } else {
- this.$u.api
- .ordinaryWxPay(params)
- .then((res) => {
- if (res.code === 200) {
- if (res.data.needPay) {
- localStorage.setItem('jumpUrl', this.jumpUrl);
- location.href = res.data.qrCodeUrl;
- } else {
- this.$refs.uToast.show({
- title: '无需支付',
- type: 'info'
- });
- setTimeout(() => {
- uni.hideLoading();
- location.href = this.jumpUrl;
- }, 1000);
- }
- } else {
- uni.hideLoading();
- }
- })
- .catch((err) => {
- this.$refs.uToast.show({
- title: '无法调起微信支付!',
- type: 'error'
- });
- });
- }
- },
- /**
- * 关闭弹框
- * */
- closePaymentMethod() {
- this.$emit('closePaymentMethod');
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import './choosePayment.scss';
- </style>
|