Selaa lähdekoodia

fix: 移除首页/tabBar隐形登录覆盖层,改为显式登录按钮以通过微信审核

- 删除 map.vue 中全屏透明 getPhoneNumber 覆盖层,改为在电站列表区域显示可见的"登录/注册"按钮
- 删除 custom-tab-bar 中透明登录按钮覆盖层
- 用户页未登录时显示登录引导按钮,不再是空白页
- 未登录用户可正常浏览地图、周边电站和 banner
- 后端 stationStatus/businessPolicy 接口添加 @SaIgnore,listStation 等加入公开白名单

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 päivä sitten
vanhempi
säilyke
227ba3923a

+ 1 - 4
charge-front/src/custom-tab-bar/index.js

@@ -1,4 +1,4 @@
-import { fetchToken, login, onLogin } from "../api/auth";
+import { fetchToken, onLogin } from "../api/auth";
 
 Component({
   data: {
@@ -69,8 +69,5 @@ Component({
         hidden: false,
       });
     },
-    login(e) {
-      login(e);
-    },
   },
 });

+ 0 - 1
charge-front/src/custom-tab-bar/index.wxml

@@ -14,5 +14,4 @@
       </block>
     </view>
   </view>
-  <button class="tab-bar-login" wx:if="{{!token}}" style="width: 100vw;height: var(--tab-bar-height);border: none;" open-type="getPhoneNumber" bindgetphonenumber="login"></button>
 </view>

+ 20 - 44
charge-front/src/pages/map/map.vue

@@ -239,12 +239,15 @@
             mode="widthFix"
           />
           <view class="fs-22 mt-14 color-000-5">{{
-            loading
-              ? "加载中"
-              : token
-              ? "暂无充电站信息"
-              : "登录后查看更多电站信息"
+            loading ? "加载中" : "暂无充电站信息"
           }}</view>
+          <view v-if="!token && !loading" class="mt-32">
+            <button
+              open-type="getPhoneNumber"
+              @getphonenumber="handleLogin"
+              class="login-btn"
+            >登录/注册,查看更多电站</button>
+          </view>
         </view>
       </block>
     </view>
@@ -263,11 +266,6 @@
       }}</view>
     </view>
   </view>
-  <view class="login-mask" v-if="!token">
-    <button open-type="getPhoneNumber" @getphonenumber="loginMask" class="full">
-      登录按钮
-    </button>
-  </view>
 </template>
 
 <script setup lang="ts">
