app-navigation.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. this.$app.popup.alert("此设备占用或异常。请更换其他设备", "温馨提示!");
  76. return;
  77. }
  78. this.$app.url.goto('/subPackages/charging/terminal/terminal?deviceId=' + res.data.connectorCode + "&deviceStatus=" + res.data
  79. .status);
  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: linear-gradient(322deg, #8FF8FB 0%, #47AEFF 100%);
  107. /* background-image: linear-gradient(to right, #8FF8FB, #47AEFF); */
  108. box-shadow: inset 0rpx 6rpx 20rpx 2rpx #FFFFFF;
  109. border: 3px solid #fff;
  110. position: absolute;
  111. transform: translateY(-10px);
  112. }
  113. .scan>.icon-scan {
  114. display: block;
  115. width: 22.5px;
  116. height: 22.5px;
  117. }
  118. .scan-placeholder {
  119. width: 60px;
  120. }
  121. .nav-item>.name {
  122. font-size: 10px;
  123. margin-top: 4px;
  124. }
  125. .nav-item>.icon {
  126. display: block;
  127. width: 22px;
  128. height: 22px;
  129. }
  130. </style>