paymentMethod.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!--
  2. * @Description: 支付方式选择 微信or快捷支付or聚合支付
  3. * @Author: 空白格
  4. * @Date: 2022-08-01 11:45:20
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-09-01 09:54:36
  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. jumpUrl: {
  101. type: String,
  102. default: null
  103. },
  104. // 出口扫码 接口不一样
  105. exportFlag: {
  106. type: Boolean,
  107. default: false
  108. }
  109. },
  110. data() {
  111. return {
  112. wxEnv: true
  113. };
  114. },
  115. created() {
  116. this.wxEnv = getEnvIsWx();
  117. },
  118. methods: {
  119. /**
  120. * 贵阳银行支付
  121. * @param {Array} orderList 需要支付的订单号组成的数组
  122. * @param {String} deviceNo 设备编号(只有车位锁部分有)
  123. * */
  124. gyBankPay() {
  125. const params = {
  126. orderList: this.curOrderList,
  127. deviceNo: this.deviceNo,
  128. jumpUrl: this.jumpUrl,
  129. payeeId: this.payeeId,
  130. payeeName: this.payeeName,
  131. pursueType: this.pursueType,
  132. sanPay: this.sanPay
  133. };
  134. if (this.exportFlag == true) {
  135. this.$u.api
  136. .quickPayExportApi(params)
  137. .then((res) => {
  138. if (res.data.needPay) {
  139. let payUrl = res.data.url;
  140. location.href = payUrl;
  141. } else {
  142. this.$refs.uToast.show({
  143. title: '无需支付',
  144. type: 'info'
  145. });
  146. setTimeout(() => {
  147. uni.hideLoading();
  148. location.reload();
  149. }, 1000);
  150. }
  151. })
  152. .catch((err) => {
  153. this.$refs.uToast.show({
  154. title: err.msg,
  155. type: 'error'
  156. });
  157. });
  158. } else {
  159. this.$u.api
  160. .payGzbank(params)
  161. .then((res) => {
  162. if (res.data.needPay) {
  163. let payUrl = res.data.url;
  164. location.href = payUrl;
  165. } else {
  166. this.$refs.uToast.show({
  167. title: '无需支付',
  168. type: 'info'
  169. });
  170. setTimeout(() => {
  171. uni.hideLoading();
  172. location.reload();
  173. }, 1000);
  174. }
  175. })
  176. .catch((err) => {
  177. this.$refs.uToast.show({
  178. title: err.msg,
  179. type: 'error'
  180. });
  181. });
  182. }
  183. },
  184. /**
  185. * 聚合支付
  186. * */
  187. juhePay() {
  188. this.getWXPayByJava(this.curOrderList, this.deviceNo);
  189. },
  190. /**
  191. * 微信支付
  192. */
  193. wechatPay() {
  194. const params = {
  195. orderList: this.curOrderList,
  196. openid: this.vuex_wxinfo.openId,
  197. deviceNo: this.deviceNo || undefined,
  198. payeeId: this.payeeId || undefined,
  199. payeeName: this.payeeName || undefined,
  200. sanPay: this.sanPay
  201. };
  202. if (this.exportFlag) {
  203. this.$u.api.parkingWechatPayApi(params).then((res) => {
  204. if (res.code === 200) {
  205. $wxPay.wexinPay(res.data.wx).then((r) => {
  206. switch (Number(r.code)) {
  207. case 0: // 成功
  208. //#ifdef H5
  209. window.location.reload();
  210. //#endif
  211. break;
  212. case 1: // 取消
  213. this.$refs.uToast.show({
  214. title: '已取消支付',
  215. type: 'info'
  216. });
  217. break;
  218. case 2: // 支付失败
  219. this.$refs.uToast.show({
  220. title: '支付失败,请检查!',
  221. type: 'error'
  222. });
  223. break;
  224. }
  225. });
  226. }
  227. });
  228. } else {
  229. this.$u.api.wechatPayApi(params).then((res) => {
  230. if (res.code === 200) {
  231. $wxPay.wexinPay(res.data.wx).then((r) => {
  232. switch (Number(r.code)) {
  233. case 0: // 成功
  234. //#ifdef H5
  235. window.location.reload();
  236. //#endif
  237. break;
  238. case 1: // 取消
  239. this.$refs.uToast.show({
  240. title: '已取消支付',
  241. type: 'info'
  242. });
  243. break;
  244. case 2: // 支付失败
  245. this.$refs.uToast.show({
  246. title: '支付失败,请检查!',
  247. type: 'error'
  248. });
  249. break;
  250. }
  251. });
  252. }
  253. });
  254. }
  255. },
  256. /**
  257. * 直接通过后台获取贵阳银行微信支付地址
  258. * @param {Array} list 需要支付的订单组合数组
  259. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  260. * */
  261. getWXPayByJava(orderList, deviceNo) {
  262. let params = {
  263. orderList: orderList,
  264. openid: this.vuex_wxinfo.openId,
  265. jumpUrl: this.jumpUrl,
  266. deviceNo: deviceNo ? deviceNo : null,
  267. payeeId: this.payeeId,
  268. payeeName: this.payeeName,
  269. pursueType: this.pursueType,
  270. sanPay: this.sanPay
  271. };
  272. if (this.exportFlag) {
  273. this.$u.api
  274. .polyPayExportApi(params)
  275. .then((res) => {
  276. if (res.code === 200) {
  277. localStorage.setItem('jumpUrl', this.jumpUrl);
  278. location.href = res.data.qrCodeUrl;
  279. } else {
  280. uni.hideLoading();
  281. }
  282. })
  283. .catch((err) => {
  284. this.$refs.uToast.show({
  285. title: '无法调起微信支付!',
  286. type: 'error'
  287. });
  288. });
  289. } else {
  290. this.$u.api
  291. .ordinaryWxPay(params)
  292. .then((res) => {
  293. if (res.code === 200) {
  294. localStorage.setItem('jumpUrl', this.jumpUrl);
  295. location.href = res.data.qrCodeUrl;
  296. } else {
  297. uni.hideLoading();
  298. }
  299. })
  300. .catch((err) => {
  301. this.$refs.uToast.show({
  302. title: '无法调起微信支付!',
  303. type: 'error'
  304. });
  305. });
  306. }
  307. },
  308. /**
  309. * 关闭弹框
  310. * */
  311. closePaymentMethod() {
  312. this.$emit('closePaymentMethod');
  313. }
  314. }
  315. };
  316. </script>
  317. <style lang="scss" scoped>
  318. @import './paymentMethod.scss';
  319. </style>