paymentMethod.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <!--
  2. * @Description: 支付方式选择 微信or快捷支付or聚合支付
  3. * @Author: 空白格
  4. * @Date: 2022-08-01 11:45:20
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2023-01-03 10:21:16
  7. * @FilePath: \parking_h5\pages\choosePayment\choosePayment.vue
  8. * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
  9. -->
  10. <template>
  11. <view>
  12. <u-modal
  13. v-model="payWayPop"
  14. :title-style="{ color: '#404040' }"
  15. title="缴费方式"
  16. width="660rpx"
  17. :show-confirm-button="false"
  18. :show-cancel-button="false"
  19. >
  20. <view class="slot-content">
  21. <view class="pay-way-new">
  22. <!-- <view class="pay-way-item pay-way-item-hy" @click="gyBankPay">
  23. <image src="../../static/img/guiyang-bank-icon.png" mode=""></image>
  24. <view class="title">贵州银行</view>
  25. <view class="subtitle">前三个月每天首次一分钱<br/>长期八折优惠</view>
  26. </view>
  27. <view class="pay-way-item pay-way-item-jh" @click="wechatPay">
  28. <image src="../../static/img/juhe-icon.png" mode=""></image>
  29. <view class="title">微信/支付宝</view>
  30. </view> -->
  31. <view class="pay-way-item pay-way-item-hy" @click="$u.debounce(gyBankPay, 1000, (immediate = true))">
  32. <image src="/static/img/gyyh-icon.svg" mode=""></image>
  33. <view class="title">贵州银行</view>
  34. </view>
  35. <!-- #ifdef H5 || MP-WEIXIN -->
  36. <view class="pay-way-item pay-way-item-wx" @click="$u.debounce(wechatPay, 1000, (immediate = true))" v-if="wxEnv">
  37. <image src="/static/img/weixin-icon.svg" mode=""></image>
  38. <view class="title">微信支付</view>
  39. </view>
  40. <!-- #endif -->
  41. <view class="pay-way-item pay-way-item-jh" @click="$u.debounce(juhePay, 1000, (immediate = true))">
  42. <image src="/static/img/juhe-icon.svg" mode=""></image>
  43. <view class="title">聚合支付</view>
  44. </view>
  45. </view>
  46. <view class="pay-way-subtitle">
  47. <view class="pay-way-subtitle-item">前三个月每天首次一分钱,长期八折优惠</view>
  48. <!-- #ifdef H5 || MP-WEIXIN -->
  49. <view class="pay-way-subtitle-item" v-if="wxEnv">&nbsp;</view>
  50. <!-- #endif -->
  51. <view class="pay-way-subtitle-item">&nbsp;</view>
  52. </view>
  53. <button class="pay-way-close-btn" @click="closePaymentMethod">关闭</button>
  54. </view>
  55. </u-modal>
  56. <u-toast ref="uToast" />
  57. </view>
  58. </template>
  59. <script>
  60. import { getEnvIsWx } from '@/utils/judgEnvironment.js';
  61. import $wxPay from '@/utils/wxPay.js';
  62. export default {
  63. props: {
  64. // 弹框显示
  65. payWayPop: {
  66. type: Boolean,
  67. default: false
  68. },
  69. // 订单数组
  70. curOrderList: {
  71. type: Array,
  72. default: null
  73. },
  74. // 设备编号
  75. deviceNo: {
  76. type: String,
  77. default: null
  78. },
  79. // 地磁支付需要字段
  80. payeeId: {
  81. type: String,
  82. default: undefined
  83. },
  84. // 地磁支付需要字段
  85. payeeName: {
  86. type: String,
  87. default: undefined
  88. },
  89. // 扫码支付需要字段
  90. sanPay: {
  91. type: Boolean,
  92. default: false
  93. },
  94. // 追缴类型
  95. pursueType: {
  96. type: String,
  97. default: undefined
  98. },
  99. // 车牌号
  100. vehicleNo: {
  101. type: String,
  102. default: undefined
  103. },
  104. // 跳转页面
  105. jumpUrl: {
  106. type: String,
  107. default: null
  108. },
  109. // 出口扫码 接口不一样
  110. exportFlag: {
  111. type: Boolean,
  112. default: false
  113. }
  114. },
  115. data() {
  116. return {
  117. wxEnv: true
  118. };
  119. },
  120. created() {
  121. this.wxEnv = getEnvIsWx();
  122. },
  123. methods: {
  124. /**
  125. * 贵阳银行支付
  126. * @param {Array} orderList 需要支付的订单号组成的数组
  127. * @param {String} deviceNo 设备编号(只有车位锁部分有)
  128. * */
  129. gyBankPay() {
  130. const params = {
  131. orderList: this.curOrderList,
  132. deviceNo: this.deviceNo,
  133. jumpUrl: this.jumpUrl,
  134. payeeId: this.payeeId,
  135. payeeName: this.payeeName,
  136. pursueType: this.pursueType,
  137. vehicleNo: this.vehicleNo,
  138. sanPay: this.sanPay
  139. };
  140. if (this.exportFlag == true) {
  141. this.$u.api
  142. .quickPayExportApi(params)
  143. .then((res) => {
  144. if (res.data.needPay) {
  145. let payUrl = res.data.url;
  146. location.href = payUrl;
  147. } else {
  148. this.$refs.uToast.show({
  149. title: '无需支付',
  150. type: 'info'
  151. });
  152. setTimeout(() => {
  153. uni.hideLoading();
  154. location.reload();
  155. }, 1000);
  156. }
  157. })
  158. .catch((err) => {
  159. this.$refs.uToast.show({
  160. title: err.msg,
  161. type: 'error'
  162. });
  163. });
  164. } else {
  165. this.$u.api
  166. .payGzbank(params)
  167. .then((res) => {
  168. if (res.data.needPay) {
  169. let payUrl = res.data.url;
  170. location.href = payUrl;
  171. } else {
  172. this.$refs.uToast.show({
  173. title: '无需支付',
  174. type: 'info'
  175. });
  176. setTimeout(() => {
  177. uni.hideLoading();
  178. location.reload();
  179. }, 1000);
  180. }
  181. })
  182. .catch((err) => {
  183. this.$refs.uToast.show({
  184. title: err.msg,
  185. type: 'error'
  186. });
  187. });
  188. }
  189. },
  190. /**
  191. * 聚合支付
  192. * */
  193. juhePay() {
  194. this.getWXPayByJava(this.curOrderList, this.deviceNo);
  195. },
  196. /**
  197. * 微信支付
  198. */
  199. wechatPay() {
  200. const params = {
  201. orderList: this.curOrderList,
  202. openid: this.vuex_wxinfo.openId,
  203. deviceNo: this.deviceNo || undefined,
  204. payeeId: this.payeeId || undefined,
  205. payeeName: this.payeeName || undefined,
  206. vehicleNo: this.vehicleNo,
  207. sanPay: this.sanPay
  208. };
  209. if (this.exportFlag) {
  210. this.$u.api.parkingWechatPayApi(params).then((res) => {
  211. if (res.code === 200) {
  212. if (res.data.needPay) {
  213. $wxPay.wexinPay(res.data.wx).then((r) => {
  214. switch (Number(r.code)) {
  215. case 0: // 成功
  216. //#ifdef H5
  217. window.location.reload();
  218. //#endif
  219. break;
  220. case 1: // 取消
  221. this.$refs.uToast.show({
  222. title: '已取消支付',
  223. type: 'info'
  224. });
  225. window.location.reload();
  226. break;
  227. case 2: // 支付失败
  228. this.$refs.uToast.show({
  229. title: '支付失败,请检查!',
  230. type: 'error'
  231. });
  232. break;
  233. }
  234. });
  235. } else {
  236. this.$refs.uToast.show({
  237. title: '无需支付',
  238. type: 'info'
  239. });
  240. setTimeout(() => {
  241. uni.hideLoading();
  242. location.reload();
  243. }, 1000);
  244. }
  245. }
  246. });
  247. } else {
  248. this.$u.api.wechatPayApi(params).then((res) => {
  249. if (res.code === 200) {
  250. if (res.data.needPay) {
  251. $wxPay.wexinPay(res.data.wx).then((r) => {
  252. switch (Number(r.code)) {
  253. case 0: // 成功
  254. //#ifdef H5
  255. window.location.reload();
  256. //#endif
  257. break;
  258. case 1: // 取消
  259. this.$refs.uToast.show({
  260. title: '已取消支付',
  261. type: 'info'
  262. });
  263. window.location.reload();
  264. break;
  265. case 2: // 支付失败
  266. this.$refs.uToast.show({
  267. title: '支付失败,请检查!',
  268. type: 'error'
  269. });
  270. break;
  271. }
  272. });
  273. } else {
  274. this.$refs.uToast.show({
  275. title: '无需支付',
  276. type: 'info'
  277. });
  278. setTimeout(() => {
  279. uni.hideLoading();
  280. location.reload();
  281. }, 1000);
  282. }
  283. }
  284. });
  285. }
  286. },
  287. /**
  288. * 直接通过后台获取贵阳银行微信支付地址
  289. * @param {Array} list 需要支付的订单组合数组
  290. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  291. * */
  292. getWXPayByJava(orderList, deviceNo) {
  293. let params = {
  294. orderList: orderList,
  295. openid: this.vuex_wxinfo.openId,
  296. jumpUrl: this.jumpUrl,
  297. deviceNo: deviceNo ? deviceNo : null,
  298. payeeId: this.payeeId,
  299. payeeName: this.payeeName,
  300. pursueType: this.pursueType,
  301. vehicleNo: this.vehicleNo,
  302. sanPay: this.sanPay
  303. };
  304. if (this.exportFlag) {
  305. this.$u.api
  306. .polyPayExportApi(params)
  307. .then((res) => {
  308. if (res.code === 200) {
  309. if (res.data.needPay) {
  310. localStorage.setItem('jumpUrl', this.jumpUrl);
  311. location.href = res.data.qrCodeUrl;
  312. } else {
  313. this.$refs.uToast.show({
  314. title: '无需支付',
  315. type: 'info'
  316. });
  317. setTimeout(() => {
  318. uni.hideLoading();
  319. location.href = this.jumpUrl;
  320. }, 1000);
  321. }
  322. } else {
  323. uni.hideLoading();
  324. }
  325. })
  326. .catch((err) => {
  327. this.$refs.uToast.show({
  328. title: '无法调起微信支付!',
  329. type: 'error'
  330. });
  331. });
  332. } else {
  333. this.$u.api
  334. .ordinaryWxPay(params)
  335. .then((res) => {
  336. if (res.code === 200) {
  337. if (res.data.needPay) {
  338. localStorage.setItem('jumpUrl', this.jumpUrl);
  339. location.href = res.data.qrCodeUrl;
  340. } else {
  341. this.$refs.uToast.show({
  342. title: '无需支付',
  343. type: 'info'
  344. });
  345. setTimeout(() => {
  346. uni.hideLoading();
  347. location.href = this.jumpUrl;
  348. }, 1000);
  349. }
  350. } else {
  351. uni.hideLoading();
  352. }
  353. })
  354. .catch((err) => {
  355. this.$refs.uToast.show({
  356. title: '无法调起微信支付!',
  357. type: 'error'
  358. });
  359. });
  360. }
  361. },
  362. /**
  363. * 关闭弹框
  364. * */
  365. closePaymentMethod() {
  366. this.$emit('closePaymentMethod');
  367. }
  368. }
  369. };
  370. </script>
  371. <style lang="scss" scoped>
  372. @import './paymentMethod.scss';
  373. </style>