@@ -399,9 +397,6 @@ const refreshStation = (location: any) => {
   let length = 0;
   let available = 0;
   const { latitude, longitude } = location;
-  if (!token.value) {
-    return;
-  }
   return fetchStations(
     stationPage.value.page,
     stationPage.value.pageSize,
@@ -562,24 +557,10 @@ onLoad((query: any) => {
 
   setTimeout(() => {
     token.value = getApp<any>().globalData.token || "";
+
     if (!token.value) {
-      isIgnoreChangeLocation = true;
-      fetchLocation().then((res: any) => {
-        mapProps.value.latitude = res.latitude;
-        mapProps.value.longitude = res.longitude;
-        mapProps.value.selflatitude = res.latitude;
-        mapProps.value.selflongitude = res.longitude;
-        markers.value = [
-          {
-            id: -1,
-            latitude: res.latitude,
-            longitude: res.longitude,
-            iconPath: "/static/images/map-current.png",
-            width: 34,
-            height: 34,
-          },
-        ];
-      });
+      refresh();
+      fetchBanner();
       onLogin((_token) => {
         if (getApp<any>().globalData.normalCode) {
           const code: string = getApp<any>().globalData.normalCode;
@@ -761,7 +742,7 @@ const tapMarker = (e: any) => {
     _changeMarker(findIndex);
   }
 };
-const loginMask = (e: any) => {
+const handleLogin = (e: any) => {
   login(e);
 };
 
@@ -818,19 +799,14 @@ page {
   overflow: hidden;
 }
 
-.login-mask {
-  position: fixed;
-  left: 0;
-  top: 0;
-  width: 100%;
-  height: 100%;
-  z-index: 999999;
-  opacity: 0;
-
-  .full {
-    width: 100%;
-    height: 100%;
-  }
+.login-btn {
+  width: 80vw;
+  height: 80rpx;
+  background: var(--color-primary);
+  color: #fff;
+  font-size: 30rpx;
+  border-radius: 40rpx;
+  line-height: 80rpx;
 }
 
 .dialog {

+ 46 - 0
charge-front/src/pages/user/user.vue

@@ -65,11 +65,35 @@
       </view>
     </view>
   </block>
+  <block v-else>
+    <view class="container" :style="containerStyle">
+      <view class="header flex-column">
+        <view class="flex-grow flex-center">
+          <image
+            src="/static/images/user/round.png"
+            mode="heightFix"
+            style="height: 100%"
+          />
+        </view>
+        <view class="main flex-shrink flex-column flex-align-center pt-40">
+          <view class="fs-32 color-000-6 mt-40">登录后查看更多功能</view>
+          <view class="mt-32">
+            <button
+              open-type="getPhoneNumber"
+              @getphonenumber="handleLogin"
+              class="login-btn"
+            >登录/注册</button>
+          </view>
+        </view>
+      </view>
+    </view>
+  </block>
 </template>
 
 <script setup lang="ts">
 import { fetchContact } from "@/api";
 import { fetchProfile } from "@/api/user";
+import { login } from "@/api/auth";
 import { onLoad, onShow } from "@dcloudio/uni-app";
 import { ref } from "vue";
 const containerStyle = ref({});
@@ -138,6 +162,19 @@ const toPage = (index: number) => {
   });
 };
 
+const handleLogin = (e: any) => {
+  login(e).then(() => {
+    fetchProfile().then((res) => {
+      res.mobilePhoneFormat =
+        res.mobilePhone.slice(0, 3) + "****" + res.mobilePhone.slice(7);
+      res.avatar = res.avatar
+        ? res.avatar
+        : "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
+      user.value = res;
+    });
+  });
+};
+
 onLoad(() => {
   const bound = uni.getMenuButtonBoundingClientRect();
   containerStyle.value = {
@@ -163,6 +200,15 @@ onShow(() => {
 
 <style lang="scss">
 @use "../../styles/dialog.scss";
+.login-btn {
+  width: 480rpx;
+  height: 80rpx;
+  background: var(--color-primary);
+  color: #fff;
+  font-size: 30rpx;
+  border-radius: 40rpx;
+  line-height: 80rpx;
+}
 .bg {
   position: absolute;
   left: 0;

+ 9 - 0
miniapp/src/main/java/com/kym/miniapp/config/SaTokenConfigure.java

@@ -27,7 +27,16 @@ public class SaTokenConfigure implements WebMvcConfigurer {
                         "/error",
                         "/user/wxLogin",
                         "/user/refresh",
+                        "/banner",
+                        "/common/contact",
                         "/charge/pullEnStations/*",
+                        "/charge/listStation",
+                        "/charge/stationStatus",
+                        "/charge/businessPolicy/*",
+                        "/charge/stationInfo/*",
+                        "/charge/stationInfoByShortId/*",
+                        "/charge/stationInfoByConnectorId/*",
+                        "/charge/stationInfoByEquipmentId/*",
                         "/charge/*/query_token",
                         "/charge/*/notification_stationStatus",
                         "/charge/*/notification_start_charge_result",

+ 2 - 0
miniapp/src/main/java/com/kym/miniapp/controller/ChargeController.java

@@ -140,6 +140,7 @@ public class ChargeController {
      * @return
      */
     @GetMapping("/stationStatus")
+    @SaIgnore
     R<?> stationStatus(@RequestParam("stationIds") String ids) {
         // 请求en+接口
         var response = stationService.stationStatus(ids.split(","));
@@ -202,6 +203,7 @@ public class ChargeController {
      * @return
      */
     @GetMapping("/businessPolicy/{connectorId}")
+    @SaIgnore
     R<?> businessPolicy(@PathVariable("connectorId") String connectorId) {
         return R.success(chargeService.queryEquipBusinessPolicy(connectorId));
     }