pay.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view>
  3. <view class="carNone" v-if="kongResult">
  4. <u-navbar title="停车缴费" :is-back="false">
  5. </u-navbar>
  6. <img src="static/img/暂无数据-缺省页.png" alt="">
  7. <p>未查询到停车数据</p>
  8. <u-button class="login-btn2" type="default" shape="circle" @click="channelPayDetail">刷新</u-button>
  9. </view>
  10. <view class="wrap" v-if="!kongResult" >
  11. <u-navbar title="停车缴费" :is-back="false">
  12. </u-navbar>
  13. <view >
  14. <view class="">
  15. <view class="cartitle"> 缴费信息</view>
  16. <view class="info" >
  17. <view class="info-name">
  18. 车牌号
  19. </view>
  20. <view class="info-text">
  21. {{detail.carNumber}}
  22. </view>
  23. </view>
  24. <view class="info" >
  25. <view class="info-name" style="font-size: 16px;">
  26. 停车费
  27. </view>
  28. <view class="info-text" style="font-size: 16px;">
  29. {{detail.price}}元
  30. </view>
  31. </view>
  32. <view class="cartitle"> 停车详情</view>
  33. <view class="info" >
  34. <view class="info-name">
  35. 停车位置
  36. </view>
  37. <view class="info-text">
  38. {{detail.parkingName}}
  39. </view>
  40. </view>
  41. <view class="info" >
  42. <view class="info-name">
  43. 入场时间
  44. </view>
  45. <view class="info-text">
  46. {{detail.inParkingTime}}
  47. </view>
  48. </view>
  49. <view class="info" >
  50. <view class="info-name">
  51. 停车时间
  52. </view>
  53. <view class="info-text">
  54. {{detail.parkingTimeStr}}
  55. </view>
  56. </view>
  57. </view>
  58. <u-button class="login-btn" type="success" shape="circle" @click="pay()">支付离场</u-button>
  59. <u-button class="login-btn2" type="default" shape="circle" @click="channelPayDetail">刷新</u-button>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import * as API from '@/apis/parking.js'
  66. import {
  67. wxPayJs
  68. } from '@/utils/wxpay'
  69. import {
  70. aliPayJs
  71. } from '@/utils/alipay'
  72. export default {
  73. components: {
  74. },
  75. data() {
  76. return {
  77. form: {
  78. channelId: "",
  79. },
  80. detail:{},
  81. kongResult: false,
  82. }
  83. },
  84. onLoad(op) {
  85. if(op.id){
  86. this.form.channelId=op.id
  87. }else{
  88. uni.showModal({
  89. content:"参数错误"
  90. })
  91. }
  92. },
  93. onReady() {
  94. this.channelPayDetail()
  95. },
  96. methods: {
  97. channelPayDetail(){
  98. uni.showLoading({
  99. title: "加载中",
  100. mask: true,
  101. })
  102. API.channelPayDetail(this.form).then(data => {
  103. uni.hideLoading()
  104. this.detail=data.data
  105. this.kongResult=false;
  106. }).catch(error => {
  107. this.kongResult=true;
  108. uni.hideLoading()
  109. uni.showToast({
  110. title: error,
  111. icon: "none"
  112. })
  113. })
  114. },
  115. //微信支付
  116. payWx() {
  117. uni.showLoading({
  118. title: "加载中",
  119. mask: true,
  120. })
  121. API.parkingWxPay({
  122. id: this.detail.id,
  123. openId: this.carhelp.getOpenId()
  124. }).then(data => {
  125. data.data.url = window.location.href.split("#")[0] + "/#/car/payResult";
  126. uni.hideLoading()
  127. wxPayJs(data.data)
  128. }).catch(error => {
  129. uni.hideLoading()
  130. uni.showToast({
  131. title: error,
  132. icon: "none"
  133. })
  134. })
  135. },
  136. //支付宝支付
  137. payAli() {
  138. uni.showLoading({
  139. title: "加载中",
  140. mask: true,
  141. })
  142. API.parkingTradeWebPay({
  143. id: this.detail.id,
  144. openId: this.carhelp.getOpenIdALI()
  145. }).then(response => {
  146. uni.hideLoading()
  147. let opthions = {
  148. tradeNo: response.data.tradeOrder.tradeNo,
  149. succUrl: window.location.href.split("#")[0] + "/#/pages/parking/payResult?id="+ response.data.tradeOrder.tradeNo,
  150. cancelUrl: window.location.href.split("#")[0] + "/#/pages/parking/pay?id=" + this.form.channelId,
  151. }
  152. console.log(opthions);
  153. aliPayJs(opthions);
  154. }).catch(error => {
  155. uni.hideLoading()
  156. uni.showToast({
  157. title: error,
  158. icon: "none"
  159. })
  160. })
  161. },
  162. //支付
  163. pay() {
  164. var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
  165. var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)
  166. if (IS_WEIXIN) {
  167. this.payWx();
  168. } else if (IS_ALI) {
  169. this.payAli();
  170. } else {
  171. this.payWx();
  172. uni.showModal({
  173. content:"请用微信或支付宝打开"
  174. })
  175. }
  176. },
  177. }
  178. }
  179. </script>
  180. <style>
  181. page {
  182. background-color: #fff;
  183. }
  184. </style>
  185. <style lang="scss" scoped>
  186. .cartitle{
  187. font-size: 16px;
  188. margin-left: 20px;
  189. font-weight: bold;
  190. margin-top: 5px;
  191. }
  192. .color4fc5f7{
  193. color:#4fc5f7;
  194. margin-left: 5px;
  195. }
  196. .info {
  197. font-size: 14px;
  198. display: flex;
  199. justify-content: space-between;
  200. margin: 0 40px;
  201. // height: 48px;
  202. line-height: 48px;
  203. background-color: rgba(255, 255, 255, 100);
  204. color: rgba(16, 16, 16, 100);
  205. border-bottom: 1px solid #ededed;
  206. .info-text {
  207. /* line-height: 23px;*/
  208. // padding: 13px 0 12px;
  209. //width: 200px;
  210. text-align: right;
  211. }
  212. }
  213. .carNone{
  214. display: flex;
  215. flex-direction: column;
  216. justify-content: center;
  217. align-items: center;
  218. img{
  219. width: 100%;
  220. height: 100%;
  221. }
  222. p{
  223. margin-top: -60px;
  224. }
  225. }
  226. .u-char-item{
  227. width: 29px !important;
  228. }
  229. .u-drawer{
  230. z-index: -1 !important;
  231. }
  232. /deep/.u-char-item {
  233. width: 30px !important;
  234. height: 40px !important;
  235. font-size: 18px !important;
  236. }
  237. .key-input {
  238. padding-top: 24px;
  239. }
  240. .default {
  241. margin: 16px 28px;
  242. }
  243. .login-btn {
  244. margin: 28px;
  245. background-color: #00B962 !important;
  246. border-color: #00B962 !important;
  247. color: #fff !important;
  248. }
  249. .login-btn2 {
  250. margin: 28px;
  251. }
  252. </style>