pay.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view>
  3. <view class="carNone" v-if="kongResult">
  4. <u-navbar title="停车缴费" :is-back="false">
  5. </u-navbar>
  6. <img src="@/assets/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.toFixed(2)}}<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.toFixed(2)}}元
  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.toFixed(2)}}元
  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.toFixed(2)}}元
  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 class="info" v-if="detail.disTimesStr!=null && detail.disTimesStr">
  82. <view class="info-name">
  83. 优惠时长
  84. </view>
  85. <view class="info-text">
  86. {{detail.disTimesStr}}
  87. </view>
  88. </view>
  89. </view>
  90. <u-button class="login-btn" type="success" shape="circle" @click="pay()">支付离场</u-button>
  91. <u-button class="login-btn2" type="default" shape="circle" @click="channelPayDetail">刷新</u-button>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import * as API from '@/apis/parking.js'
  98. import {
  99. wxPayJs
  100. } from '@/utils/wxpay'
  101. import {
  102. aliPayJs
  103. } from '@/utils/alipay'
  104. export default {
  105. components: {
  106. },
  107. data() {
  108. return {
  109. form: {
  110. channelId: "",
  111. },
  112. detail: {
  113. price: 0,
  114. total: 0,
  115. discountMoney: 0,
  116. hourCost: 0
  117. },
  118. kongResult: true,
  119. }
  120. },
  121. onLoad(op) {
  122. if (op.id) {
  123. this.form.channelId = op.id
  124. } else {
  125. uni.showModal({
  126. content: "参数错误"
  127. })
  128. }
  129. },
  130. onReady() {
  131. this.channelPayDetail()
  132. },
  133. methods: {
  134. channelPayDetail() {
  135. uni.showLoading({
  136. title: "加载中",
  137. mask: true,
  138. })
  139. API.channelPayDetail(this.form).then(data => {
  140. uni.hideLoading()
  141. this.detail = data.data
  142. this.kongResult = false;
  143. }).catch(error => {
  144. this.kongResult = true;
  145. uni.hideLoading()
  146. uni.showToast({
  147. title: error,
  148. icon: "none"
  149. })
  150. })
  151. },
  152. //微信支付
  153. payWx() {
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. })
  158. API.parkingWxPay({
  159. id: this.detail.id,
  160. openId: this.carhelp.getOpenId()
  161. }).then(data => {
  162. data.data.url = window.location.href.split("#")[0] + "/#/car/payResult";
  163. uni.hideLoading()
  164. wxPayJs(data.data)
  165. }).catch(error => {
  166. uni.hideLoading()
  167. uni.showToast({
  168. title: error,
  169. icon: "none"
  170. })
  171. })
  172. },
  173. //支付宝支付
  174. payAli() {
  175. uni.showLoading({
  176. title: "加载中",
  177. mask: true,
  178. })
  179. API.parkingTradeWebPay({
  180. id: this.detail.id,
  181. openId: this.carhelp.getOpenIdALI()
  182. }).then(response => {
  183. uni.hideLoading()
  184. let opthions = {
  185. tradeNo: response.data.tradeOrder.tradeNo,
  186. succUrl: window.location.href.split("#")[0] + "/#/pages/parking/payResult?id=" + response.data
  187. .tradeOrder.tradeNo,
  188. cancelUrl: window.location.href.split("#")[0] + "/#/pages/parking/pay?id=" + this.form.channelId,
  189. }
  190. //(opthions);
  191. aliPayJs(opthions);
  192. }).catch(error => {
  193. uni.hideLoading()
  194. uni.showToast({
  195. title: error,
  196. icon: "none"
  197. })
  198. })
  199. },
  200. //支付
  201. pay() {
  202. var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
  203. var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)
  204. if (IS_WEIXIN) {
  205. this.payWx();
  206. } else if (IS_ALI) {
  207. this.payAli();
  208. } else {
  209. this.payWx();
  210. uni.showModal({
  211. content: "请用微信或支付宝打开"
  212. })
  213. }
  214. },
  215. }
  216. }
  217. </script>
  218. <style>
  219. page {
  220. background-color: #fff;
  221. }
  222. </style>
  223. <style lang="scss" scoped>
  224. .cartitle {
  225. font-size: 16px;
  226. margin-left: 20px;
  227. font-weight: bold;
  228. margin-top: 5px;
  229. }
  230. .color4fc5f7 {
  231. color: #4fc5f7;
  232. margin-left: 5px;
  233. }
  234. .info {
  235. font-size: 14px;
  236. display: flex;
  237. justify-content: space-between;
  238. margin: 0 40px;
  239. // height: 48px;
  240. line-height: 48px;
  241. background-color: rgba(255, 255, 255, 100);
  242. color: rgba(16, 16, 16, 100);
  243. border-bottom: 1px solid #ededed;
  244. .info-text {
  245. /* line-height: 23px;*/
  246. // padding: 13px 0 12px;
  247. //width: 200px;
  248. text-align: right;
  249. }
  250. }
  251. .carNone {
  252. display: flex;
  253. flex-direction: column;
  254. justify-content: center;
  255. align-items: center;
  256. img {
  257. width: 100%;
  258. height: 100%;
  259. }
  260. p {
  261. margin-top: -60px;
  262. }
  263. }
  264. .u-char-item {
  265. width: 29px !important;
  266. }
  267. .u-drawer {
  268. z-index: -1 !important;
  269. }
  270. ::v-deep .u-char-item {
  271. width: 30px !important;
  272. height: 40px !important;
  273. font-size: 18px !important;
  274. }
  275. .key-input {
  276. padding-top: 24px;
  277. }
  278. .default {
  279. margin: 16px 28px;
  280. }
  281. .login-btn {
  282. margin: 28px;
  283. background-color: #00B962 !important;
  284. border-color: #00B962 !important;
  285. color: #fff !important;
  286. }
  287. .login-btn2 {
  288. margin: 28px;
  289. }
  290. </style>