pay.vue 6.2 KB

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