index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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" mode="none"></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.payAmount}}</span>
  82. </view>
  83. <!-- <view class="item-cell">
  84. <span class="pending-order-body-left-label">出场时间:</span>
  85. <span>{{item.outTime||'停放中'}}</span>
  86. </view>
  87. <view class="item-cell">
  88. <span class="pending-order-body-left-label">停留时间:</span>
  89. <span>{{item.duration||'停放中'}}</span>
  90. </view>
  91. <view class="item-cell cost">
  92. <span class="pending-order-body-left-label">停车费用:</span>
  93. <span>
  94. <span class="number" v-if="item.payAmount">¥{{item.payAmount}}</span>
  95. <span class="number" v-else>停放中</span>
  96. </span>
  97. </view> -->
  98. </view>
  99. <view class="pending-order-body-right">
  100. <view class="order">停车泊位:{{item.spaceName}}</view>
  101. </view>
  102. <view class="go-pay-wrap">
  103. <view class="go-pay" @click="goPay(item.id)">出场缴费</view>
  104. </view>
  105. </view>
  106. <view class="pending-order-body-wrap" v-show="orderNav==1">
  107. <view v-if="contractStatus==0" class="nosign">
  108. <view class="nosign1">您的车牌未签约贵州银行无感支付</view>
  109. <view class="nosign2">请下载贵州银行手机银行app进行签约</view>
  110. </view>
  111. <view v-if="contractStatus==1" class="sign">
  112. <view class="sign1">您已签约贵州银行无感支付</view>
  113. <view class="sign2">停车出场时将默认使用无感支付进行支付</view>
  114. </view>
  115. </view>
  116. </view>
  117. </u-card>
  118. </template>
  119. <!-- <view class="promotion" @click="$refs.uToast.show({title: '建设中'})">
  120. <view class="promotion-header u-flex u-row-between">
  121. <view class="promotion-header-til">优惠活动</view>
  122. <view class="promotion-header-con">去领取</view>
  123. </view>
  124. <view class="promotion-body">
  125. <view class="promotion-body-til">八折停车</view>
  126. <view class="promotion-body-con">从客户启用贵州银行行卡支付的第四个月开始,使用我行卡支付永久享受八折优惠(单日不限次数)...</view>
  127. </view>
  128. </view> -->
  129. <view class="promotion-box">
  130. <view class="promotion-title">
  131. <text>优惠活动</text>
  132. </view>
  133. <view class="promotion-banner">
  134. <!-- <swiper
  135. class="promotion-banner-swiper"
  136. :indicator-dots="true"
  137. indicator-color="rgba(170, 216, 255, 1)"
  138. indicator-active-color="#008CFF"
  139. :autoplay="true"
  140. :duration="500"
  141. mode="dot"
  142. :interval="3000"
  143. :circular="true">
  144. <swiper-item v-for="(item, index) in promotionBannerList" :key="'bannner' + index">
  145. <view class="promotion-banner-item">
  146. <image :src="item.image" mode=""></image>
  147. </view>
  148. </swiper-item>
  149. </swiper> -->
  150. <u-swiper
  151. :list="promotionBannerList"
  152. @click="promotionBannerClick"
  153. height="221"></u-swiper>
  154. </view>
  155. </view>
  156. <u-modal
  157. v-model="bindCarShow"
  158. title="绑定车牌号"
  159. :show-cancel-button="true"
  160. confirm-text="去绑定"
  161. content="首次使用请先绑定您的车牌"
  162. @confirm="$u.route({url:'pages/myCars/myCars'})"></u-modal>
  163. <u-popup class="popup-order-details" v-model="showOrderDetails" mode="center" width="90%" border-radius="20">
  164. <view class="popup-order-details-til">停车场信息</view>
  165. <view class="popup-order-details-con">
  166. <dl><dt>路段名称:</dt> <dd>{{popupOrderDetails.roadName}}</dd></dl>
  167. <dl><dt>路段编码:</dt><dd>{{popupOrderDetails.roadNo}}</dd></dl>
  168. <dl><dt>联系人:</dt><dd>{{popupOrderDetails.manager}} </dd></dl>
  169. <dl><dt>联系电话:</dt><dd @click="phoneCall(popupOrderDetails.telephone)">{{popupOrderDetails.telephone}}</dd></dl>
  170. </view>
  171. <view class="popup-order-details-footer" @click="closeOrderDetails">
  172. 知道了
  173. </view>
  174. </u-popup>
  175. <!-- 缴费方式-->
  176. <u-modal
  177. v-model="payWayPop"
  178. :title-style="{color: '#404040'}"
  179. title="缴费方式"
  180. :show-confirm-button="false"
  181. :show-cancel-button="false">
  182. <view class="slot-content">
  183. <view class="pay-way">
  184. <view class="pay-way-item" @click="gyBankPay">
  185. <image src="../../static/img/gy-bank-pay-icon.png" mode=""></image>
  186. <view>贵州银行</view>
  187. </view>
  188. <view class="pay-way-item" @click="wechatPay">
  189. <image src="../../static/img/wechat-pay-icon.png" mode=""></image>
  190. <view>微信支付</view>
  191. </view>
  192. </view>
  193. <button class="pay-way-close-btn" @click="payWayPop = false">关闭</button>
  194. </view>
  195. </u-modal>
  196. <u-toast ref="uToast" />
  197. </view>
  198. </template>
  199. <script>
  200. import getUrlParams from "../../utils/getUrlParams.js";
  201. export default {
  202. // components: {
  203. // citySelect
  204. // },
  205. data() {
  206. return {
  207. city: '普定县',
  208. keyword:'',
  209. bannerList:[
  210. {image: '/static/img/index-banner01.png',title: ''}
  211. ],
  212. orderList:[],
  213. cityOpen:false,
  214. pendingOrder:[],
  215. code:null,//微信code
  216. orderNav:'',//手动,无感
  217. bindCarShow:false,//绑定车询问弹窗
  218. showOrderDetails:false,//是否线上订单细节
  219. popupOrderDetails:[],
  220. noticeList:[],
  221. // 优惠活动广告图
  222. promotionBannerList: [
  223. {
  224. id: 1,
  225. image: '/static/img/promotion-banner-1.png',
  226. title: '1分钱停车'
  227. },
  228. {
  229. id: 2,
  230. image: '/static/img/promotion-banner-2.png',
  231. title: '八折停车'
  232. }
  233. ],
  234. contractStatus:'',
  235. vehicleId:'',
  236. recordList:[],
  237. // 支付方式
  238. payWayPop: false,
  239. // 订单号
  240. curOrderList: [],
  241. latLongItude:{}
  242. }
  243. },
  244. onShow() {
  245. this.handleGetIndexData();
  246. // this.getLocation();
  247. // this.getCityNameByLonLat({latitude: 26.301447, longitude: 105.743197})
  248. let locationLocaturl = window.location.search;
  249. this.code = getUrlParams(locationLocaturl,"code");
  250. if(this.code&&!this.$store.state.vuex_wxinfo.openId){this.handleGetWXInfo(this.code)};
  251. },
  252. methods: {
  253. getLocation(){
  254. const that = this
  255. uni.getLocation({
  256. type: 'wgs84',
  257. geocode: true,
  258. success: (res) => {
  259. that.latLongItude = {latitude: res.latitude,longitude:res.longitude};
  260. that.latitude = res.latitude;
  261. that.longitude = res.longitude;
  262. // that.getCityNameByLonLat(that.latLongItude)
  263. },
  264. fail: () => {
  265. console.log("获取经纬度失败");
  266. }
  267. })
  268. },
  269. // 通过经纬度获取地区详细信息
  270. getCityNameByLonLat({longitude,latitude} = {}){
  271. let that = this;
  272. uni.showLoading({
  273. title: '加载中',
  274. mask:true
  275. });
  276. let str = `output=jsonp&key=BOGBZ-2BZ33-O4L32-Y3QJR-PGN66-RFFEL&location=${latitude},${longitude}`
  277. this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/?'+ str, {}).then(res=>{
  278. uni.hideLoading();
  279. if(res.status == 0){
  280. console.log(res.result.ad_info)
  281. if (res.result.ad_info) {
  282. that.city = res.result.ad_info.district
  283. }
  284. }
  285. })
  286. },
  287. orderNavclick(){
  288. this.feePay()
  289. },
  290. feePay(){
  291. this.$u.api.feePay({vehicleId: this.recordList[1]})
  292. .then( res=>{
  293. if(res.code == 200){
  294. this.handleGetIndexData()
  295. }
  296. })
  297. },
  298. openPage(path) {
  299. console.log('path',path);
  300. this.$u.route({
  301. url: path
  302. })
  303. },
  304. handleSearch(){
  305. console.log('this.keyword',this.keyword);
  306. uni.reLaunch({
  307. url: `/pages/parkingLists/parkingLists?keyword=${this.keyword}`
  308. })
  309. },
  310. handleCitySelect(){
  311. this.cityOpen = true;
  312. },
  313. cityChange(e){
  314. console.log('cityChange',e);
  315. this.city = e.city.label;
  316. },
  317. handleGetIndexData(){
  318. this.$u.api.getIndexData()
  319. .then(res=>{
  320. if(res.data.vehicleList.length<1){
  321. this.bindCarShow = true;
  322. }
  323. const enableFeepay=[]
  324. res.data.orderList.forEach(item => {
  325. enableFeepay.push(item.enableFeepay);
  326. enableFeepay.push(item.vehicleId);
  327. enableFeepay.push(item.contractStatus);
  328. })
  329. this.recordList=enableFeepay;
  330. // this.vehicleId=enableFeepay.vehicleId;
  331. this.orderNav = enableFeepay[0];
  332. this.contractStatus=enableFeepay[2];
  333. console.log('recordList',this.recordList)
  334. this.orderList = res.data.orderList;
  335. const list = []
  336. res.data.news.forEach(item => {
  337. list.push(item.content)
  338. })
  339. this.noticeList = list;
  340. }).catch(err=>{
  341. // alert(err.msg);
  342. console.log('getIndexData err',err)
  343. });
  344. },
  345. // 去支付,选择支付方式
  346. goPay(orderId){
  347. this.payWayPop = true
  348. this.curOrderList = []
  349. this.curOrderList.push(orderId)
  350. },
  351. onRoadInfo(item){
  352. this.$u.api.roadInfoById({id:item.roadId})
  353. .then(res=>{
  354. this.popupOrderDetails=res.data;
  355. this.showOrderDetails = true;
  356. }).catch(err=>{
  357. // alert(err.msg);
  358. console.log('getIndexData err',err)
  359. });
  360. },
  361. closeOrderDetails(){
  362. this.showOrderDetails = false;
  363. },
  364. phoneCall(phone){
  365. uni.makePhoneCall({
  366. phoneNumber: phone
  367. });
  368. },
  369. /**
  370. * 点击优惠活动的广告图
  371. * */
  372. promotionBannerClick(cur) {
  373. this.promotionBannerList.forEach((item, index) => {
  374. if (cur === index) {
  375. this.$u.route({
  376. url:'pages/favourableActivity/favourableActivity',
  377. params: {
  378. title: item.title,
  379. id: item.id
  380. }
  381. })
  382. }
  383. })
  384. },
  385. gyBankPay() {
  386. this.$u.api.payGzbank({orderList: this.curOrderList}).then(res=>{
  387. let payUrl = res.data.url;
  388. this.currentPayUrl=encodeURIComponent(res.data.url);
  389. this.$u.route({
  390. url: 'pages/payLists/pay',
  391. params: {
  392. currentPayUrl: this.currentPayUrl
  393. }
  394. });
  395. }).catch(err=>{
  396. this.$refs.uToast.show({
  397. title: err.msg,
  398. type: 'error',
  399. });
  400. });
  401. },
  402. // 微信支付
  403. wechatPay() {
  404. const openId = this.$store.state.vuex_wxinfo.openId
  405. if (openId) {
  406. this.getWXPay(this.curOrderList)
  407. } else {
  408. this.getCode()
  409. }
  410. },
  411. async getWXPay(list){
  412. let params = {
  413. orderList: list,
  414. openid: this.$store.state.vuex_wxinfo.openId
  415. };
  416. await this.$wxApi.config();
  417. this.$pay.wechatPay(params).then(res =>{
  418. if(res.code == 0){
  419. // 成功
  420. this.$u.route({
  421. url:'/',
  422. });
  423. }else if(res.code == 1){
  424. // 取消
  425. // uni.redirectTo({
  426. // url: '/pages/userCenter/myOrder/myOrder'
  427. // })
  428. }else if(res.code == 2){
  429. this.$refs.uToast.show({
  430. title: '支付失败,请检查!',
  431. type: 'error',
  432. // url: '/pages/user/index'
  433. });
  434. }
  435. });
  436. },
  437. getCode () {
  438. var local = window.location.href // 获取页面url
  439. let locationLocaturl = window.location.search;
  440. this.code = getUrlParams(locationLocaturl,"code"); // 截取code
  441. if (this.code == null || this.code === '') { // 如果没有code,则去请求
  442. 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`
  443. } else {
  444. this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
  445. }
  446. },
  447. handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
  448. let _this = this
  449. this.$u.api.getWXInfo(code).then((res) => {
  450. if (res.code === 200 ) {
  451. this.$u.vuex('vuex_wxinfo', res.data);
  452. // 继续支付
  453. this.getWXPay(this.currentItem)
  454. }
  455. }).catch((err) => {
  456. this.$refs.uToast.show({
  457. title: err.msg,
  458. type: 'error',
  459. });
  460. })
  461. },
  462. }
  463. }
  464. </script>
  465. <style lang="scss" scoped>
  466. @import "./index.scss";
  467. </style>