search.vue 7.3 KB

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