paymentMethod.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <!--
  2. * @Description: 支付方式选择 微信or快捷支付or聚合支付
  3. * @Author: 空白格
  4. * @Date: 2022-08-01 11:45:20
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-10-09 13:54:07
  7. * @FilePath: \parking_h5\pages\paymentMethod\paymentMethod.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. $wxPay.wexinPay(res.data.wx).then((r) => {
  213. switch (Number(r.code)) {
  214. case 0: // 成功
  215. //#ifdef H5
  216. window.location.reload();
  217. //#endif
  218. break;
  219. case 1: // 取消
  220. this.$refs.uToast.show({
  221. title: '已取消支付',
  222. type: 'info'
  223. });
  224. break;
  225. case 2: // 支付失败
  226. this.$refs.uToast.show({
  227. title: '支付失败,请检查!',
  228. type: 'error'
  229. });
  230. break;
  231. }
  232. });
  233. }
  234. });
  235. } else {
  236. this.$u.api.wechatPayApi(params).then((res) => {
  237. if (res.code === 200) {
  238. $wxPay.wexinPay(res.data.wx).then((r) => {
  239. switch (Number(r.code)) {
  240. case 0: // 成功
  241. //#ifdef H5
  242. window.location.reload();
  243. //#endif
  244. break;
  245. case 1: // 取消
  246. this.$refs.uToast.show({
  247. title: '已取消支付',
  248. type: 'info'
  249. });
  250. break;
  251. case 2: // 支付失败
  252. this.$refs.uToast.show({
  253. title: '支付失败,请检查!',
  254. type: 'error'
  255. });
  256. break;
  257. }
  258. });
  259. }
  260. });
  261. }
  262. },
  263. /**
  264. * 直接通过后台获取贵阳银行微信支付地址
  265. * @param {Array} list 需要支付的订单组合数组
  266. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  267. * */
  268. getWXPayByJava(orderList, deviceNo) {
  269. let params = {
  270. orderList: orderList,
  271. openid: this.vuex_wxinfo.openId,
  272. jumpUrl: this.jumpUrl,
  273. deviceNo: deviceNo ? deviceNo : null,
  274. payeeId: this.payeeId,
  275. payeeName: this.payeeName,
  276. pursueType: this.pursueType,
  277. vehicleNo: this.vehicleNo,
  278. sanPay: this.sanPay
  279. };
  280. if (this.exportFlag) {
  281. this.$u.api
  282. .polyPayExportApi(params)
  283. .then((res) => {
  284. if (res.code === 200) {
  285. localStorage.setItem('jumpUrl', this.jumpUrl);
  286. location.href = res.data.qrCodeUrl;
  287. } else {
  288. uni.hideLoading();
  289. }
  290. })
  291. .catch((err) => {
  292. this.$refs.uToast.show({
  293. title: '无法调起微信支付!',
  294. type: 'error'
  295. });
  296. });
  297. } else {
  298. this.$u.api
  299. .ordinaryWxPay(params)
  300. .then((res) => {
  301. if (res.code === 200) {
  302. localStorage.setItem('jumpUrl', this.jumpUrl);
  303. location.href = res.data.qrCodeUrl;
  304. } else {
  305. uni.hideLoading();
  306. }
  307. })
  308. .catch((err) => {
  309. this.$refs.uToast.show({
  310. title: '无法调起微信支付!',
  311. type: 'error'
  312. });
  313. });
  314. }
  315. },
  316. /**
  317. * 关闭弹框
  318. * */
  319. closePaymentMethod() {
  320. this.$emit('closePaymentMethod');
  321. }
  322. }
  323. };
  324. </script>
  325. <style lang="scss" scoped>
  326. @import './paymentMethod.scss';
  327. </style>