app-navigation.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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("get", "/applet/v1/station/connector/detail", { "connectorCode": sn }, {}).then(res => {
  73. console.log("设备信息:", res)
  74. if (res.data.status == 0 || res.data.status == 255) {
  75. return;
  76. }
  77. this.$app.url.goto('/pages/terminal/terminal?deviceId=' + res.data.connectorCode + "&deviceStatus=" + res.data
  78. .status);
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped>
  85. .app-navigation {
  86. background-color: #fff;
  87. border-radius: 15px 15px 0 0;
  88. filter: drop-shadow(0 -3px 6px rgba(0, 0, 0, 0.05));
  89. }
  90. .app-navigation .__body {
  91. display: flex;
  92. align-items: center;
  93. justify-content: space-around;
  94. position: relative;
  95. padding: 10px;
  96. padding-bottom: 0;
  97. }
  98. .scan {
  99. display: inline-flex;
  100. align-items: center;
  101. justify-content: center;
  102. width: 60px;
  103. height: 60px;
  104. border-radius: 100pc;
  105. background-image: linear-gradient(to right, #8FF8FB, #47AEFF);
  106. box-shadow: 0 3px 6px #00BFE1 inset;
  107. border: 3px solid #fff;
  108. position: absolute;
  109. transform: translateY(-10px);
  110. }
  111. .scan>.icon-scan {
  112. display: block;
  113. width: 22.5px;
  114. height: 22.5px;
  115. }
  116. .scan-placeholder {
  117. width: 60px;
  118. }
  119. .nav-item>.name {
  120. font-size: 10px;
  121. margin-top: 4px;
  122. }
  123. .nav-item>.icon {
  124. display: block;
  125. width: 22px;
  126. height: 22px;
  127. }
  128. </style>