index.vue 15 KB

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