Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="content">
  3. <custom-header title="订单支付" :back="config.hasReturn === 'true'"></custom-header>
  4. <view style="padding: 20rpx 0 30rpx" class="order-content">
  5. <!-- 获取产品展示 -->
  6. <view class="order-car" v-for='(item,index) in orderList' @click="handlePayment(item)" :key='index'
  7. :class="{isWing:item.payStatus !== 'UNPAY'}">
  8. <view class="l-info">
  9. <view class="goods-name">
  10. {{ item.payTypeName }}
  11. </view>
  12. <view class="goods-des">
  13. {{ item.payStatusName }}
  14. </view>
  15. </view>
  16. <view class="r-amount">
  17. ¥: {{ handleAmount(item.fee) }}
  18. </view>
  19. </view>
  20. </view>
  21. <u-popup v-model="show" mode='bottom' border-radius="14" :closeable='true' length='60%' @close='detectAliPay'>
  22. <view class="title">
  23. 微信扫码支付
  24. </view>
  25. <view class="slot-content">
  26. <view class='order-amount'><text>{{currentData.payTypeName}}:</text><text class='amount'>¥
  27. {{handleAmount(currentData.fee)}}</text></view>
  28. <view style="width: 300rpx; height: 300rpx;">
  29. <qrcode-vue :value="qrCodeValue" :level="level" :render-as="renderAs" style='width: 100%;height: 100%;' />
  30. </view>
  31. <view class="desc">
  32. 请您及时付款,二维码将会5分钟后在后超时!
  33. </view>
  34. </view>
  35. <view class="bottom-btn">
  36. <u-button class='btn' type='primary' @click="getQrCodeText">刷新二维码</u-button>
  37. <u-button class='btn' type='success' @click="handleWing">已支付</u-button>
  38. </view>
  39. </u-popup>
  40. </view>
  41. </template>
  42. <script setup lang='ts'>
  43. import handleAmount from '@/utils/handleAmount.js';
  44. import {
  45. unifyTemplate
  46. } from '@/hooks/unifyTemplate'
  47. import {
  48. reactive,
  49. ref,
  50. nextTick
  51. } from 'vue'
  52. import {
  53. onLoad
  54. } from '@dcloudio/uni-app'
  55. import {
  56. request,
  57. myJsonp,
  58. toWeixin
  59. } from '@/utils/network/request'
  60. import {
  61. setToken,
  62. getToken
  63. } from '@/utils/storage'
  64. import {payType,payMentStatus,orderSource} from './common.js'
  65. import QrcodeVue, {
  66. Level,
  67. RenderAs
  68. } from 'qrcode.vue'
  69. const {
  70. CustomHeader, //头部组件
  71. initData, //初始化数据
  72. isShow, //是否展示formBuilderVue组件
  73. qdOrderVal //qdOrder中数据 ref
  74. } = unifyTemplate() //初始化数据
  75. // import {
  76. // request
  77. // } from '../../static/js/network/request'
  78. const orderList = ref < any > ([])
  79. // 实付款
  80. const amount = ref < any > ('')
  81. let config = ref < any > ({
  82. jumpPage:''
  83. })
  84. onLoad((opin) => {
  85. initData(opin, 4).then(data => {
  86. console.log(data);
  87. detectAliPay()
  88. delete data.config.tableConfig
  89. if(data.config.jumpPage){
  90. config.value.jumpPage = data.config.jumpPage
  91. }
  92. })
  93. })
  94. // 订单已支付
  95. function detectAliPay() {
  96. request('7d240e2034f94da399fb0e3775f87a62', {
  97. data: {
  98. orderId: qdOrderVal.value.qtOrderNo
  99. }
  100. }).then((res) => {
  101. if (res.statusCode === 0) {
  102. let data = JSON.parse(res.bizContent)
  103. let dataList = []
  104. if (data.paymentStatus === 'ALLSUCCESS') {
  105. let {
  106. jumpPage
  107. } = config.value
  108. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  109. uni.navigateTo({
  110. url: '/' + jumpPage,
  111. animationType: 'pop-in',
  112. animationDuration: 500
  113. })
  114. } else {
  115. data.datas.forEach(item => {
  116. if (item.payStatus === 'UNPAY') {
  117. dataList.push({
  118. ...item,
  119. payStatusName: payMentStatus[item.payStatus],
  120. payTypeName: payType[item.payType],
  121. })
  122. }
  123. })
  124. }
  125. orderList.value = dataList
  126. }
  127. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  128. })
  129. }
  130. const show = ref(false)
  131. const currentData = ref < any > ({})
  132. const qrCodeValue = ref < String > ('')
  133. const level = ref < Level > ('M')
  134. const renderAs = ref < RenderAs > ('svg')
  135. //提交
  136. function handlePayment(orderData) {
  137. console.log(orderData);
  138. if (orderData.payStatus !== 'UNPAY') {
  139. return
  140. }
  141. currentData.value = {
  142. ...orderData
  143. }
  144. getQrCodeText()
  145. }
  146. // 根据公网ip获取支付地址
  147. // 获取二维码
  148. function getQrCodeText() {
  149. let params = {
  150. orderId: currentData.value.orderId,
  151. payType: currentData.value.payType,
  152. // spbillCreateIp: "",
  153. // h5Type: ""
  154. }
  155. request('377421d6ed4f48a29575aa126838a4d2', {
  156. data: params
  157. }).then((res) => {
  158. if (res.statusCode === 0) {
  159. show.value = true
  160. let data = JSON.parse(res.bizContent)
  161. qrCodeValue.value = data.codeUrl
  162. }
  163. // contractTesting(qdOrderVal.value.qdOrderNo, jumpPage)
  164. })
  165. }
  166. // 已支付
  167. async function handleWing(params) {
  168. show.value = false
  169. detectAliPay()
  170. }
  171. // 签约检测
  172. function contractTesting(qdOrderNo, jumpPage) {
  173. const data = {
  174. qdOrderNo,
  175. }
  176. request('fdfbdddba6ec49f8b451cf2e299b4feb', {
  177. data,
  178. }).then((res) => {
  179. if (res.statusCode === 0) {
  180. const data = JSON.parse(res.bizContent)
  181. if (data.signStatus === 1 && data.accountStatus === 1 && data.bindStatus === 1) {
  182. // 上面三值都为1才进行下一步,否则进行签约初始化
  183. if (!jumpPage) return
  184. uni.navigateTo({
  185. url: '/' + jumpPage,
  186. animationType: 'pop-in',
  187. animationDuration: 500
  188. })
  189. /* 自定义返回 */
  190. } else {
  191. // 进行签约初始化
  192. signingInitialization(qdOrderNo)
  193. }
  194. // qdOrderStore.orderInfo.value.orderId = JSON.parse(res.bizContent).orderId
  195. // 通过检测
  196. }
  197. })
  198. }
  199. // 签约初始化
  200. function signingInitialization(qdOrderNo) {
  201. const data = {
  202. qdOrderNo
  203. }
  204. request('94569071cf814517908cd35693f1f2e1', {
  205. data,
  206. }).then((res) => {
  207. if (res.statusCode === 0) {
  208. const data = JSON.parse(res.bizContent)
  209. if (data.returnType === 0) {
  210. // 0-无需跳转,关闭H5即可 1-需跳转至返回url
  211. // const opened = window.open('about:blank', '_self');
  212. // opened.opener = null;
  213. // opened.close();
  214. closeWin()
  215. } else {
  216. window.open(data.signUrl, '_self')
  217. }
  218. }
  219. })
  220. }
  221. // 关闭当前页面方法
  222. function closeWin() {
  223. // @ts-ignore
  224. var jWeixin = import('jweixin-module')
  225. // @ts-ignore
  226. jWeixin.miniProgram.getEnv(function(res) {
  227. if (res.miniprogram) {
  228. // @ts-ignore
  229. jWeixin.miniProgram.navigateTo({
  230. url: '/path/to/page'
  231. })
  232. } else {
  233. const opened = window.open('about:blank', '_self');
  234. opened.opener = null;
  235. opened.close()
  236. }
  237. })
  238. }
  239. </script>
  240. <style lang='scss' scoped>
  241. view.isWing {
  242. background-color: #27be5e;
  243. }
  244. .order-car {
  245. margin: 30rpx 30rpx 0;
  246. width: calc(100% - 60rpx);
  247. height: 170rpx;
  248. border-radius: 20rpx;
  249. background-color: #57aef9;
  250. display: flex;
  251. justify-content: space-between;
  252. box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
  253. align-items: center;
  254. padding: 0 40rpx;
  255. .l-info {
  256. color: #fff;
  257. .goods-name {
  258. margin-bottom: 16rpx;
  259. font-size: 32rpx;
  260. font-weight: bold;
  261. }
  262. .goods-des {
  263. font-size: 26rpx;
  264. }
  265. }
  266. .r-amount {
  267. font-size: 38rpx;
  268. color: #fff;
  269. padding-left: 20rpx;
  270. font-weight: bold;
  271. }
  272. }
  273. .title {
  274. font-size: 36rpx;
  275. text-align: center;
  276. padding: 20rpx 0;
  277. }
  278. .slot-content {
  279. display: flex;
  280. flex-direction: column;
  281. justify-content: center;
  282. align-items: center;
  283. .order-amount {
  284. font-size: 28rpx;
  285. color: #999;
  286. margin-bottom: 20rpx;
  287. }
  288. .desc {
  289. margin-top: 20rpx;
  290. font-size: 28rpx;
  291. color: #999;
  292. }
  293. }
  294. .bottom-btn {
  295. padding: 20rpx;
  296. display: flex;
  297. align-items: center;
  298. .btn {
  299. width: 260rpx;
  300. }
  301. }
  302. </style>