paymentMethod.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <!--
  3. 支付方式选择 微信or贵阳银行
  4. -->
  5. <view>
  6. <u-modal v-model="payWayPop" :title-style="{color: '#404040'}" title="缴费方式" :show-confirm-button="false"
  7. :show-cancel-button="false">
  8. <view class="slot-content">
  9. <view class="pay-way-new">
  10. <view class="pay-way-item pay-way-item-hy" @click="gyBankPay">
  11. <image src="../../static/img/guiyang-bank-icon.png" mode=""></image>
  12. <view class="title">贵州银行</view>
  13. <view class="subtitle">前三个月每天首次一分钱<br />长期八折优惠</view>
  14. </view>
  15. <view class="pay-way-item pay-way-item-jh" @click="wechatPay">
  16. <image src="../../static/img/juhe-icon.png" mode=""></image>
  17. <view class="title">微信/支付宝</view>
  18. </view>
  19. </view>
  20. <button class="pay-way-close-btn" @click="closePaymentMethod">关闭</button>
  21. </view>
  22. </u-modal>
  23. <u-toast ref="uToast" />
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. // 弹框显示
  30. payWayPop: {
  31. type: Boolean,
  32. default: false
  33. },
  34. // 订单数组
  35. curOrderList: {
  36. type: Array,
  37. default: null
  38. },
  39. // 设备编号
  40. deviceNo: {
  41. type: String,
  42. default: null
  43. },
  44. // 地磁支付需要字段
  45. payeeId: {
  46. type: String,
  47. default: undefined
  48. },
  49. // 地磁支付需要字段
  50. payeeName: {
  51. type: String,
  52. default: undefined
  53. },
  54. //扫码支付需要字段
  55. sanPay: {
  56. type: Boolean,
  57. default: false
  58. },
  59. // 追缴类型
  60. pursueType: {
  61. type: String,
  62. default: undefined
  63. },
  64. // 跳转页面
  65. jumpUrl: {
  66. type: String,
  67. default: null
  68. },
  69. // 出口扫码 接口不一样
  70. exportFlag: {
  71. type: Boolean,
  72. default: false
  73. }
  74. },
  75. data() {
  76. return {}
  77. },
  78. methods: {
  79. /**
  80. * 贵阳银行支付
  81. * @param {Array} orderList 需要支付的订单号组成的数组
  82. * @param {String} deviceNo 设备编号(只有车位锁部分有)
  83. * */
  84. gyBankPay() {
  85. uni.showLoading({
  86. title: '加载中'
  87. });
  88. const params = {
  89. orderList: this.curOrderList,
  90. deviceNo: this.deviceNo,
  91. jumpUrl: this.jumpUrl,
  92. payeeId: this.payeeId,
  93. payeeName: this.payeeName,
  94. pursueType: this.pursueType,
  95. sanPay: this.sanPay
  96. };
  97. console.log(params)
  98. if (this.exportFlag == true) {
  99. this.$u.api.quickPayExportApi(params).then(res => {
  100. if (res.data.needPay) {
  101. let payUrl = res.data.url;
  102. location.href = payUrl;
  103. } else {
  104. this.$refs.uToast.show({
  105. title: '无需支付',
  106. type: 'info',
  107. });
  108. setTimeout(() => {
  109. uni.hideLoading();
  110. location.reload()
  111. }, 1000)
  112. }
  113. }).catch(err => {
  114. this.$refs.uToast.show({
  115. title: err.msg,
  116. type: 'error',
  117. });
  118. });
  119. } else {
  120. this.$u.api.payGzbank(params).then(res => {
  121. if (res.data.needPay) {
  122. let payUrl = res.data.url;
  123. location.href = payUrl;
  124. } else {
  125. this.$refs.uToast.show({
  126. title: '无需支付',
  127. type: 'info',
  128. });
  129. setTimeout(() => {
  130. uni.hideLoading();
  131. location.reload()
  132. }, 1000)
  133. }
  134. }).catch(err => {
  135. this.$refs.uToast.show({
  136. title: err.msg,
  137. type: 'error',
  138. });
  139. });
  140. }
  141. },
  142. /**
  143. * 微信支付
  144. * 判断vuex中是否存在openId
  145. * 存在直接调起微信支付
  146. * 不存在则通过微信登录去获取用户的code
  147. * 完成后通过code去获取用户的openId等信息
  148. * 最后再调起微信支付
  149. * */
  150. wechatPay() {
  151. uni.showLoading({
  152. title: '加载中'
  153. });
  154. this.getWXPayByJava(this.curOrderList, this.deviceNo)
  155. },
  156. /**
  157. * 直接通过后台获取贵阳银行微信支付地址
  158. * @param {Array} list 需要支付的订单组合数组
  159. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  160. * */
  161. getWXPayByJava(orderList, deviceNo) {
  162. let params = {
  163. orderList: orderList,
  164. openid: '',
  165. jumpUrl: this.jumpUrl,
  166. deviceNo: deviceNo ? deviceNo : null,
  167. payeeId: this.payeeId,
  168. payeeName: this.payeeName,
  169. pursueType: this.pursueType,
  170. sanPay: this.sanPay
  171. };
  172. if (this.exportFlag) {
  173. this.$u.api.polyPayExportApi(params)
  174. .then(res => {
  175. if (res.code === 200) {
  176. localStorage.setItem('jumpUrl', this.jumpUrl)
  177. location.href = res.data.qrCodeUrl
  178. } else {
  179. uni.hideLoading();
  180. }
  181. })
  182. .catch(err => {
  183. this.$refs.uToast.show({
  184. title: '无法调起微信支付!',
  185. type: 'error',
  186. });
  187. })
  188. } else {
  189. this.$u.api.ordinaryWxPay(params)
  190. .then(res => {
  191. if (res.code === 200) {
  192. localStorage.setItem('jumpUrl', this.jumpUrl)
  193. location.href = res.data.qrCodeUrl
  194. } else {
  195. uni.hideLoading();
  196. }
  197. })
  198. .catch(err => {
  199. this.$refs.uToast.show({
  200. title: '无法调起微信支付!',
  201. type: 'error',
  202. });
  203. })
  204. }
  205. },
  206. /**
  207. * 关闭弹框
  208. * */
  209. closePaymentMethod() {
  210. this.$emit('closePaymentMethod')
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. @import './paymentMethod.scss'
  217. </style>