app-navigation.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="app-navigation">
  3. <view class="__body">
  4. <view @click="act('home')" class="nav-item">
  5. <image :src="homeIcon" class="icon"></image>
  6. <view class="name">首页</view>
  7. </view>
  8. <view class="scan" @click="sacn()">
  9. <image src="@/static/img/appnav-scan.svg.svg" class="icon-scan"></image>
  10. </view>
  11. <view class="scan-placeholder"></view>
  12. <view @click="act('my')" class="nav-item">
  13. <image :src="myIcon" class="icon"></image>
  14. <view class="name">我的</view>
  15. </view>
  16. </view>
  17. <ax-ios-indicator min="10"></ax-ios-indicator>
  18. </view>
  19. </template>
  20. <script>
  21. import { url } from '../../static/js/app';
  22. export default {
  23. name:"app-navigation",
  24. props:{
  25. // 激活对象
  26. active:{type:String,default:""}
  27. },
  28. computed:{
  29. myIcon(){
  30. return `../../static/img/appnav-my${this.active == 'my'?'.active':''}.svg`;
  31. },
  32. homeIcon(){
  33. return `../../static/img/appnav-home${this.active == 'home'?'.active':''}.svg`;
  34. }
  35. },
  36. methods:{
  37. act(name){
  38. if(name == this.active) return;
  39. var url = '';
  40. switch (name){
  41. case 'home':
  42. url = '/pages/index/index';
  43. break;
  44. case 'my':
  45. url = '/pages/my/my';
  46. break;
  47. }
  48. if(url) uni.reLaunch({url});
  49. },
  50. //扫一扫
  51. sacn(){
  52. this.$app.act.scan().then(res=>{
  53. var paramObj = this.getUrlParams(res.result);
  54. if(!paramObj || !paramObj.connectorCode){
  55. this.$app.popup.alert("二维码不正确。","温馨提示!");
  56. return;
  57. }
  58. this.getDeviceInfo(paramObj.connectorCode);
  59. })
  60. },
  61. getUrlParams(url) {
  62. const paramsRegex = /[?&]+([^=&]+)=([^&]*)/gi;
  63. const params = {};
  64. let match;
  65. while (match = paramsRegex.exec(url)) {
  66. params[match[1]] = match[2];
  67. }
  68. return params;
  69. },
  70. //通过充电桩编码(sn)获取设备详情
  71. getDeviceInfo(sn){
  72. this.$api.base("post","/chargeApi/checkDevicesBySn",{"sn":sn},{}).then(res=>{
  73. console.log("设备信息:",res)
  74. var item = res.device;
  75. //设备状态 0:离网1:空闲2:占用(未充电)3:占用(充电中)4:占用(预约锁定)255:故障
  76. if(item.deviceStatus == 0 || item.deviceStatus == 255 ){
  77. return;
  78. }
  79. this.$app.url.goto('/pages/terminal/terminal?deviceId='+item.id+"&deviceStatus="+item.deviceStatus);
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .app-navigation{
  87. background-color: #fff;
  88. border-radius: 15px 15px 0 0;
  89. filter: drop-shadow(0 -3px 6px rgba(0, 0, 0, 0.05));
  90. }
  91. .app-navigation .__body{
  92. display: flex;
  93. align-items: center;
  94. justify-content: space-around;
  95. position: relative;
  96. padding: 10px;
  97. padding-bottom: 0;
  98. }
  99. .scan{
  100. display: inline-flex;
  101. align-items: center;
  102. justify-content: center;
  103. width: 60px;
  104. height: 60px;
  105. border-radius: 100pc;
  106. background-image: linear-gradient(to right,#8FF8FB,#47AEFF);
  107. box-shadow: 0 3px 6px #00BFE1 inset;
  108. border: 3px solid #fff;
  109. position: absolute;
  110. transform: translateY(-10px);
  111. }
  112. .scan > .icon-scan{
  113. display: block;
  114. width: 22.5px;
  115. height: 22.5px;
  116. }
  117. .scan-placeholder{
  118. width: 60px;
  119. }
  120. .nav-item > .name{
  121. font-size: 10px;
  122. margin-top: 4px;
  123. }
  124. .nav-item > .icon{
  125. display: block;
  126. width: 22px;
  127. height: 22px;
  128. }
  129. </style>