index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <view class="header">
  4. <view class="u-flex user-box u-m-b-24">
  5. <view class="u-m-r-10" @click="login($store.state.vuex_hasLogin)">
  6. <u-avatar :src="userInfo.headImgUrl || userInfo.avatar||pic" size="140"></u-avatar>
  7. </view>
  8. <view class="u-flex-1" @click="login($store.state.vuex_hasLogin)">
  9. <view class="u-font-18 u-p-b-20"><b>智慧停车</b><span class="payee-no">工号:{{ userInfo.payeeNo || '请登录' }}</span></view>
  10. <view class="u-font-14 u-flex">
  11. <u-icon class="u-m-r-18" name="map-fill" color="#fff" size="38"></u-icon>
  12. {{ theRoad.roadName || '暂无' }}
  13. </view>
  14. </view>
  15. <view class="u-m-l-10 u-p-10">
  16. <u-icon name="arrow-right" color="#fff" size="28"></u-icon>
  17. </view>
  18. </view>
  19. <view class="header-total u-flex wrap">
  20. <view class="u-p-r-60">
  21. 车位:{{ spaceInfo.spaceBusy }}/{{ spaceInfo.spaceTotal}}
  22. </view>
  23. <view class="">
  24. 需确认:{{ spaceInfo.spaceConfirm}}
  25. </view>
  26. </view>
  27. </view>
  28. <view class="wrap">
  29. <view class="notice u-flex u-p-l-35 u-p-r-40">
  30. <u-image width="113rpx" height="83rpx" src="/static/img/tip.png"></u-image>
  31. <view class="notice-wrap u-flex-1">
  32. <u-notice-bar mode="vertical" :list="noticeList" :more-icon="true" :volume-icon="false" bg-color="#fff" color="#373737"></u-notice-bar>
  33. </view>
  34. </view>
  35. <view class="feature-list u-flex u-flex-wrap u-row-between">
  36. <view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
  37. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-01.png"></u-image>
  38. <view class="feature-item-text">签到</view>
  39. </view>
  40. <view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
  41. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-02.png"></u-image>
  42. <view class="feature-item-text">拍照取证</view>
  43. </view>
  44. <view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
  45. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-03.png"></u-image>
  46. <view class="feature-item-text">缴费</view>
  47. </view>
  48. <view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
  49. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-04.png"></u-image>
  50. <view class="feature-item-text">车位管理</view>
  51. </view>
  52. <view class="feature-item" @click="openPage('pages/parking/parking')">
  53. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-05.png"></u-image>
  54. <view class="feature-item-text">车辆入场</view>
  55. </view>
  56. <view class="feature-item" @click="openPage('pages/getout/getout')">
  57. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-06.png"></u-image>
  58. <view class="feature-item-text">车辆出场</view>
  59. </view>
  60. <view class="feature-item" @click="openPage('pages/modifypwd/modifypwd')">
  61. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-07.png"></u-image>
  62. <view class="feature-item-text">密码修改</view>
  63. </view>
  64. <view class="feature-item" @click="$refs.uToast.show({title: '建设中'})">
  65. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-08.png"></u-image>
  66. <view class="feature-item-text">设置</view>
  67. </view>
  68. <view class="feature-item" @click="logout">
  69. <u-image width="120rpx" height="120rpx" src="/static/img/index-feature-09.png"></u-image>
  70. <view class="feature-item-text">退出登录</view>
  71. </view>
  72. </view>
  73. <u-bottom color="#949494"></u-bottom>
  74. </view>
  75. <u-toast ref="uToast" />
  76. </view>
  77. </template>
  78. <script>
  79. var ALog = uni.requireNativePlugin("AndroidLog")
  80. var location = uni.requireNativePlugin("Location")
  81. export default {
  82. data() {
  83. return {
  84. pic:'https://uviewui.com/common/logo.png',
  85. userInfo:[],
  86. noticeList:['智慧停车车主端V0.1版本发布','智慧停车PDA端V0.1版本发布'],
  87. theRoad:[],
  88. spaceInfo:new Object,
  89. }
  90. },
  91. onLoad() {
  92. this.getLocation();
  93. },
  94. onShow() {
  95. if(this.$store.state.vuex_hasLogin){
  96. this.userInfo = this.$store.state.vuex_user;
  97. this.theRoad = this.$store.state.vuex_user?.roadList?.[0]||[];
  98. if(this.theRoad.roadNo){
  99. console.log('this.theRoad.roadNo',this.theRoad.roadNo)
  100. this.handleGetIndex(this.theRoad.roadNo);
  101. };
  102. console.log('this.theRoad',this.theRoad);
  103. console.log('this.userInfo',this.userInfo);
  104. }else{
  105. this.userInfo = [];
  106. this.openPage('pages/login/login');
  107. };
  108. },
  109. methods: {
  110. getLocation(){
  111. ALog.info({msg:'请求定位'})
  112. uni.getLocation({
  113. type:"gcj02",
  114. success : function (res) {
  115. // console.log("定位返回信息:", res)
  116. // alert(res.longitude + "," + res.latitude )
  117. ALog.info({msg:res})
  118. var dst = '26.58751,106.78329';
  119. var src = res.latitude + ',' + res.longitude;
  120. var locRet = location.distance(src, dst)
  121. ALog.info({msg:locRet.distance})
  122. },
  123. fail: function(res){
  124. ALog.info({msg:'请求错误',err:res})
  125. }
  126. })
  127. },
  128. openPage(path) {
  129. // console.log('path',path);
  130. this.$u.route({
  131. url: path
  132. });
  133. },
  134. //登录判断
  135. login(status){
  136. if(!status){
  137. console.log('config',this.config);
  138. this.openPage('pages/login/login');
  139. // window.location.replace(this.config.loginUrl)
  140. }
  141. },
  142. logout(){
  143. uni.clearStorage();
  144. this.$u.vuex('vuex_token', null);
  145. this.$u.vuex('vuex_user', null);
  146. this.$u.vuex('vuex_hasLogin', false);
  147. this.userInfo = [];
  148. this.theRoad = [];
  149. this.$refs.uToast.show({
  150. title: '退出成功,即将跳转登录页!',
  151. type: 'success',
  152. url:'pages/login/login'
  153. });
  154. // this.$u.route(-1);
  155. },
  156. handleGetIndex(roadNo){
  157. this.$u.api.getIndex({roadNo:roadNo})
  158. .then(res=>{
  159. // this.$refs.uToast.show({
  160. // title: res.msg,
  161. // type: 'success',
  162. // });
  163. this.spaceInfo = res.data.spaceInfo;
  164. console.log('this.spaceInfo',this.spaceInfo)
  165. }).catch(err=>{
  166. if(err.errMsg){
  167. this.$refs.uToast.show({
  168. title: '请检查网络',
  169. type: 'error',
  170. });
  171. return false;
  172. };
  173. this.$refs.uToast.show({
  174. title: err.msg,
  175. type: 'error',
  176. });
  177. console.log('handleGetIndex ',err)
  178. });
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. @import "./index.scss";
  185. </style>