Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

orderPayment.vue 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="content">
  3. <image class='bg-image' mode="widthFix"
  4. src="https://qtzl.etcjz.cn/default-bucket/20240324/3eba2095f5204798a1f8101b_beijing.jpg"></image>
  5. <view class="content-re">
  6. <custom-header title="订单支付" :back="config.hasReturn === 'true'"></custom-header>
  7. <view style="padding: 20rpx 0 30rpx" class="order-content">
  8. <!-- 获取产品展示 -->
  9. <view class="order-car" v-for="(item, index) in orderList" @click="handlePayment(item)" :key="index"
  10. :class="{ isWing: item.payStatus !== 'UNPAY' }">
  11. <view class="l-info">
  12. <view class="goods-name">
  13. {{ item.payTypeName }}
  14. </view>
  15. <view class="goods-des">
  16. {{ item.payStatusName }}
  17. </view>
  18. </view>
  19. <view class="r-amount">¥: {{ handleAmount(item.fee) }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <u-popup v-model="show" mode="bottom" border-radius="14" :closeable="true" length="60%" @close="detectAliPay">
  24. <view class="title">微信扫码支付</view>
  25. <view class="slot-content">
  26. <view class="order-amount">
  27. <text>{{ currentData.payTypeName }}:</text>
  28. <text class="amount">¥ {{ handleAmount(currentData.fee) }}</text>
  29. </view>
  30. <view style="width: 300rpx; height: 300rpx">
  31. <qrcode-vue :value="qrCodeValue" :level="level" :render-as="renderAs" style="width: 100%; height: 100%" />
  32. </view>
  33. <view class="desc">请您及时付款,二维码将会5分钟后在后超时!</view>
  34. </view>
  35. <view class="bottom-btn">
  36. <u-button class="btn" type="primary" @click="getQrCodeText">
  37. 刷新二维码
  38. </u-button>
  39. <u-button class="btn" type="success" @click="show = false">
  40. 已支付
  41. </u-button>
  42. </view>
  43. </u-popup>
  44. </view>
  45. </template>
  46. <script setup lang="ts">
  47. import handleAmount from '@/utils/handleAmount.js';
  48. import { unifyTemplate } from '@/hooks/unifyTemplate';
  49. import { reactive, ref, nextTick } from 'vue';
  50. import { onLoad } from '@dcloudio/uni-app';
  51. import { request, myJsonp, toWeixin } from '@/utils/network/request';
  52. import { payType, payMentStatus, orderSource } from './common.js';
  53. import QrcodeVue, { Level, RenderAs } from 'qrcode.vue';
  54. const {
  55. CustomHeader, //头部组件
  56. initData, //初始化数据
  57. isShow, //是否展示formBuilderVue组件
  58. qdOrderVal //qdOrder中数据 ref
  59. } = unifyTemplate(); //初始化数据
  60. // import {
  61. // request
  62. // } from '../../static/js/network/request'
  63. const orderList = ref<any>([]);
  64. // 实付款
  65. const amount = ref<any>('');
  66. let config = ref<any>({
  67. jumpPage: ''
  68. });
  69. onLoad((opin) => {
  70. initData(opin, 4).then((data) => {
  71. console.log('data数据', data);
  72. detectAliPay(data.qdOrder.qtOrderNo);
  73. delete data.config.tableConfig;
  74. if (data.config.jumpPage) {
  75. config.value.jumpPage = data.config.jumpPage;
  76. }
  77. });
  78. });
  79. let isLock = ref(false);
  80. // 订单已支付
  81. function detectAliPay(orderIdOld = '') {
  82. let orderId = orderIdOld || qdOrderVal.value.qtOrderNo;
  83. if (!orderId) {
  84. return;
  85. }
  86. request('7d240e2034f94da399fb0e3775f87a62', {
  87. data: {
  88. orderId
  89. }
  90. }).then((res) => {
  91. if (res.statusCode === 0) {
  92. let data = JSON.parse(res.bizContent);
  93. let dataList = [];
  94. console.log(data, '支付的数据');
  95. if (data.paymentStatus === 'ALLSUCCESS') {
  96. console.log('全部已支付');
  97. if (isLock.value) {
  98. return;
  99. }
  100. isLock.value = true;
  101. let { jumpPage } = config.value;
  102. uni.navigateTo({
  103. url: '/' + jumpPage,
  104. animationType: 'pop-in',
  105. animationDuration: 500
  106. });
  107. } else {
  108. data.datas.forEach((item) => {
  109. if (item.payStatus === 'UNPAY') {
  110. dataList.push({
  111. ...item,
  112. payStatusName: payMentStatus[item.payStatus],
  113. payTypeName: payType[item.payType]
  114. });
  115. }
  116. });
  117. }
  118. orderList.value = dataList;
  119. }
  120. });
  121. }
  122. const show = ref(false);
  123. const currentData = ref<any>({});
  124. const qrCodeValue = ref<String>('');
  125. const level = ref<Level>('M');
  126. const renderAs = ref<RenderAs>('svg');
  127. //提交
  128. function handlePayment(orderData) {
  129. console.log(orderData);
  130. if (orderData.payStatus !== 'UNPAY') {
  131. return;
  132. }
  133. currentData.value = {
  134. ...orderData
  135. };
  136. getQrCodeText();
  137. }
  138. // 根据公网ip获取支付地址
  139. // 获取二维码
  140. function getQrCodeText() {
  141. let params = {
  142. orderId: currentData.value.orderId,
  143. payType: currentData.value.payType
  144. // spbillCreateIp: "",
  145. // h5Type: ""
  146. };
  147. request('377421d6ed4f48a29575aa126838a4d2', {
  148. data: params,
  149. hideShowModal: true
  150. }).then((res) => {
  151. if (res.statusCode === 0) {
  152. show.value = true;
  153. let data = JSON.parse(res.bizContent);
  154. qrCodeValue.value = data.codeUrl;
  155. } else {
  156. uni.showModal({
  157. title: '提示',
  158. content: res.data.errorMsg,
  159. success: function (res) {
  160. detectAliPay();
  161. }
  162. });
  163. }
  164. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  165. });
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. view.isWing {
  170. background-color: #27be5e;
  171. }
  172. .order-car {
  173. margin: 30rpx 30rpx 0;
  174. width: calc(100% - 60rpx);
  175. height: 170rpx;
  176. border-radius: 20rpx;
  177. background-color: #57aef9;
  178. display: flex;
  179. justify-content: space-between;
  180. box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
  181. align-items: center;
  182. padding: 0 40rpx;
  183. .l-info {
  184. color: #fff;
  185. .goods-name {
  186. margin-bottom: 16rpx;
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. }
  190. .goods-des {
  191. font-size: 26rpx;
  192. }
  193. }
  194. .r-amount {
  195. font-size: 38rpx;
  196. color: #fff;
  197. padding-left: 20rpx;
  198. font-weight: bold;
  199. }
  200. }
  201. .title {
  202. font-size: 36rpx;
  203. text-align: center;
  204. padding: 20rpx 0;
  205. }
  206. .slot-content {
  207. display: flex;
  208. flex-direction: column;
  209. justify-content: center;
  210. align-items: center;
  211. .order-amount {
  212. font-size: 28rpx;
  213. color: #999;
  214. margin-bottom: 20rpx;
  215. }
  216. .desc {
  217. margin-top: 20rpx;
  218. font-size: 28rpx;
  219. color: #999;
  220. }
  221. }
  222. .bottom-btn {
  223. padding: 20rpx;
  224. display: flex;
  225. align-items: center;
  226. .btn {
  227. width: 260rpx;
  228. }
  229. }
  230. </style>