index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view>
  3. <!-- <u-navbar :is-back='false' :border-bottom="false" :background="{ background: '#008CFF' }" title=""></u-navbar> -->
  4. <view class="header-bar">
  5. <view class="city" @click="handleCitySelect">
  6. <view class="city-name">{{city}}</view>
  7. <u-icon name="arrow-down" color="#fff" size="32"></u-icon>
  8. </view>
  9. <u-search placeholder="搜索停车点" :show-action="false" @search="handleSearch" v-model="keyword"></u-search>
  10. <!-- <u-icon class="scan" name="scan" color="#fff" size="48" @click="$refs.uToast.show({title: '建设中'})"></u-icon> -->
  11. </view>
  12. <u-swiper :list="bannerList" border-radius="0"></u-swiper>
  13. <u-city-select v-model="cityOpen" @city-change="cityChange" :areaCode='["52", "5201"]' ></u-city-select>
  14. <view class="notice-bar-wrap u-flex" v-if="noticeList.length>=1" @click="openPage('pages/message/message')">
  15. <u-icon custom-prefix="custom-icon" size="50" name="xiaoxi" color="#008CFF"></u-icon>
  16. <u-notice-bar
  17. class="u-flex-1"
  18. mode="vertical"
  19. :autoplay="true"
  20. :list="noticeList"
  21. :volume-icon="false"
  22. bg-color="#fff"
  23. color="#727272"
  24. :more-icon="true"></u-notice-bar>
  25. </view>
  26. <u-card :show-head="false" :show-foot="false" border-radius="16" margin="20rpx 40rpx" padding="30">
  27. <view class="content-nav" slot="body">
  28. <view class="content-nav-item" @click="openPage('pages/payLists/payLists')">
  29. <view class="content-nav-item-icon-wrap">
  30. <u-image src="../../static/img/index-content-nav-01.png" width="95rpx" height="95rpx" mode="heightFix"></u-image>
  31. </view>
  32. <view class="content-nav-item-icon-text">停车缴费</view>
  33. </view>
  34. <view class="content-nav-item" @click="openPage('pages/favourableActivity/favourableActivity')">
  35. <view class="content-nav-item-icon-wrap">
  36. <u-image src="../../static/img/index-content-nav-02.png" width="95rpx" height="95rpx" mode="heightFix"></u-image>
  37. </view>
  38. <view class="content-nav-item-icon-text">优惠活动</view>
  39. </view>
  40. <view class="content-nav-item" @click="openPage('pages/myCars/myCars')">
  41. <view class="content-nav-item-icon-wrap">
  42. <u-image src="../../static/img/index-content-nav-03.png" width="95rpx" height="95rpx" mode="heightFix"></u-image>
  43. </view>
  44. <view class="content-nav-item-icon-text">车辆管理</view>
  45. </view>
  46. <view class="content-nav-item" @click="openPage('pages/searchparking/searchparking')">
  47. <view class="content-nav-item-icon-wrap">
  48. <u-image src="../../static/img/index-content-nav-04.png" width="95rpx" height="95rpx" mode="heightFix"></u-image>
  49. </view>
  50. <view class="content-nav-item-icon-text">我的停车</view>
  51. </view>
  52. </view>
  53. </u-card>
  54. <view class="empty-data-box" v-if="!orderList||orderList.length<1">
  55. <u-empty text="暂无停车信息" mode="list"></u-empty>
  56. </view>
  57. <template v-for="(item, index) in orderList">
  58. <u-card :show-foot="false" border-radius="16" margin="20rpx 40rpx" padding="30">
  59. <view class="pending-order-head" slot="head">
  60. <view class="pending-order-head-left"><b>P</b>{{item.roadName}}</view>
  61. <view class="pending-order-head-right" @click="onRoadInfo(item)"><u-icon class="arrow-down" name="arrow-down" size="32" color="#aaa"></u-icon></view>
  62. </view>
  63. <view class="pending-order-body" slot="body">
  64. <view class="pending-order-body-nav">
  65. <view class="nav-item nav-manual" @click="orderNavclick()" :class="{active:orderNav==0}">手动缴费</view>
  66. <view class="nav-item nav-auto" @click="orderNavclick()" :class="{active:orderNav==1}">无感支付</view>
  67. </view>
  68. <view class="pending-order-body-wrap" v-show="orderNav==0">
  69. <view class="pending-order-body-left">
  70. <view class="car-number">{{item.vehicleNo}}</view>
  71. <view class="item-cell">
  72. <span class="pending-order-body-left-label">入场时间:</span>
  73. <span>{{item.inTime}}</span>
  74. </view>
  75. <!-- <view class="item-cell">
  76. <span class="pending-order-body-left-label">出场时间:</span>
  77. <span>{{item.outTime||'停放中'}}</span>
  78. </view>
  79. <view class="item-cell">
  80. <span class="pending-order-body-left-label">停留时间:</span>
  81. <span>{{item.duration||'停放中'}}</span>
  82. </view>
  83. <view class="item-cell cost">
  84. <span class="pending-order-body-left-label">停车费用:</span>
  85. <span>
  86. <span class="number" v-if="item.payAmount">¥{{item.payAmount}}</span>
  87. <span class="number" v-else>停放中</span>
  88. </span>
  89. </view> -->
  90. </view>
  91. <view class="pending-order-body-right">
  92. <view class="order">停车泊位:{{item.spaceName}}</view>
  93. </view>
  94. <view class="go-pay-wrap">
  95. <view class="go-pay" @click="goPay(item.id)">出场缴费</view>
  96. </view>
  97. </view>
  98. <view class="pending-order-body-wrap" v-show="orderNav==1">
  99. <view v-if="contractStatus==0" class="nosign">
  100. <view class="nosign1">您的车牌未签约贵州银行无感支付</view>
  101. <view class="nosign2">请下载贵州银行手机银行app进行签约</view>
  102. </view>
  103. <view v-if="contractStatus==1" class="sign">
  104. <view class="sign1">您已签约贵州银行无感支付</view>
  105. <view class="sign2">停车出场时将默认使用无感支付进行支付</view>
  106. </view>
  107. </view>
  108. </view>
  109. </u-card>
  110. </template>
  111. <!-- <view class="promotion" @click="$refs.uToast.show({title: '建设中'})">
  112. <view class="promotion-header u-flex u-row-between">
  113. <view class="promotion-header-til">优惠活动</view>
  114. <view class="promotion-header-con">去领取</view>
  115. </view>
  116. <view class="promotion-body">
  117. <view class="promotion-body-til">八折停车</view>
  118. <view class="promotion-body-con">从客户启用贵州银行行卡支付的第四个月开始,使用我行卡支付永久享受八折优惠(单日不限次数)...</view>
  119. </view>
  120. </view> -->
  121. <view class="promotion-box">
  122. <view class="promotion-title">
  123. <text>优惠活动</text>
  124. </view>
  125. <view class="promotion-banner">
  126. <!-- <swiper
  127. class="promotion-banner-swiper"
  128. :indicator-dots="true"
  129. indicator-color="rgba(170, 216, 255, 1)"
  130. indicator-active-color="#008CFF"
  131. :autoplay="true"
  132. :duration="500"
  133. mode="dot"
  134. :interval="3000"
  135. :circular="true">
  136. <swiper-item v-for="(item, index) in promotionBannerList" :key="'bannner' + index">
  137. <view class="promotion-banner-item">
  138. <image :src="item.image" mode=""></image>
  139. </view>
  140. </swiper-item>
  141. </swiper> -->
  142. <u-swiper
  143. :list="promotionBannerList"
  144. @click="promotionBannerClick"
  145. height="221"></u-swiper>
  146. </view>
  147. </view>
  148. <u-modal
  149. v-model="bindCarShow"
  150. title="绑定车牌号"
  151. :show-cancel-button="true"
  152. confirm-text="去绑定"
  153. content="首次使用请先绑定您的车牌"
  154. @confirm="$u.route({url:'pages/myCars/myCars'})"></u-modal>
  155. <u-popup class="popup-order-details" v-model="showOrderDetails" mode="center" width="90%" border-radius="20">
  156. <view class="popup-order-details-til">停车场信息</view>
  157. <view class="popup-order-details-con">
  158. <dl><dt>路段名称:</dt> <dd>{{popupOrderDetails.roadName}}</dd></dl>
  159. <dl><dt>路段编码:</dt><dd>{{popupOrderDetails.roadNo}}</dd></dl>
  160. <dl><dt>联系人:</dt><dd>{{popupOrderDetails.manager}} </dd></dl>
  161. <dl><dt>联系电话:</dt><dd @click="phoneCall(popupOrderDetails.telephone)">{{popupOrderDetails.telephone}}</dd></dl>
  162. </view>
  163. <view class="popup-order-details-footer" @click="closeOrderDetails">
  164. 知道了
  165. </view>
  166. </u-popup>
  167. <!-- 缴费方式-->
  168. <u-modal
  169. v-model="payWayPop"
  170. :title-style="{color: '#404040'}"
  171. title="缴费方式"
  172. :show-confirm-button="false"
  173. :show-cancel-button="false">
  174. <view class="slot-content">
  175. <view class="pay-way">
  176. <view class="pay-way-item" @click="gyBankPay">
  177. <image src="../../static/img/gy-bank-pay-icon.png" mode=""></image>
  178. <view>贵州银行</view>
  179. </view>
  180. <view class="pay-way-item" @click="wechatPay">
  181. <image src="../../static/img/wechat-pay-icon.png" mode=""></image>
  182. <view>微信支付</view>
  183. </view>
  184. </view>
  185. <button class="pay-way-close-btn" @click="payWayPop = false">关闭</button>
  186. </view>
  187. </u-modal>
  188. <u-toast ref="uToast" />
  189. </view>
  190. </template>
  191. <script>
  192. import getUrlParams from "../../utils/getUrlParams.js";
  193. export default {
  194. // components: {
  195. // citySelect
  196. // },
  197. data() {
  198. return {
  199. city: '贵阳市',
  200. keyword:'',
  201. bannerList:[
  202. {image: '/static/img/index-banner01.png',title: ''}
  203. ],
  204. orderList:[],
  205. cityOpen:false,
  206. pendingOrder:[],
  207. code:null,//微信code
  208. orderNav:'',//手动,无感
  209. bindCarShow:false,//绑定车询问弹窗
  210. showOrderDetails:false,//是否线上订单细节
  211. popupOrderDetails:[],
  212. noticeList:[],
  213. // 优惠活动广告图
  214. promotionBannerList: [
  215. {
  216. id: 1,
  217. image: '/static/img/promotion-banner-1.png',
  218. title: '1分钱停车'
  219. },
  220. {
  221. id: 2,
  222. image: '/static/img/promotion-banner-2.png',
  223. title: '八折停车'
  224. }
  225. ],
  226. contractStatus:'',
  227. vehicleId:'',
  228. recordList:[],
  229. // 支付方式
  230. payWayPop: false,
  231. // 订单号
  232. curOrderList: []
  233. }
  234. },
  235. onShow() {
  236. this.handleGetIndexData();
  237. // this.getLocation();
  238. let locationLocaturl = window.location.search;
  239. this.code = getUrlParams(locationLocaturl,"code");
  240. if(this.code&&!this.$store.state.vuex_wxinfo.openId){this.handleGetWXInfo(this.code)};
  241. },
  242. methods: {
  243. // getLocation(){
  244. // console.log("请求定位")
  245. // uni.getLocation({
  246. // type:"gcj02",
  247. // success : function (res) {
  248. // console.log("定位返回信息:", res)
  249. // alert(res.longitude + "," + res.latitude )
  250. // },
  251. // fail: function(res){
  252. // console.log("请求错误:", res)
  253. // }
  254. // })
  255. // },
  256. orderNavclick(){
  257. this.feePay()
  258. },
  259. feePay(){
  260. this.$u.api.feePay({vehicleId: this.recordList[1]})
  261. .then( res=>{
  262. if(res.code == 200){
  263. this.handleGetIndexData()
  264. }
  265. })
  266. },
  267. openPage(path) {
  268. console.log('path',path);
  269. this.$u.route({
  270. url: path
  271. })
  272. },
  273. handleSearch(){
  274. console.log('this.keyword',this.keyword);
  275. this.$u.route({
  276. url:'pages/parkingLists/parkingLists',
  277. type:'tab',
  278. params: {
  279. keyword: this.keyword
  280. }
  281. })
  282. },
  283. handleCitySelect(){
  284. this.cityOpen = true;
  285. },
  286. cityChange(e){
  287. console.log('cityChange',e);
  288. this.city = e.city.label;
  289. },
  290. handleGetIndexData(){
  291. this.$u.api.getIndexData()
  292. .then(res=>{
  293. if(res.data.vehicleList.length<1){
  294. this.bindCarShow = true;
  295. }
  296. const enableFeepay=[]
  297. res.data.orderList.forEach(item => {
  298. enableFeepay.push(item.enableFeepay);
  299. enableFeepay.push(item.vehicleId);
  300. enableFeepay.push(item.contractStatus);
  301. })
  302. this.recordList=enableFeepay;
  303. // this.vehicleId=enableFeepay.vehicleId;
  304. this.orderNav = enableFeepay[0];
  305. this.contractStatus=enableFeepay[2];
  306. console.log('recordList',this.recordList)
  307. this.orderList = res.data.orderList;
  308. const list = []
  309. res.data.news.forEach(item => {
  310. list.push(item.content)
  311. })
  312. this.noticeList = list;
  313. }).catch(err=>{
  314. // alert(err.msg);
  315. console.log('getIndexData err',err)
  316. });
  317. },
  318. goPay(orderId){
  319. this.payWayPop = true
  320. this.curOrderList = []
  321. this.curOrderList.push(orderId)
  322. // let orderList=[];
  323. // orderList.push(orderId);
  324. // this.$u.api.payGzbank({orderList: orderList}).then(res=>{
  325. // let payUrl = res.data.url;
  326. // this.currentPayUrl=encodeURIComponent(res.data.url);
  327. // // return;
  328. // this.$u.route({
  329. // url: 'pages/payLists/pay',
  330. // params: {
  331. // currentPayUrl:this.currentPayUrl
  332. // }
  333. // });
  334. // }).catch(err=>{
  335. // this.$refs.uToast.show({
  336. // title: err.msg,
  337. // type: 'error',
  338. // });
  339. // });
  340. // // this.$u.route({
  341. // // url: 'pages/payPage/payPage',
  342. // // params: {
  343. // // orderId: orderId
  344. // // }
  345. // // });
  346. },
  347. //
  348. onRoadInfo(item){
  349. this.$u.api.roadInfoById({id:item.roadId})
  350. .then(res=>{
  351. this.popupOrderDetails=res.data;
  352. this.showOrderDetails = true;
  353. }).catch(err=>{
  354. // alert(err.msg);
  355. console.log('getIndexData err',err)
  356. });
  357. },
  358. closeOrderDetails(){
  359. this.showOrderDetails = false;
  360. },
  361. phoneCall(phone){
  362. uni.makePhoneCall({
  363. phoneNumber: phone
  364. });
  365. },
  366. /**
  367. * 点击优惠活动的广告图
  368. * */
  369. promotionBannerClick(cur) {
  370. this.promotionBannerList.forEach((item, index) => {
  371. if (cur === index) {
  372. this.$u.route({
  373. url:'pages/favourableActivity/favourableActivity',
  374. params: {
  375. title: item.title,
  376. id: item.id
  377. }
  378. })
  379. }
  380. })
  381. },
  382. gyBankPay() {
  383. this.$u.api.payGzbank({orderList: this.curOrderList}).then(res=>{
  384. let payUrl = res.data.url;
  385. this.currentPayUrl=encodeURIComponent(res.data.url);
  386. this.$u.route({
  387. url: 'pages/payLists/pay',
  388. params: {
  389. currentPayUrl: this.currentPayUrl
  390. }
  391. });
  392. }).catch(err=>{
  393. this.$refs.uToast.show({
  394. title: err.msg,
  395. type: 'error',
  396. });
  397. });
  398. },
  399. // 微信支付
  400. wechatPay() {
  401. const openId = this.$store.state.vuex_wxinfo.openId
  402. if (openId) {
  403. this.getWXPay(this.curOrderList)
  404. } else {
  405. this.getCode()
  406. }
  407. },
  408. async getWXPay(list){
  409. let params = {
  410. orderList: list,
  411. openid: this.$store.state.vuex_wxinfo.openId
  412. };
  413. await this.$wxApi.config();
  414. this.$pay.wechatPay(params).then(res =>{
  415. if(res.code == 0){
  416. // 成功
  417. this.$u.route({
  418. url:'/',
  419. });
  420. }else if(res.code == 1){
  421. // 取消
  422. // uni.redirectTo({
  423. // url: '/pages/userCenter/myOrder/myOrder'
  424. // })
  425. }else if(res.code == 2){
  426. this.$refs.uToast.show({
  427. title: '支付失败,请检查!',
  428. type: 'error',
  429. // url: '/pages/user/index'
  430. });
  431. }
  432. });
  433. },
  434. getCode () {
  435. var local = window.location.href // 获取页面url
  436. let locationLocaturl = window.location.search;
  437. this.code = getUrlParams(locationLocaturl,"code"); // 截取code
  438. if (this.code == null || this.code === '') { // 如果没有code,则去请求
  439. window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
  440. } else {
  441. this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
  442. }
  443. },
  444. handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
  445. let _this = this
  446. this.$u.api.getWXInfo(code).then((res) => {
  447. if (res.code === 200 ) {
  448. this.$u.vuex('vuex_wxinfo', res.data);
  449. // 继续支付
  450. this.getWXPay(this.currentItem)
  451. }
  452. }).catch((err) => {
  453. this.$refs.uToast.show({
  454. title: err.msg,
  455. type: 'error',
  456. });
  457. })
  458. },
  459. }
  460. }
  461. </script>
  462. <style lang="scss" scoped>
  463. @import "./index.scss";
  464. </style>