您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

orderPayment.vue 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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="handleClose">
  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="getPayCode">
  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, requestNew, } 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. getPayStatus(data.order.orderNo)
  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. function getPayStatus(orderIdOld = '') {
  81. let orderId = orderIdOld || qdOrderVal.value.orderNo;
  82. let options = {
  83. type: 2,
  84. data: {
  85. orderId,
  86. agentId: qdOrderVal.value.agencyId,
  87. channelId: qdOrderVal.value.channelId,
  88. },
  89. method: 'POST',
  90. showLoading: true
  91. }
  92. requestNew('/iaw/issue/order/payQuery', options).then((res) => {
  93. console.log(res, '请求支付状态获取的数据');
  94. if (res.code === 0) {
  95. let data = res.data;
  96. let dataList = [];
  97. console.log(data, '支付的数据');
  98. if (data.paymentStatus === 'ALLSUCCESS') {
  99. if (isLock.value) {
  100. return;
  101. }
  102. isLock.value = true;
  103. let { jumpPage } = config.value;
  104. uni.navigateTo({
  105. url: '/' + jumpPage,
  106. animationType: 'pop-in',
  107. animationDuration: 500
  108. });
  109. } else {
  110. data.datas.forEach((item) => {
  111. if (item.payStatus === 'UNPAY') {
  112. dataList.push({
  113. ...item,
  114. payStatusName: payMentStatus[item.payStatus],
  115. payTypeName: payType[item.payType]
  116. });
  117. }
  118. });
  119. }
  120. orderList.value = dataList;
  121. }
  122. })
  123. }
  124. // 订单已支付
  125. function detectAliPay(orderIdOld = '') {
  126. let orderId = orderIdOld || qdOrderVal.value.orderNo;
  127. if (!orderId) {
  128. return;
  129. }
  130. request('7d240e2034f94da399fb0e3775f87a62', {
  131. data: {
  132. orderId
  133. }
  134. }).then((res) => {
  135. if (res.statusCode === 0) {
  136. let data = JSON.parse(res.bizContent);
  137. let dataList = [];
  138. console.log(data, '支付的数据');
  139. if (data.paymentStatus === 'ALLSUCCESS') {
  140. if (isLock.value) {
  141. return;
  142. }
  143. isLock.value = true;
  144. let { jumpPage } = config.value;
  145. return
  146. uni.navigateTo({
  147. url: '/' + jumpPage,
  148. animationType: 'pop-in',
  149. animationDuration: 500
  150. });
  151. } else {
  152. data.datas.forEach((item) => {
  153. if (item.payStatus === 'UNPAY') {
  154. dataList.push({
  155. ...item,
  156. payStatusName: payMentStatus[item.payStatus],
  157. payTypeName: payType[item.payType]
  158. });
  159. }
  160. });
  161. }
  162. orderList.value = dataList;
  163. }
  164. });
  165. }
  166. const show = ref(false);
  167. const currentData = ref<any>({});
  168. const qrCodeValue = ref<String>('');
  169. const level = ref<Level>('M');
  170. const renderAs = ref<RenderAs>('svg');
  171. //提交
  172. function handlePayment(orderData) {
  173. console.log(orderData);
  174. if (orderData.payStatus !== 'UNPAY') {
  175. return;
  176. }
  177. currentData.value = {
  178. ...orderData
  179. };
  180. getPayCode();
  181. }
  182. // 根据公网ip获取支付地址
  183. function handleClose() {
  184. console.log('close');
  185. getPayStatus();
  186. }
  187. function getPayCode() {
  188. let params = {
  189. orderId: currentData.value.orderId,
  190. payType: currentData.value.payType,
  191. // spbillCreateIp: "",
  192. // h5Type: ""
  193. };
  194. requestNew('/iaw/issue/order/payApply', {
  195. data: params,
  196. hideShowModal: true
  197. }).then((res) => {
  198. if (res.code === 0) {
  199. show.value = true;
  200. let data = res.data;
  201. qrCodeValue.value = data.codeUrl;
  202. } else {
  203. uni.showModal({
  204. title: '提示',
  205. content: res.data.errorMsg,
  206. success: function (res) {
  207. getPayStatus();
  208. }
  209. });
  210. }
  211. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  212. });
  213. }
  214. // 获取二维码
  215. function getQrCodeText() {
  216. let params = {
  217. orderId: currentData.value.orderId,
  218. payType: currentData.value.payType,
  219. spbillCreateIp: "",
  220. h5Type: ""
  221. };
  222. request('377421d6ed4f48a29575aa126838a4d2', {
  223. data: params,
  224. hideShowModal: true
  225. }).then((res) => {
  226. if (res.statusCode === 0) {
  227. show.value = true;
  228. let data = JSON.parse(res.bizContent);
  229. qrCodeValue.value = data.codeUrl;
  230. } else {
  231. uni.showModal({
  232. title: '提示',
  233. content: res.data.errorMsg,
  234. success: function (res) {
  235. getPayStatus();
  236. }
  237. });
  238. }
  239. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  240. });
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. view.isWing {
  245. background-color: #27be5e;
  246. }
  247. .order-car {
  248. margin: 30rpx 30rpx 0;
  249. width: calc(100% - 60rpx);
  250. height: 170rpx;
  251. border-radius: 20rpx;
  252. background-color: #57aef9;
  253. display: flex;
  254. justify-content: space-between;
  255. box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
  256. align-items: center;
  257. padding: 0 40rpx;
  258. .l-info {
  259. color: #fff;
  260. .goods-name {
  261. margin-bottom: 16rpx;
  262. font-size: 32rpx;
  263. font-weight: bold;
  264. }
  265. .goods-des {
  266. font-size: 26rpx;
  267. }
  268. }
  269. .r-amount {
  270. font-size: 38rpx;
  271. color: #fff;
  272. padding-left: 20rpx;
  273. font-weight: bold;
  274. }
  275. }
  276. .title {
  277. font-size: 36rpx;
  278. text-align: center;
  279. padding: 20rpx 0;
  280. }
  281. .slot-content {
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: center;
  286. .order-amount {
  287. font-size: 28rpx;
  288. color: #999;
  289. margin-bottom: 20rpx;
  290. }
  291. .desc {
  292. margin-top: 20rpx;
  293. font-size: 28rpx;
  294. color: #999;
  295. }
  296. }
  297. .bottom-btn {
  298. padding-top: 40rpx;
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. .btn {
  303. width: 260rpx;
  304. }
  305. }
  306. </style>