search.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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: '鄂DD12345',
  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. debugger
  124. data.data.url = window.location.href.split("#")[0] + "/#/car/payResult";
  125. uni.hideLoading()
  126. wxPayJs(data.data)
  127. }).catch(error => {
  128. uni.hideLoading()
  129. uni.showToast({
  130. title: error,
  131. icon: "none"
  132. })
  133. })
  134. },
  135. //支付宝支付
  136. payAli() {
  137. uni.showLoading({
  138. title: "加载中",
  139. mask: true,
  140. })
  141. API.parkingTradeWebPay({
  142. id: this.detail.id,
  143. openId: this.carhelp.getOpenIdALI()
  144. }).then(response => {
  145. uni.hideLoading()
  146. let opthions = {
  147. tradeNo: response.data.tradeOrder.tradeNo,
  148. succUrl: window.location.href.split("#")[0] + "/#/pages/parking/payResult?id="+ response.data.tradeOrder.tradeNo,
  149. cancelUrl: window.location.href.split("#")[0] + "/#/pages/parking/search?id=" + this.form.parkId,
  150. }
  151. console.log(opthions);
  152. aliPayJs(opthions);
  153. }).catch(error => {
  154. uni.hideLoading()
  155. uni.showToast({
  156. title: error,
  157. icon: "none"
  158. })
  159. })
  160. },
  161. //支付
  162. pay() {
  163. var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
  164. var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)
  165. if (IS_WEIXIN) {
  166. this.payWx();
  167. } else if (IS_ALI) {
  168. this.payAli();
  169. } else {
  170. this.payWx();
  171. uni.showModal({
  172. content:"请用微信或支付宝打开"
  173. })
  174. }
  175. },
  176. goToBack() {
  177. this.kongResult=false
  178. },
  179. // 按键被点击(点击退格键不会触发此事件)
  180. valChange(val) {
  181. if(this.form.carNum.length>=this.maxlength){
  182. return
  183. }
  184. // 将每次按键的值拼接到form.carNum变量中,注意+=写法
  185. this.form.carNum += val;
  186. console.log(this.form.carNum);
  187. if(this.form.carNum.length == 1) {
  188. this.$refs.uKeyboard.changeCarInputMode();
  189. }
  190. },
  191. // 退格键被点击
  192. backspace() {
  193. // 删除form.carNum的最后一个字符
  194. if (this.form.carNum.length) this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
  195. console.log(this.form.carNum);
  196. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  197. if(this.form.carNum.length == 0 && aaa) {
  198. this.$refs.uKeyboard.changeCarInputMode();
  199. }
  200. },
  201. keepCar() {
  202. console.log(this.form)
  203. if (this.form.carNum.length <7) {
  204. uni.showToast({
  205. title:"车牌号至少输入7位"
  206. })
  207. return false;
  208. }
  209. uni.showLoading({
  210. title: "加载中",
  211. mask: true,
  212. })
  213. API.carPayDetail(this.form).then((res) => {
  214. uni.hideLoading();
  215. this.detail = res.data;
  216. this.kongResult=true;
  217. }).catch(error => {
  218. uni.hideLoading()
  219. uni.showToast({
  220. title: error,
  221. icon: "none"
  222. })
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style>
  229. page {
  230. background-color: #fff;
  231. }
  232. </style>
  233. <style lang="scss" scoped>
  234. .cartitle{
  235. font-size: 16px;
  236. margin-left: 20px;
  237. font-weight: bold;
  238. margin-top: 5px;
  239. }
  240. .color4fc5f7{
  241. color:#4fc5f7;
  242. margin-left: 5px;
  243. }
  244. .info {
  245. font-size: 14px;
  246. display: flex;
  247. justify-content: space-between;
  248. margin: 0 40px;
  249. // height: 48px;
  250. line-height: 48px;
  251. background-color: rgba(255, 255, 255, 100);
  252. color: rgba(16, 16, 16, 100);
  253. border-bottom: 1px solid #ededed;
  254. .info-text {
  255. /* line-height: 23px;*/
  256. // padding: 13px 0 12px;
  257. //width: 200px;
  258. text-align: right;
  259. }
  260. }
  261. .carNone{
  262. display: flex;
  263. flex-direction: column;
  264. justify-content: center;
  265. align-items: center;
  266. img{
  267. width: 100%;
  268. height: 100%;
  269. }
  270. p{
  271. margin-top: -60px;
  272. }
  273. }
  274. .u-char-item{
  275. width: 29px !important;
  276. }
  277. .u-drawer{
  278. z-index: -1 !important;
  279. }
  280. /deep/.u-char-item {
  281. width: 30px !important;
  282. height: 40px !important;
  283. font-size: 18px !important;
  284. }
  285. .key-input {
  286. padding-top: 24px;
  287. }
  288. .default {
  289. margin: 16px 28px;
  290. }
  291. .login-btn {
  292. margin: 28px;
  293. background-color: #00B962 !important;
  294. border-color: #00B962 !important;
  295. color: #fff !important;
  296. }
  297. .login-btn2 {
  298. margin: 28px;
  299. }
  300. </style>