search.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <view>
  3. <view class="wrap" v-if="!kongResult">
  4. <u-navbar title="车牌查询" :is-back="false">
  5. </u-navbar>
  6. <view class="key-input">
  7. <u-message-input :focus="true" :value="form.carNum" :maxlength="maxlength" :disabled-keyboard="true"></u-message-input>
  8. </view>
  9. <ucarkeyboard ref="uKeyboard" mode="car" :showTips="true" :confirmBtn="false" :mask="true" :mask-close-able="true" :tooltip="false" v-model="keyShow" @change="valChange" @backspace="backspace"></ucarkeyboard>
  10. <!-- <view class="carNone" v-if="kongResult">
  11. <img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
  12. <p>没有找到停车信息</p>
  13. </view> -->
  14. <u-button class="login-btn" type="success" shape="circle" @click="keepCar">查询</u-button>
  15. <view style="padding: 20px;">
  16. <b>停车场收费说明:</b><br>
  17. 缴费后请于规定时间离场,离场会自动抬杆。如果找不到停车信息,或者临牌停车,请至集中缴费处缴纳现金。
  18. </view>
  19. </view>
  20. <view class="wrap" v-if="kongResult">
  21. <view >
  22. <view class="">
  23. <h2 style="
  24. text-align: center;
  25. font-size: 36px;
  26. padding-top: 30px;
  27. "> 停车缴费</h2>
  28. <h2 style="
  29. text-align: center;
  30. font-size: 46px;
  31. color: #53b56b;
  32. "> {{detail.price.toFixed(2)}}<span style="font-size: 16px;">元</span></h2>
  33. <view class="cartitle"> 缴费信息</view>
  34. <view class="info" >
  35. <view class="info-name">
  36. 车牌号
  37. </view>
  38. <view class="info-text">
  39. {{detail.carNumber}}
  40. <a @click="goToBack" class="color4fc5f7 marginl5">修改</a>
  41. </view>
  42. </view>
  43. <view class="info" >
  44. <view class="info-name" style="font-size: 16px;">
  45. 停车费
  46. </view>
  47. <view class="info-text" style="font-size: 16px;">
  48. {{detail.total.toFixed(2)}}元
  49. </view>
  50. </view>
  51. <view class="info" >
  52. <view class="info-name" style="font-size: 16px;">
  53. 折扣
  54. </view>
  55. <view class="info-text" style="font-size: 16px;">
  56. {{detail.discountMoney.toFixed(2)}}元
  57. </view>
  58. </view>
  59. <view class="cartitle"> 停车详情</view>
  60. <view class="info" >
  61. <view class="info-name">
  62. 每小时费用
  63. </view>
  64. <view class="info-text">
  65. {{detail.hourCost.toFixed(2)}}元
  66. </view>
  67. </view>
  68. <view class="info" >
  69. <view class="info-name">
  70. 停车位置
  71. </view>
  72. <view class="info-text">
  73. {{detail.parkingName}}
  74. </view>
  75. </view>
  76. <view class="info" >
  77. <view class="info-name">
  78. 入场时间
  79. </view>
  80. <view class="info-text">
  81. {{detail.inParkingTime}}
  82. </view>
  83. </view>
  84. <view class="info" >
  85. <view class="info-name">
  86. 停车时间
  87. </view>
  88. <view class="info-text">
  89. {{detail.parkingTimeStr}}
  90. </view>
  91. </view>
  92. </view>
  93. <u-button class="login-btn" type="success" shape="circle" @click="pay()">支付离场</u-button>
  94. <u-button class="login-btn2" type="default" shape="circle" @click="keepCar">刷新</u-button>
  95. </view>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. import * as API from '@/apis/parking.js'
  101. import ucarkeyboard from '@/components/Ucarkeyboard.vue'
  102. import {
  103. wxPayJs
  104. } from '@/utils/wxpay'
  105. import {
  106. aliPayJs
  107. } from '@/utils/alipay'
  108. export default {
  109. components: {
  110. ucarkeyboard
  111. },
  112. data() {
  113. return {
  114. maxlength:8,
  115. keyShow: true,
  116. detail:{},
  117. form: {
  118. carNum: '',
  119. parkId: "",
  120. },
  121. kongResult: false,
  122. }
  123. },
  124. onLoad(op) {
  125. if(op.id){
  126. this.form.parkId=op.id
  127. }else{
  128. uni.showModal({
  129. content:"参数错误"
  130. })
  131. }
  132. },
  133. onReady() {
  134. //this.$refs.uKeyboard.changeCarInputMode();
  135. },
  136. methods: {
  137. //微信支付
  138. payWx() {
  139. uni.showLoading({
  140. title: "加载中",
  141. mask: true,
  142. })
  143. API.parkingWxPay({
  144. id: this.detail.id,
  145. openId: this.carhelp.getOpenId()
  146. }).then(data => {
  147. data.data.url = window.location.href.split("#")[0] + "/#/car/payResult";
  148. uni.hideLoading()
  149. wxPayJs(data.data)
  150. }).catch(error => {
  151. uni.hideLoading()
  152. uni.showToast({
  153. title: error,
  154. icon: "none"
  155. })
  156. })
  157. },
  158. //支付宝支付
  159. payAli() {
  160. uni.showLoading({
  161. title: "加载中",
  162. mask: true,
  163. })
  164. API.parkingTradeWebPay({
  165. id: this.detail.id,
  166. openId: this.carhelp.getOpenIdALI()
  167. }).then(response => {
  168. uni.hideLoading()
  169. let opthions = {
  170. tradeNo: response.data.tradeOrder.tradeNo,
  171. succUrl: window.location.href.split("#")[0] + "/#/pages/parking/payResult?id="+ response.data.tradeOrder.tradeNo,
  172. cancelUrl: window.location.href.split("#")[0] + "/#/pages/parking/search?id=" + this.form.parkId,
  173. }
  174. //(opthions);
  175. aliPayJs(opthions);
  176. }).catch(error => {
  177. uni.hideLoading()
  178. uni.showToast({
  179. title: error,
  180. icon: "none"
  181. })
  182. })
  183. },
  184. //支付
  185. pay() {
  186. var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
  187. var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)
  188. if (IS_WEIXIN) {
  189. this.payWx();
  190. } else if (IS_ALI) {
  191. this.payAli();
  192. } else {
  193. this.payWx();
  194. uni.showModal({
  195. content:"请用微信或支付宝打开"
  196. })
  197. }
  198. },
  199. goToBack() {
  200. this.kongResult=false
  201. },
  202. // 按键被点击(点击退格键不会触发此事件)
  203. valChange(val) {
  204. if(this.form.carNum.length>=this.maxlength){
  205. return
  206. }
  207. // 将每次按键的值拼接到form.carNum变量中,注意+=写法
  208. this.form.carNum += val;
  209. //(this.form.carNum);
  210. if(this.form.carNum.length == 1) {
  211. this.$refs.uKeyboard.changeCarInputMode();
  212. }
  213. },
  214. // 退格键被点击
  215. backspace() {
  216. // 删除form.carNum的最后一个字符
  217. if (this.form.carNum.length) this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
  218. //(this.form.carNum);
  219. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  220. if(this.form.carNum.length == 0 && aaa) {
  221. this.$refs.uKeyboard.changeCarInputMode();
  222. }
  223. },
  224. keepCar() {
  225. //(this.form)
  226. if (this.form.carNum.length <7) {
  227. uni.showToast({
  228. title:"车牌号至少输入7位"
  229. })
  230. return false;
  231. }
  232. uni.showLoading({
  233. title: "加载中",
  234. mask: true,
  235. })
  236. API.carPayDetail(this.form).then((res) => {
  237. uni.hideLoading();
  238. this.detail = res.data;
  239. this.kongResult=true;
  240. }).catch(error => {
  241. uni.hideLoading()
  242. uni.showToast({
  243. title: error,
  244. icon: "none"
  245. })
  246. })
  247. }
  248. }
  249. }
  250. </script>
  251. <style>
  252. page {
  253. background-color: #fff;
  254. }
  255. </style>
  256. <style lang="scss" scoped>
  257. .cartitle{
  258. font-size: 16px;
  259. margin-left: 20px;
  260. font-weight: bold;
  261. margin-top: 5px;
  262. }
  263. .color4fc5f7{
  264. color:#53b56b;
  265. margin-left: 5px;
  266. font-weight: bold;
  267. }
  268. .info {
  269. font-size: 14px;
  270. display: flex;
  271. justify-content: space-between;
  272. margin: 0 40px;
  273. // height: 48px;
  274. line-height: 48px;
  275. background-color: rgba(255, 255, 255, 100);
  276. color: rgba(16, 16, 16, 100);
  277. border-bottom: 1px solid #ededed;
  278. .info-text {
  279. /* line-height: 23px;*/
  280. // padding: 13px 0 12px;
  281. //width: 200px;
  282. text-align: right;
  283. }
  284. }
  285. .carNone{
  286. display: flex;
  287. flex-direction: column;
  288. justify-content: center;
  289. align-items: center;
  290. img{
  291. width: 100%;
  292. height: 100%;
  293. }
  294. p{
  295. margin-top: -60px;
  296. }
  297. }
  298. .u-char-item{
  299. width: 29px !important;
  300. }
  301. .u-drawer{
  302. z-index: -1 !important;
  303. }
  304. ::v-deep.u-char-item {
  305. width: 30px !important;
  306. height: 40px !important;
  307. font-size: 18px !important;
  308. }
  309. .key-input {
  310. padding-top: 24px;
  311. }
  312. .default {
  313. margin: 16px 28px;
  314. }
  315. .login-btn {
  316. margin: 28px;
  317. background-color: #00B962 !important;
  318. border-color: #00B962 !important;
  319. color: #fff !important;
  320. }
  321. .login-btn2 {
  322. margin: 28px;
  323. }
  324. </style>