123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <template>
- <view class="content">
- <image class='bg-image' mode="widthFix"
- src="https://qtzl.etcjz.cn/default-bucket/20240324/3eba2095f5204798a1f8101b_beijing.jpg"></image>
- <view class="content-re">
- <custom-header title="订单支付" :back="config.hasReturn === 'true'"></custom-header>
- <view style="padding: 20rpx 0 30rpx" class="order-content">
- <!-- 获取产品展示 -->
- <view class="order-car" v-for="(item, index) in orderList" @click="handlePayment(item)" :key="index"
- :class="{ isWing: item.payStatus !== 'UNPAY' }">
- <view class="l-info">
- <view class="goods-name">
- {{ item.payTypeName }}
- </view>
- <view class="goods-des">
- {{ item.payStatusName }}
- </view>
- </view>
- <view class="r-amount">¥: {{ handleAmount(item.fee) }}</view>
- </view>
- </view>
- </view>
- <u-popup v-model="show" mode="bottom" border-radius="14" :closeable="true" length="60%" @close="handleClose">
- <view class="title">微信扫码支付</view>
- <view class="slot-content">
- <view class="order-amount">
- <text>{{ currentData.payTypeName }}:</text>
- <text class="amount">¥ {{ handleAmount(currentData.fee) }}</text>
- </view>
-
- <view style="width: 300rpx; height: 300rpx">
- <qrcode-vue :value="qrCodeValue" :level="level" :render-as="renderAs" style="width: 100%; height: 100%" />
- </view>
- <view class="desc">请您及时付款,二维码将会5分钟后在后超时!</view>
- </view>
- <view class="bottom-btn">
- <u-button class="btn" type="primary" @click="getPayCode">
- 刷新二维码
- </u-button>
- <u-button class="btn" type="success" @click="show = false">
- 已支付
- </u-button>
- </view>
- </u-popup>
- </view>
- </template>
- <script setup lang="ts">
- import handleAmount from '@/utils/handleAmount.js';
- import { unifyTemplate } from '@/hooks/unifyTemplate';
- import { reactive, ref, nextTick } from 'vue';
- import { onLoad } from '@dcloudio/uni-app';
- import { request, myJsonp, toWeixin, requestNew, } from '@/utils/network/request';
-
- import { payType, payMentStatus, orderSource } from './common.js';
- import QrcodeVue, { Level, RenderAs } from 'qrcode.vue';
- const {
- CustomHeader, //头部组件
- initData, //初始化数据
- isShow, //是否展示formBuilderVue组件
- qdOrderVal //qdOrder中数据 ref
- } = unifyTemplate(); //初始化数据
- // import {
- // request
- // } from '../../static/js/network/request'
-
- const orderList = ref<any>([]);
- // 实付款
- const amount = ref<any>('');
- let config = ref<any>({
- jumpPage: ''
- });
- onLoad((opin) => {
- initData(opin, 4).then((data) => {
- console.log('data数据', data);
- getPayStatus(data.order.orderNo)
- delete data.config.tableConfig;
- if (data.config.jumpPage) {
- config.value.jumpPage = data.config.jumpPage;
- }
- });
- });
- let isLock = ref(false);
- function getPayStatus(orderIdOld = '') {
- let orderId = orderIdOld || qdOrderVal.value.orderNo;
- let options = {
- type: 2,
- data: {
- orderId,
- agentId: qdOrderVal.value.agencyId,
- channelId: qdOrderVal.value.channelId,
- },
- method: 'POST',
- showLoading: true
- }
- requestNew('/iaw/issue/order/payQuery', options).then((res) => {
- console.log(res, '请求支付状态获取的数据');
- if (res.code === 0) {
- let data = res.data;
- let dataList = [];
- console.log(data, '支付的数据');
- if (data.paymentStatus === 'ALLSUCCESS') {
- if (isLock.value) {
- return;
- }
- isLock.value = true;
- let { jumpPage } = config.value;
- uni.navigateTo({
- url: '/' + jumpPage,
- animationType: 'pop-in',
- animationDuration: 500
- });
- } else {
- data.datas.forEach((item) => {
- if (item.payStatus === 'UNPAY') {
- dataList.push({
- ...item,
- payStatusName: payMentStatus[item.payStatus],
- payTypeName: payType[item.payType]
- });
- }
- });
- }
- orderList.value = dataList;
- }
- })
- }
- // 订单已支付
- function detectAliPay(orderIdOld = '') {
- let orderId = orderIdOld || qdOrderVal.value.orderNo;
- if (!orderId) {
- return;
- }
- request('7d240e2034f94da399fb0e3775f87a62', {
- data: {
- orderId
- }
- }).then((res) => {
- if (res.statusCode === 0) {
- let data = JSON.parse(res.bizContent);
- let dataList = [];
- console.log(data, '支付的数据');
- if (data.paymentStatus === 'ALLSUCCESS') {
- if (isLock.value) {
- return;
- }
- isLock.value = true;
- let { jumpPage } = config.value;
- return
- uni.navigateTo({
- url: '/' + jumpPage,
- animationType: 'pop-in',
- animationDuration: 500
- });
- } else {
- data.datas.forEach((item) => {
- if (item.payStatus === 'UNPAY') {
- dataList.push({
- ...item,
- payStatusName: payMentStatus[item.payStatus],
- payTypeName: payType[item.payType]
- });
- }
- });
- }
- orderList.value = dataList;
- }
- });
- }
- const show = ref(false);
- const currentData = ref<any>({});
- const qrCodeValue = ref<String>('');
- const level = ref<Level>('M');
- const renderAs = ref<RenderAs>('svg');
- //提交
- function handlePayment(orderData) {
- console.log(orderData);
- if (orderData.payStatus !== 'UNPAY') {
- return;
- }
- currentData.value = {
- ...orderData
- };
- getPayCode();
- }
- // 根据公网ip获取支付地址
- function handleClose() {
- console.log('close');
- getPayStatus();
- }
- function getPayCode() {
- let params = {
- orderId: currentData.value.orderId,
- payType: currentData.value.payType,
- // spbillCreateIp: "",
- // h5Type: ""
- };
- requestNew('/iaw/issue/order/payApply', {
- data: params,
- hideShowModal: true
- }).then((res) => {
- if (res.code === 0) {
- show.value = true;
- let data = res.data;
- qrCodeValue.value = data.codeUrl;
- } else {
- uni.showModal({
- title: '提示',
- content: res.data.errorMsg,
- success: function (res) {
- getPayStatus();
- }
- });
- }
- // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
- });
- }
- // 获取二维码
- function getQrCodeText() {
- let params = {
- orderId: currentData.value.orderId,
- payType: currentData.value.payType,
- spbillCreateIp: "",
- h5Type: ""
- };
- request('377421d6ed4f48a29575aa126838a4d2', {
- data: params,
- hideShowModal: true
- }).then((res) => {
- if (res.statusCode === 0) {
- show.value = true;
- let data = JSON.parse(res.bizContent);
- qrCodeValue.value = data.codeUrl;
- } else {
- uni.showModal({
- title: '提示',
- content: res.data.errorMsg,
- success: function (res) {
- getPayStatus();
- }
- });
- }
- // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
- });
- }
- </script>
- <style lang="scss" scoped>
- view.isWing {
- background-color: #27be5e;
- }
-
- .order-car {
- margin: 30rpx 30rpx 0;
- width: calc(100% - 60rpx);
- height: 170rpx;
- border-radius: 20rpx;
- background-color: #57aef9;
- display: flex;
- justify-content: space-between;
- box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
- align-items: center;
- padding: 0 40rpx;
-
- .l-info {
- color: #fff;
-
- .goods-name {
- margin-bottom: 16rpx;
- font-size: 32rpx;
- font-weight: bold;
- }
-
- .goods-des {
- font-size: 26rpx;
- }
- }
-
- .r-amount {
- font-size: 38rpx;
- color: #fff;
- padding-left: 20rpx;
- font-weight: bold;
- }
- }
-
- .title {
- font-size: 36rpx;
- text-align: center;
- padding: 20rpx 0;
- }
-
- .slot-content {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .order-amount {
- font-size: 28rpx;
- color: #999;
- margin-bottom: 20rpx;
- }
-
- .desc {
- margin-top: 20rpx;
- font-size: 28rpx;
- color: #999;
- }
- }
-
- .bottom-btn {
- padding-top: 40rpx;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .btn {
- width: 260rpx;
- }
- }
- </style>
|