choosePayment.vue 10 KB

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