Zhangbw hace 3 meses
padre
commit
05e7b1f2ec

+ 57 - 7
dist/dev/mp-weixin/pages/index/index.js

@@ -13,6 +13,7 @@ const _sfc_main = {
     const suggestions = common_vendor.ref([]);
     const showDropdown = common_vendor.ref(false);
     const isLoggedIn = common_vendor.ref(false);
+    const showPhoneAuth = common_vendor.ref(false);
     let timer = null;
     common_vendor.onMounted(() => {
       isLoggedIn.value = utils_auth.isLoggedIn();
@@ -23,19 +24,61 @@ const _sfc_main = {
       isLoggedIn.value = utils_auth.isLoggedIn();
       console.log("[首页] 登录状态:", isLoggedIn.value);
     });
-    const handleSearchClick = () => {
+    const handleSearchClick = async () => {
       console.log("=== 点击搜索按钮 ===");
       console.log("当前登录状态:", isLoggedIn.value);
       if (!isLoggedIn.value) {
-        console.log("未登录,显示微信授权弹窗");
-        utils_auth.checkLogin(() => {
-          onSearch();
-        });
+        console.log("未登录,直接调用微信授权");
+        handleLogin();
         return;
       }
       console.log("已登录,执行搜索");
       onSearch();
     };
+    const handleLogin = () => {
+      console.log("[首页] 显示手机号授权弹窗");
+      showPhoneAuth.value = true;
+    };
+    const onGetPhoneNumber = async (e) => {
+      console.log("[首页] 获取手机号回调:", e.detail);
+      if (e.detail.errMsg === "getPhoneNumber:ok") {
+        const phoneCode = e.detail.code;
+        console.log("[首页] phoneCode:", phoneCode);
+        common_vendor.index.showLoading({
+          title: "登录中...",
+          mask: true
+        });
+        try {
+          const loginRes = await common_vendor.index.login();
+          console.log("[首页] uni.login完整响应:", loginRes);
+          console.log("[首页] 微信登录code:", loginRes.code);
+          if (!loginRes.code) {
+            throw new Error("获取微信登录code失败");
+          }
+          const result2 = await utils_auth.wxAuthLogin(loginRes.code, phoneCode);
+          common_vendor.index.hideLoading();
+          if (result2) {
+            showPhoneAuth.value = false;
+            isLoggedIn.value = utils_auth.isLoggedIn();
+            onSearch();
+          }
+        } catch (error) {
+          common_vendor.index.hideLoading();
+          console.error("[首页] 登录失败:", error);
+        }
+      } else {
+        showPhoneAuth.value = false;
+        common_vendor.index.showToast({
+          title: "需要授权手机号才能完成登录",
+          icon: "none",
+          duration: 2e3
+        });
+      }
+    };
+    const closePhoneAuth = () => {
+      showPhoneAuth.value = false;
+      tempUserInfo.value = null;
+    };
     const onKeywordChange = (e) => {
       const value = e.detail.value;
       keyword.value = value;
@@ -117,7 +160,7 @@ const _sfc_main = {
     return (_ctx, _cache) => {
       return common_vendor.e({
         a: common_vendor.o([($event) => keyword.value = $event.detail.value, onKeywordChange]),
-        b: common_vendor.o(onSearch),
+        b: common_vendor.o(handleSearchClick),
         c: common_vendor.o(onInputBlur),
         d: keyword.value,
         e: common_vendor.o(handleSearchClick),
@@ -160,7 +203,14 @@ const _sfc_main = {
       } : {}, {
         k: errorMsg.value,
         m: result.value
-      }) : {});
+      }) : {}, {
+        s: showPhoneAuth.value
+      }, showPhoneAuth.value ? {
+        t: common_vendor.o(onGetPhoneNumber),
+        v: common_vendor.o(() => {
+        }),
+        w: common_vendor.o(closePhoneAuth)
+      } : {});
     };
   }
 };

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
dist/dev/mp-weixin/pages/index/index.wxml


+ 59 - 0
dist/dev/mp-weixin/pages/index/index.wxss

@@ -286,3 +286,62 @@
 .bottom-safe-area {
   height: 80rpx;
 }
+
+/* 手机号授权弹窗 */
+.phone-auth-mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.6);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 9999;
+}
+.phone-auth-prompt {
+  width: 560rpx;
+  background: #ffffff;
+  border-radius: 24rpx;
+  padding: 50rpx 40rpx;
+  text-align: center;
+  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
+}
+.auth-icon {
+  font-size: 72rpx;
+  margin-bottom: 20rpx;
+}
+.auth-title {
+  display: block;
+  font-size: 32rpx;
+  font-weight: 600;
+  color: #222222;
+  margin-bottom: 12rpx;
+}
+.auth-desc {
+  display: block;
+  font-size: 24rpx;
+  color: #999999;
+  line-height: 1.5;
+  margin-bottom: 32rpx;
+}
+.auth-button {
+  width: 100%;
+  height: 80rpx;
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  color: #ffffff;
+  border-radius: 40rpx;
+  font-size: 30rpx;
+  font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+.auth-button::after {
+  border: none;
+}

+ 61 - 26
dist/dev/mp-weixin/pages/mine/mine.js

@@ -6,6 +6,7 @@ const _sfc_main = {
   __name: "mine",
   setup(__props) {
     const isLoggedIn = common_vendor.ref(false);
+    const showPhoneAuth = common_vendor.ref(false);
     const userInfo = common_vendor.ref({
       nickname: "",
       avatar: "",
@@ -30,47 +31,74 @@ const _sfc_main = {
       }
     };
     const handleEditProfile = () => {
-      if (!utils_auth.checkLogin(() => {
-        handleEditProfile();
-      })) {
+      if (!utils_auth.checkLogin()) {
         return;
       }
       common_vendor.index.navigateTo({
         url: "/pages/profile/edit"
       });
     };
-    const toggleLogin = () => {
-      if (isLoggedIn.value) {
-        common_vendor.index.showModal({
-          title: "提示",
-          content: "确定要退出登录吗?",
-          success: (res) => {
-            if (res.confirm) {
-              utils_auth.logout();
-              isLoggedIn.value = false;
-              userInfo.value = { nickname: "", avatar: "", phone: "" };
-              common_vendor.index.showToast({ title: "已退出登录", icon: "none" });
-            }
-          }
+    const handleLogin = () => {
+      console.log("[我的] 显示手机号授权弹窗");
+      showPhoneAuth.value = true;
+    };
+    const onGetPhoneNumber = async (e) => {
+      console.log("[我的] 获取手机号回调:", e.detail);
+      if (e.detail.errMsg === "getPhoneNumber:ok") {
+        const phoneCode = e.detail.code;
+        console.log("[我的] phoneCode:", phoneCode);
+        common_vendor.index.showLoading({
+          title: "登录中...",
+          mask: true
         });
+        try {
+          const loginRes = await common_vendor.index.login();
+          console.log("[我的] uni.login完整响应:", loginRes);
+          console.log("[我的] 微信登录code:", loginRes.code);
+          if (!loginRes.code) {
+            throw new Error("获取微信登录code失败");
+          }
+          const result = await utils_auth.wxAuthLogin(loginRes.code, phoneCode);
+          common_vendor.index.hideLoading();
+          if (result) {
+            showPhoneAuth.value = false;
+            loadUserInfo();
+          }
+        } catch (error) {
+          common_vendor.index.hideLoading();
+          console.error("[我的] 登录失败:", error);
+        }
       } else {
-        utils_auth.wxAuthLogin(() => {
-          loadUserInfo();
+        showPhoneAuth.value = false;
+        common_vendor.index.showToast({
+          title: "需要授权手机号才能完成登录",
+          icon: "none",
+          duration: 2e3
         });
       }
     };
+    const handleLogout = () => {
+      common_vendor.index.showModal({
+        title: "提示",
+        content: "确定要退出登录吗?",
+        success: (res) => {
+          if (res.confirm) {
+            utils_auth.logout();
+            isLoggedIn.value = false;
+            userInfo.value = { nickname: "", avatar: "", phone: "" };
+            common_vendor.index.showToast({ title: "已退出登录", icon: "none" });
+          }
+        }
+      });
+    };
     const handleRecharge = () => {
-      if (!utils_auth.checkLogin(() => {
-        handleRecharge();
-      })) {
+      if (!utils_auth.checkLogin()) {
         return;
       }
       common_vendor.index.showToast({ title: "充值功能开发中", icon: "none" });
     };
     const handleHistory = () => {
-      if (!utils_auth.checkLogin(() => {
-        handleHistory();
-      })) {
+      if (!utils_auth.checkLogin()) {
         return;
       }
       common_vendor.index.showToast({ title: "记录功能开发中", icon: "none" });
@@ -87,8 +115,15 @@ const _sfc_main = {
         f: common_vendor.t(isLoggedIn.value ? points.value : 0),
         g: common_vendor.o(handleRecharge),
         h: common_vendor.o(handleHistory),
-        i: common_vendor.t(isLoggedIn.value ? "退出登录" : "登录"),
-        j: common_vendor.o(toggleLogin)
+        i: !isLoggedIn.value && !showPhoneAuth.value
+      }, !isLoggedIn.value && !showPhoneAuth.value ? {
+        j: common_vendor.o(handleLogin)
+      } : !isLoggedIn.value && showPhoneAuth.value ? {
+        l: common_vendor.o(onGetPhoneNumber)
+      } : {
+        m: common_vendor.o(handleLogout)
+      }, {
+        k: !isLoggedIn.value && showPhoneAuth.value
       });
     };
   }

+ 1 - 1
dist/dev/mp-weixin/pages/mine/mine.wxml

@@ -1 +1 @@
-<view class="page-mine"><view class="user-card"><view class="avatar-container" bindtap="{{b}}"><image class="avatar" src="{{a}}" mode="aspectFill"></image><view class="edit-icon">✏️</view></view><view class="user-info"><text class="username">{{c}}</text><text wx:if="{{d}}" class="phone">{{e}}</text></view></view><view class="section-card"><view class="card-header"><view class="header-icon-box"><text class="header-icon-text">🪙</text></view><text class="header-title">积分值</text></view><view class="card-content points-content"><text class="points-value">积分值:{{f}}</text><view class="points-actions"><button class="mini-btn" bindtap="{{g}}">充值</button><button class="mini-btn" bindtap="{{h}}">积分记录</button></view></view></view><view class="section-card"><view class="card-header"><view class="header-icon-box"><text class="header-icon-text">📝</text></view><text class="header-title">交易记录</text></view><view class="card-content transaction-content"><text class="empty-text">暂无交易记录</text></view></view><view class="action-area"><button class="main-btn" bindtap="{{j}}">{{i}}</button></view></view>
+<view class="page-mine"><view class="user-card"><view class="avatar-container" bindtap="{{b}}"><image class="avatar" src="{{a}}" mode="aspectFill"></image><view class="edit-icon">✏️</view></view><view class="user-info"><text class="username">{{c}}</text><text wx:if="{{d}}" class="phone">{{e}}</text></view></view><view class="section-card"><view class="card-header"><view class="header-icon-box"><text class="header-icon-text">🪙</text></view><text class="header-title">积分值</text></view><view class="card-content points-content"><text class="points-value">积分值:{{f}}</text><view class="points-actions"><button class="mini-btn" bindtap="{{g}}">充值</button><button class="mini-btn" bindtap="{{h}}">积分记录</button></view></view></view><view class="section-card"><view class="card-header"><view class="header-icon-box"><text class="header-icon-text">📝</text></view><text class="header-title">交易记录</text></view><view class="card-content transaction-content"><text class="empty-text">暂无交易记录</text></view></view><view class="action-area"><button wx:if="{{i}}" class="main-btn" bindtap="{{j}}"> 微信授权登录 </button><button wx:elif="{{k}}" class="main-btn phone-auth-btn" open-type="getPhoneNumber" bindgetphonenumber="{{l}}"> 授权手机号 </button><button wx:else class="main-btn" bindtap="{{m}}"> 退出登录 </button></view></view>

+ 5 - 0
dist/dev/mp-weixin/pages/mine/mine.wxss

@@ -157,3 +157,8 @@
 .main-btn:active {
   opacity: 0.9;
 }
+.phone-auth-btn {
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  box-shadow: 0 12rpx 24rpx rgba(255, 152, 0, 0.4);
+}
+

+ 58 - 10
dist/dev/mp-weixin/pages/pool/pool.js

@@ -7,6 +7,7 @@ const _sfc_main = {
   setup(__props) {
     const isPurchased = common_vendor.ref(false);
     const showModal = common_vendor.ref(false);
+    const showPhoneAuth = common_vendor.ref(false);
     const selectedPlan = common_vendor.ref("daily");
     const selectedDate = common_vendor.ref("2025年11月20日");
     const isLoggedIn = common_vendor.ref(false);
@@ -38,12 +39,52 @@ const _sfc_main = {
     const showPurchaseModal = () => {
       console.log("点击立即解锁");
       if (!checkLogin()) {
-        console.log("未登录,显示微信授权弹窗");
+        console.log("未登录,显示手机号授权弹窗");
+        showPhoneAuth.value = true;
         return;
       }
       console.log("已登录,显示购买弹窗");
       showModal.value = true;
     };
+    const onGetPhoneNumber = async (e) => {
+      console.log("[超短池] 获取手机号回调:", e.detail);
+      if (e.detail.errMsg === "getPhoneNumber:ok") {
+        const phoneCode = e.detail.code;
+        console.log("[超短池] phoneCode:", phoneCode);
+        common_vendor.index.showLoading({
+          title: "登录中...",
+          mask: true
+        });
+        try {
+          const loginRes = await common_vendor.index.login();
+          console.log("[超短池] uni.login完整响应:", loginRes);
+          console.log("[超短池] 微信登录code:", loginRes.code);
+          if (!loginRes.code) {
+            throw new Error("获取微信登录code失败");
+          }
+          const result = await utils_auth.wxAuthLogin(loginRes.code, phoneCode);
+          common_vendor.index.hideLoading();
+          if (result) {
+            showPhoneAuth.value = false;
+            checkLogin();
+            showModal.value = true;
+          }
+        } catch (error) {
+          common_vendor.index.hideLoading();
+          console.error("[超短池] 登录失败:", error);
+        }
+      } else {
+        showPhoneAuth.value = false;
+        common_vendor.index.showToast({
+          title: "需要授权手机号才能完成登录",
+          icon: "none",
+          duration: 2e3
+        });
+      }
+    };
+    const closePhoneAuth = () => {
+      showPhoneAuth.value = false;
+    };
     const closePurchaseModal = () => {
       showModal.value = false;
     };
@@ -100,17 +141,24 @@ const _sfc_main = {
         c: selectedDate.value,
         d: common_vendor.o(($event) => selectedDate.value = $event.detail.value),
         e: common_vendor.o(onHistorySearch),
-        f: showModal.value
+        f: showPhoneAuth.value
+      }, showPhoneAuth.value ? {
+        g: common_vendor.o(onGetPhoneNumber),
+        h: common_vendor.o(() => {
+        }),
+        i: common_vendor.o(closePhoneAuth)
+      } : {}, {
+        j: showModal.value
       }, showModal.value ? {
-        g: common_vendor.o(closePurchaseModal),
-        h: selectedPlan.value === "daily" ? 1 : "",
-        i: common_vendor.o(($event) => selectedPlan.value = "daily"),
-        j: selectedPlan.value === "weekly" ? 1 : "",
-        k: common_vendor.o(($event) => selectedPlan.value = "weekly"),
-        l: common_vendor.o(handlePurchase),
-        m: common_vendor.o(() => {
+        k: common_vendor.o(closePurchaseModal),
+        l: selectedPlan.value === "daily" ? 1 : "",
+        m: common_vendor.o(($event) => selectedPlan.value = "daily"),
+        n: selectedPlan.value === "weekly" ? 1 : "",
+        o: common_vendor.o(($event) => selectedPlan.value = "weekly"),
+        p: common_vendor.o(handlePurchase),
+        q: common_vendor.o(() => {
         }),
-        n: common_vendor.o(closePurchaseModal)
+        r: common_vendor.o(closePurchaseModal)
       } : {});
     };
   }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
dist/dev/mp-weixin/pages/pool/pool.wxml


+ 59 - 0
dist/dev/mp-weixin/pages/pool/pool.wxss

@@ -303,3 +303,62 @@
 .bottom-safe-area {
   height: 80rpx;
 }
+
+/* 手机号授权弹窗 */
+.phone-auth-mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.6);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 9999;
+}
+.phone-auth-prompt {
+  width: 560rpx;
+  background: #ffffff;
+  border-radius: 24rpx;
+  padding: 50rpx 40rpx;
+  text-align: center;
+  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
+}
+.auth-icon {
+  font-size: 72rpx;
+  margin-bottom: 20rpx;
+}
+.auth-title {
+  display: block;
+  font-size: 32rpx;
+  font-weight: 600;
+  color: #222222;
+  margin-bottom: 12rpx;
+}
+.auth-desc {
+  display: block;
+  font-size: 24rpx;
+  color: #999999;
+  line-height: 1.5;
+  margin-bottom: 32rpx;
+}
+.auth-button {
+  width: 100%;
+  height: 80rpx;
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  color: #ffffff;
+  border-radius: 40rpx;
+  font-size: 30rpx;
+  font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+.auth-button::after {
+  border: none;
+}

+ 33 - 5
dist/dev/mp-weixin/pages/rank/rank.js

@@ -41,10 +41,38 @@ const _sfc_main = {
         return "rank-third";
       return "";
     };
-    const goToLogin = () => {
-      utils_auth.wxAuthLogin(() => {
-        checkLoginAndLoadData();
-      });
+    const onGetPhoneNumber = async (e) => {
+      console.log("[模拟排名] 获取手机号回调:", e.detail);
+      if (e.detail.errMsg === "getPhoneNumber:ok") {
+        const phoneCode = e.detail.code;
+        console.log("[模拟排名] phoneCode:", phoneCode);
+        common_vendor.index.showLoading({
+          title: "登录中...",
+          mask: true
+        });
+        try {
+          const loginRes = await common_vendor.index.login();
+          console.log("[模拟排名] uni.login完整响应:", loginRes);
+          console.log("[模拟排名] 微信登录code:", loginRes.code);
+          if (!loginRes.code) {
+            throw new Error("获取微信登录code失败");
+          }
+          const result = await utils_auth.wxAuthLogin(loginRes.code, phoneCode);
+          common_vendor.index.hideLoading();
+          if (result) {
+            checkLoginAndLoadData();
+          }
+        } catch (error) {
+          common_vendor.index.hideLoading();
+          console.error("[模拟排名] 登录失败:", error);
+        }
+      } else {
+        common_vendor.index.showToast({
+          title: "需要授权手机号才能登录",
+          icon: "none",
+          duration: 2e3
+        });
+      }
     };
     const checkLoginAndLoadData = () => {
       isLoggedIn.value = utils_auth.isLoggedIn();
@@ -101,7 +129,7 @@ const _sfc_main = {
         j: !isLoggedIn.value ? 1 : "",
         k: !isLoggedIn.value
       }, !isLoggedIn.value ? {
-        l: common_vendor.o(goToLogin)
+        l: common_vendor.o(onGetPhoneNumber)
       } : {});
     };
   }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
dist/dev/mp-weixin/pages/rank/rank.wxml


+ 15 - 3
dist/dev/mp-weixin/pages/rank/rank.wxss

@@ -245,14 +245,26 @@
   line-height: 1.5;
   margin-bottom: 32rpx;
 }
-.login-button {
+.login-button-native {
   width: 100%;
   height: 80rpx;
-  background: linear-gradient(135deg, #5d55e8, #7568ff);
+  background: linear-gradient(135deg, #4CAF50, #66BB6A);
   color: #ffffff;
   border-radius: 40rpx;
   font-size: 30rpx;
   font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(76, 175, 80, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
   border: none;
-  box-shadow: 0 8rpx 24rpx rgba(93, 85, 232, 0.4);
+  padding: 0;
+  line-height: 80rpx;
+}
+.login-button-native::after {
+  border: none;
+}
+.button-icon {
+  font-size: 32rpx;
+  margin-right: 12rpx;
 }

+ 45 - 21
dist/dev/mp-weixin/pages/strong/strong.js

@@ -22,18 +22,42 @@ const _sfc_main = {
     ]);
     const selectedDate = common_vendor.ref("2025年11月20日");
     const showBuyModalFlag = common_vendor.ref(false);
-    const showSellModalFlag = common_vendor.ref(false);
-    const currentStock = common_vendor.ref({});
-    const buyQuantity = common_vendor.ref("100");
-    const sellQuantity = common_vendor.ref("100");
     const checkLogin = () => {
       isLoggedIn.value = utils_auth.isLoggedIn();
       console.log("[强势池] 登录状态:", isLoggedIn.value);
     };
-    const goToLogin = () => {
-      utils_auth.wxAuthLogin(() => {
-        checkLogin();
-      });
+    const onGetPhoneNumber = async (e) => {
+      console.log("[强势池] 获取手机号回调:", e.detail);
+      if (e.detail.errMsg === "getPhoneNumber:ok") {
+        const phoneCode = e.detail.code;
+        console.log("[强势池] phoneCode:", phoneCode);
+        common_vendor.index.showLoading({
+          title: "登录中...",
+          mask: true
+        });
+        try {
+          const loginRes = await common_vendor.index.login();
+          console.log("[强势池] uni.login完整响应:", loginRes);
+          console.log("[强势池] 微信登录code:", loginRes.code);
+          if (!loginRes.code) {
+            throw new Error("获取微信登录code失败");
+          }
+          const result = await utils_auth.wxAuthLogin(loginRes.code, phoneCode);
+          common_vendor.index.hideLoading();
+          if (result) {
+            checkLogin();
+          }
+        } catch (error) {
+          common_vendor.index.hideLoading();
+          console.error("[强势池] 登录失败:", error);
+        }
+      } else {
+        common_vendor.index.showToast({
+          title: "需要授权手机号才能登录",
+          icon: "none",
+          duration: 2e3
+        });
+      }
     };
     const buyTotalAmount = common_vendor.computed(() => {
       const qty = parseInt(buyQuantity.value) || 0;
@@ -181,30 +205,30 @@ const _sfc_main = {
         f: !isLoggedIn.value ? 1 : "",
         g: !isLoggedIn.value
       }, !isLoggedIn.value ? {
-        h: common_vendor.o(goToLogin)
+        h: common_vendor.o(onGetPhoneNumber)
       } : {}, {
         i: showBuyModalFlag.value
       }, showBuyModalFlag.value ? {
         j: common_vendor.o(closeBuyModal),
-        k: common_vendor.t(currentStock.value.name),
-        l: common_vendor.t(currentStock.value.code),
-        m: common_vendor.t(currentStock.value.price),
-        n: common_vendor.o([($event) => buyQuantity.value = $event.detail.value, onBuyQuantityChange]),
-        o: buyQuantity.value,
+        k: common_vendor.t(_ctx.currentStock.name),
+        l: common_vendor.t(_ctx.currentStock.code),
+        m: common_vendor.t(_ctx.currentStock.price),
+        n: common_vendor.o([($event) => _ctx.buyQuantity = $event.detail.value, onBuyQuantityChange]),
+        o: _ctx.buyQuantity,
         p: common_vendor.t(common_vendor.unref(buyTotalAmount).toFixed(2)),
         q: common_vendor.o(handleBuy),
         r: common_vendor.o(() => {
         }),
         s: common_vendor.o(closeBuyModal)
       } : {}, {
-        t: showSellModalFlag.value
-      }, showSellModalFlag.value ? {
+        t: _ctx.showSellModalFlag
+      }, _ctx.showSellModalFlag ? {
         v: common_vendor.o(closeSellModal),
-        w: common_vendor.t(currentStock.value.name),
-        x: common_vendor.t(currentStock.value.code),
-        y: common_vendor.t(currentStock.value.price),
-        z: common_vendor.o([($event) => sellQuantity.value = $event.detail.value, onSellQuantityChange]),
-        A: sellQuantity.value,
+        w: common_vendor.t(_ctx.currentStock.name),
+        x: common_vendor.t(_ctx.currentStock.code),
+        y: common_vendor.t(_ctx.currentStock.price),
+        z: common_vendor.o([($event) => _ctx.sellQuantity = $event.detail.value, onSellQuantityChange]),
+        A: _ctx.sellQuantity,
         B: common_vendor.t(common_vendor.unref(sellTotalAmount).toFixed(2)),
         C: common_vendor.o(handleSell),
         D: common_vendor.o(() => {

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
dist/dev/mp-weixin/pages/strong/strong.wxml


+ 15 - 3
dist/dev/mp-weixin/pages/strong/strong.wxss

@@ -425,14 +425,26 @@
   line-height: 1.5;
   margin-bottom: 32rpx;
 }
-.login-button {
+.login-button-native {
   width: 100%;
   height: 80rpx;
-  background: linear-gradient(135deg, #5d55e8, #7568ff);
+  background: linear-gradient(135deg, #4CAF50, #66BB6A);
   color: #ffffff;
   border-radius: 40rpx;
   font-size: 30rpx;
   font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(76, 175, 80, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+.login-button-native::after {
   border: none;
-  box-shadow: 0 8rpx 24rpx rgba(93, 85, 232, 0.4);
+}
+.button-icon {
+  font-size: 32rpx;
+  margin-right: 12rpx;
 }

+ 7 - 6
dist/dev/mp-weixin/utils/api.js

@@ -1,6 +1,7 @@
 "use strict";
 const common_vendor = require("../common/vendor.js");
-const BASE_URL = "http://localhost:8080";
+const DEV_BASE_URL = "http://192.168.1.3:8080";
+const BASE_URL = DEV_BASE_URL;
 const getToken = () => {
   return common_vendor.index.getStorageSync("user_token") || null;
 };
@@ -30,13 +31,13 @@ const request = (options) => {
           setTimeout(() => {
             common_vendor.index.showModal({
               title: "登录提示",
-              content: "登录已过期,是否重新登录?",
-              confirmText: "立即登录",
-              cancelText: "暂不登录",
+              content: '登录已过期,请前往"模拟排名"或"强势池"页面重新登录',
+              confirmText: "登录",
+              cancelText: "取消",
               success: (modalRes) => {
                 if (modalRes.confirm) {
-                  "./auth.js".then((auth) => {
-                    auth.wxAuthLogin();
+                  common_vendor.index.switchTab({
+                    url: "/pages/rank/rank"
                   });
                 }
               }

+ 43 - 37
dist/dev/mp-weixin/utils/auth.js

@@ -1,5 +1,4 @@
 "use strict";
-Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
 const common_vendor = require("../common/vendor.js");
 const utils_api = require("./api.js");
 const TOKEN_KEY = "user_token";
@@ -30,37 +29,53 @@ const logout = () => {
   removeToken();
   removeUserInfo();
 };
-const wxAuthLogin = async (successCallback, failCallback) => {
+const wxAuthLogin = async (code, phoneCode) => {
   try {
-    const loginRes = await common_vendor.index.login();
-    console.log("[微信登录] 获取code成功:", loginRes.code);
-    const result = await utils_api.wxLogin({
-      code: loginRes.code
-    });
-    console.log("[微信登录] 登录成功:", result);
-    setToken(result.data.token);
-    setUserInfo(result.data.userInfo);
-    common_vendor.index.showToast({
-      title: "登录成功",
-      icon: "success",
-      duration: 1500
-    });
-    if (successCallback) {
-      setTimeout(() => {
-        successCallback();
-      }, 1500);
+    console.log("[微信登录] ========== 开始登录 ==========");
+    console.log("[微信登录] 接收到的参数:");
+    console.log("  - code:", code);
+    console.log("  - phoneCode:", phoneCode);
+    if (!code) {
+      console.error("[微信登录] 错误:code为空!");
+      throw new Error("微信登录code为空,请重试");
+    }
+    if (!phoneCode) {
+      console.error("[微信登录] 错误:phoneCode为空!");
+      throw new Error("手机号授权code为空,请重试");
+    }
+    const loginParams = {
+      code,
+      // 微信登录code,后端用于获取 openid 和 unionid
+      phoneCode
+      // 手机号授权code,后端用于获取手机号、昵称、头像等
+    };
+    console.log("[微信登录] 准备发送到后端的参数:", JSON.stringify(loginParams));
+    const result = await utils_api.wxLogin(loginParams);
+    console.log("[微信登录] 后端响应:", result);
+    if (result.code === 200 && result.data && result.data.token) {
+      setToken(result.data.token);
+      if (result.data.userInfo) {
+        setUserInfo(result.data.userInfo);
+      }
+      console.log("[微信登录] 登录成功,token已保存");
+      common_vendor.index.showToast({
+        title: "登录成功",
+        icon: "success",
+        duration: 1500
+      });
+      return true;
+    } else {
+      console.error("[微信登录] 后端返回格式错误:", result);
+      throw new Error(result.message || "登录返回数据格式错误");
     }
-    return true;
   } catch (error) {
-    console.error("[微信登录] 登录失败:", error);
+    console.error("[微信登录] ========== 登录失败 ==========");
+    console.error("[微信登录] 错误详情:", error);
     common_vendor.index.showToast({
-      title: error.message || "登录失败",
+      title: error.message || "登录失败,请稍后重试",
       icon: "none",
       duration: 2e3
     });
-    if (failCallback) {
-      failCallback(error);
-    }
     return false;
   }
 };
@@ -70,24 +85,15 @@ const checkLogin = (callback) => {
   }
   common_vendor.index.showModal({
     title: "登录提示",
-    content: "此功能需要登录后使用,是否立即登录?",
-    confirmText: "立即登录",
-    cancelText: "暂不登录",
-    success: (res) => {
-      if (res.confirm) {
-        wxAuthLogin(callback);
-      }
-    }
+    content: '此功能需要登录后使用,请点击"立即登录"按钮进行授权',
+    showCancel: false,
+    confirmText: "我知道了"
   });
   return false;
 };
 exports.checkLogin = checkLogin;
-exports.getToken = getToken;
 exports.getUserInfo = getUserInfo;
 exports.isLoggedIn = isLoggedIn;
 exports.logout = logout;
-exports.removeToken = removeToken;
-exports.removeUserInfo = removeUserInfo;
-exports.setToken = setToken;
 exports.setUserInfo = setUserInfo;
 exports.wxAuthLogin = wxAuthLogin;

+ 146 - 8
src/pages/index/index.vue

@@ -20,7 +20,7 @@
               confirm-type="search"
               v-model="keyword"
               @input="onKeywordChange"
-              @confirm="onSearch"
+              @confirm="handleSearchClick"
               @blur="onInputBlur"
             />
             <!-- 搜索按钮(统一处理登录检查) -->
@@ -125,13 +125,30 @@
         <view class="bottom-safe-area"></view>
       </view>
     </scroll-view>
+    
+    <!-- 手机号授权弹窗 -->
+    <view v-if="showPhoneAuth" class="phone-auth-mask" @click="closePhoneAuth">
+      <view class="phone-auth-prompt" @click.stop>
+        <view class="auth-icon">📱</view>
+        <text class="auth-title">授权手机号</text>
+        <text class="auth-desc">为了完成登录,需要获取您的手机号</text>
+        
+        <button 
+          class="auth-button" 
+          open-type="getPhoneNumber" 
+          @getphonenumber="onGetPhoneNumber"
+        >
+          授权手机号
+        </button>
+      </view>
+    </view>
   </view>
 </template>
 
 <script setup>
 import { ref, onMounted } from 'vue'
 import { getSuggestions, searchStocks } from '../../utils/api.js'
-import { isLoggedIn as checkLoginStatus, checkLogin } from '../../utils/auth.js'
+import { isLoggedIn as checkLoginStatus, wxAuthLogin } from '../../utils/auth.js'
 
 // 引入 onShow 生命周期
 import { onShow } from '@dcloudio/uni-app'
@@ -144,6 +161,7 @@ const result = ref(null)
 const suggestions = ref([])
 const showDropdown = ref(false)
 const isLoggedIn = ref(false)
+const showPhoneAuth = ref(false)  // 是否显示手机号授权按钮
 let timer = null
 
 /**
@@ -166,17 +184,14 @@ onShow(() => {
 /**
  * 处理搜索按钮点击(统一登录校验UI)
  */
-const handleSearchClick = () => {
+const handleSearchClick = async () => {
   console.log('=== 点击搜索按钮 ===')
   console.log('当前登录状态:', isLoggedIn.value)
   
   // 检查登录状态
   if (!isLoggedIn.value) {
-    console.log('未登录,显示微信授权弹窗')
-    checkLogin(() => {
-      // 登录成功后执行搜索
-      onSearch()
-    })
+    console.log('未登录,直接调用微信授权')
+    handleLogin()
     return
   }
   
@@ -185,6 +200,64 @@ const handleSearchClick = () => {
   onSearch()
 }
 
+// 处理登录 - 直接显示手机号授权
+const handleLogin = () => {
+  console.log('[首页] 显示手机号授权弹窗')
+  showPhoneAuth.value = true
+}
+
+// 处理手机号授权并完成登录
+const onGetPhoneNumber = async (e) => {
+  console.log('[首页] 获取手机号回调:', e.detail)
+  
+  if (e.detail.errMsg === 'getPhoneNumber:ok') {
+    const phoneCode = e.detail.code
+    console.log('[首页] phoneCode:', phoneCode)
+    
+    uni.showLoading({
+      title: '登录中...',
+      mask: true
+    })
+    
+    try {
+      const loginRes = await uni.login()
+      console.log('[首页] uni.login完整响应:', loginRes)
+      console.log('[首页] 微信登录code:', loginRes.code)
+      
+      if (!loginRes.code) {
+        throw new Error('获取微信登录code失败')
+      }
+      
+      const result = await wxAuthLogin(loginRes.code, phoneCode)
+      
+      uni.hideLoading()
+      
+      if (result) {
+        showPhoneAuth.value = false
+        isLoggedIn.value = checkLoginStatus()
+        // 登录成功后执行搜索
+        onSearch()
+      }
+    } catch (error) {
+      uni.hideLoading()
+      console.error('[首页] 登录失败:', error)
+    }
+  } else {
+    showPhoneAuth.value = false
+    uni.showToast({
+      title: '需要授权手机号才能完成登录',
+      icon: 'none',
+      duration: 2000
+    })
+  }
+}
+
+// 关闭手机号授权弹窗
+const closePhoneAuth = () => {
+  showPhoneAuth.value = false
+  tempUserInfo.value = null
+}
+
 const onKeywordChange = (e) => {
   const value = e.detail.value
   keyword.value = value
@@ -620,4 +693,69 @@ const onInputBlur = () => {
 .bottom-safe-area {
   height: 80rpx;
 }
+
+/* 手机号授权弹窗 */
+.phone-auth-mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.6);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 9999;
+}
+
+.phone-auth-prompt {
+  width: 560rpx;
+  background: #ffffff;
+  border-radius: 24rpx;
+  padding: 50rpx 40rpx;
+  text-align: center;
+  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
+}
+
+.auth-icon {
+  font-size: 72rpx;
+  margin-bottom: 20rpx;
+}
+
+.auth-title {
+  display: block;
+  font-size: 32rpx;
+  font-weight: 600;
+  color: #222222;
+  margin-bottom: 12rpx;
+}
+
+.auth-desc {
+  display: block;
+  font-size: 24rpx;
+  color: #999999;
+  line-height: 1.5;
+  margin-bottom: 32rpx;
+}
+
+.auth-button {
+  width: 100%;
+  height: 80rpx;
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  color: #ffffff;
+  border-radius: 40rpx;
+  font-size: 30rpx;
+  font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+
+.auth-button::after {
+  border: none;
+}
 </style>

+ 97 - 22
src/pages/mine/mine.vue

@@ -49,11 +49,34 @@
 
     <!-- Login/Logout Button -->
     <view class="action-area">
-      <button class="main-btn" @click="toggleLogin">
-        {{ isLoggedIn ? '退出登录' : '登录' }}
+      <!-- 未登录且未开始授权 -->
+      <button 
+        v-if="!isLoggedIn && !showPhoneAuth"
+        class="main-btn" 
+        @click="handleLogin"
+      >
+        微信授权登录
+      </button>
+      
+      <!-- 未登录但已获取用户信息,等待手机号授权 -->
+      <button 
+        v-else-if="!isLoggedIn && showPhoneAuth"
+        class="main-btn phone-auth-btn" 
+        open-type="getPhoneNumber"
+        @getphonenumber="onGetPhoneNumber"
+      >
+        授权手机号
+      </button>
+      
+      <!-- 已登录 -->
+      <button 
+        v-else
+        class="main-btn" 
+        @click="handleLogout"
+      >
+        退出登录
       </button>
     </view>
-
   </view>
 </template>
 
@@ -63,6 +86,7 @@ import { onShow } from '@dcloudio/uni-app'
 import { isLoggedIn as checkLogin, getUserInfo as getStoredUserInfo, logout, checkLogin as requireLogin, wxAuthLogin } from '@/utils/auth.js'
 
 const isLoggedIn = ref(false)
+const showPhoneAuth = ref(false)  // 是否显示手机号授权按钮
 const userInfo = ref({
   nickname: '',
   avatar: '',
@@ -116,32 +140,77 @@ const handleEditProfile = () => {
 }
 
 /**
- * 切换登录状态
+ * 处理登录按钮点击 - 直接显示手机号授权
  */
-const toggleLogin = () => {
-  if (isLoggedIn.value) {
-    // 退出登录
-    uni.showModal({
-      title: '提示',
-      content: '确定要退出登录吗?',
-      success: (res) => {
-        if (res.confirm) {
-          logout()
-          isLoggedIn.value = false
-          userInfo.value = { nickname: '', avatar: '', phone: '' }
-          uni.showToast({ title: '已退出登录', icon: 'none' })
-        }
-      }
+const handleLogin = () => {
+  console.log('[我的] 显示手机号授权弹窗')
+  showPhoneAuth.value = true
+}
+
+/**
+ * 处理手机号授权并完成登录
+ */
+const onGetPhoneNumber = async (e) => {
+  console.log('[我的] 获取手机号回调:', e.detail)
+  
+  if (e.detail.errMsg === 'getPhoneNumber:ok') {
+    const phoneCode = e.detail.code
+    console.log('[我的] phoneCode:', phoneCode)
+    
+    uni.showLoading({
+      title: '登录中...',
+      mask: true
     })
+    
+    try {
+      const loginRes = await uni.login()
+      console.log('[我的] uni.login完整响应:', loginRes)
+      console.log('[我的] 微信登录code:', loginRes.code)
+      
+      if (!loginRes.code) {
+        throw new Error('获取微信登录code失败')
+      }
+      
+      const result = await wxAuthLogin(loginRes.code, phoneCode)
+      
+      uni.hideLoading()
+      
+      if (result) {
+        showPhoneAuth.value = false
+        loadUserInfo()
+      }
+    } catch (error) {
+      uni.hideLoading()
+      console.error('[我的] 登录失败:', error)
+    }
   } else {
-    // 使用微信授权登录
-    wxAuthLogin(() => {
-      // 登录成功后重新加载用户信息
-      loadUserInfo()
+    showPhoneAuth.value = false
+    uni.showToast({
+      title: '需要授权手机号才能完成登录',
+      icon: 'none',
+      duration: 2000
     })
   }
 }
 
+/**
+ * 退出登录
+ */
+const handleLogout = () => {
+  uni.showModal({
+    title: '提示',
+    content: '确定要退出登录吗?',
+    success: (res) => {
+      if (res.confirm) {
+        logout()
+        isLoggedIn.value = false
+        userInfo.value = { nickname: '', avatar: '', phone: '' }
+        uni.showToast({ title: '已退出登录', icon: 'none' })
+      }
+    }
+  })
+}
+
 /**
  * 处理充值按钮点击
  * 需要登录才能操作
@@ -349,4 +418,10 @@ const handleHistory = () => {
 .main-btn:active {
   opacity: 0.9;
 }
+
+.phone-auth-btn {
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  box-shadow: 0 12rpx 24rpx rgba(255, 152, 0, 0.4);
+}
+
 </style>

+ 138 - 3
src/pages/pool/pool.vue

@@ -78,6 +78,23 @@
       </view>
     </scroll-view>
 
+    <!-- 手机号授权弹窗 -->
+    <view v-if="showPhoneAuth" class="phone-auth-mask" @click="closePhoneAuth">
+      <view class="phone-auth-prompt" @click.stop>
+        <view class="auth-icon">📱</view>
+        <text class="auth-title">授权手机号</text>
+        <text class="auth-desc">为了完成登录,需要获取您的手机号</text>
+        
+        <button 
+          class="auth-button" 
+          open-type="getPhoneNumber" 
+          @getphonenumber="onGetPhoneNumber"
+        >
+          授权手机号
+        </button>
+      </view>
+    </view>
+
     <!-- 购买弹窗 -->
     <view v-if="showModal" class="modal-overlay" @click="closePurchaseModal">
       <view class="modal-content" @click.stop>
@@ -126,10 +143,11 @@
 <script setup>
 import { ref } from 'vue'
 import { onLoad, onShow } from '@dcloudio/uni-app'
-import { isLoggedIn as checkLoginStatus } from '../../utils/auth.js'
+import { isLoggedIn as checkLoginStatus, wxAuthLogin } from '../../utils/auth.js'
 
 const isPurchased = ref(false)
 const showModal = ref(false)
+const showPhoneAuth = ref(false)  // 是否显示手机号授权按钮
 const selectedPlan = ref('daily')
 const selectedDate = ref('2025年11月20日')
 const isLoggedIn = ref(false)
@@ -170,7 +188,8 @@ const showPurchaseModal = () => {
   
   // 检查登录状态
   if (!checkLogin()) {
-    console.log('未登录,显示微信授权弹窗')
+    console.log('未登录,显示手机号授权弹窗')
+    showPhoneAuth.value = true
     return
   }
   
@@ -178,6 +197,57 @@ const showPurchaseModal = () => {
   showModal.value = true
 }
 
+// 处理手机号授权并完成登录
+const onGetPhoneNumber = async (e) => {
+  console.log('[超短池] 获取手机号回调:', e.detail)
+  
+  if (e.detail.errMsg === 'getPhoneNumber:ok') {
+    const phoneCode = e.detail.code
+    console.log('[超短池] phoneCode:', phoneCode)
+    
+    uni.showLoading({
+      title: '登录中...',
+      mask: true
+    })
+    
+    try {
+      const loginRes = await uni.login()
+      console.log('[超短池] uni.login完整响应:', loginRes)
+      console.log('[超短池] 微信登录code:', loginRes.code)
+      
+      if (!loginRes.code) {
+        throw new Error('获取微信登录code失败')
+      }
+      
+      const result = await wxAuthLogin(loginRes.code, phoneCode)
+      
+      uni.hideLoading()
+      
+      if (result) {
+        showPhoneAuth.value = false
+        checkLogin()
+        // 登录成功后显示购买弹窗
+        showModal.value = true
+      }
+    } catch (error) {
+      uni.hideLoading()
+      console.error('[超短池] 登录失败:', error)
+    }
+  } else {
+    showPhoneAuth.value = false
+    uni.showToast({
+      title: '需要授权手机号才能完成登录',
+      icon: 'none',
+      duration: 2000
+    })
+  }
+}
+
+// 关闭手机号授权弹窗
+const closePhoneAuth = () => {
+  showPhoneAuth.value = false
+}
+
 // 关闭购买弹窗
 const closePurchaseModal = () => {
   showModal.value = false
@@ -601,4 +671,69 @@ onShow(() => {
 .bottom-safe-area {
   height: 80rpx;
 }
-</style>
+
+/* 手机号授权弹窗 */
+.phone-auth-mask {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: rgba(0, 0, 0, 0.6);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  z-index: 9999;
+}
+
+.phone-auth-prompt {
+  width: 560rpx;
+  background: #ffffff;
+  border-radius: 24rpx;
+  padding: 50rpx 40rpx;
+  text-align: center;
+  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
+}
+
+.auth-icon {
+  font-size: 72rpx;
+  margin-bottom: 20rpx;
+}
+
+.auth-title {
+  display: block;
+  font-size: 32rpx;
+  font-weight: 600;
+  color: #222222;
+  margin-bottom: 12rpx;
+}
+
+.auth-desc {
+  display: block;
+  font-size: 24rpx;
+  color: #999999;
+  line-height: 1.5;
+  margin-bottom: 32rpx;
+}
+
+.auth-button {
+  width: 100%;
+  height: 80rpx;
+  background: linear-gradient(135deg, #FF9800, #FFA726);
+  color: #ffffff;
+  border-radius: 40rpx;
+  font-size: 30rpx;
+  font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+
+.auth-button::after {
+  border: none;
+}
+</style>

+ 71 - 11
src/pages/rank/rank.vue

@@ -80,8 +80,17 @@
       <view class="login-prompt">
         <view class="lock-icon">🔒</view>
         <text class="prompt-title">登录后查看完整数据</text>
-        <text class="prompt-desc">登录后可查看您的模拟资产和完整排行榜</text>
-        <button class="login-button" @click="goToLogin">立即登录</button>
+        <text class="prompt-desc">使用微信授权快速登录</text>
+        
+        <!-- 微信授权登录按钮 -->
+        <button 
+          class="login-button-native" 
+          open-type="getPhoneNumber" 
+          @getphonenumber="onGetPhoneNumber"
+        >
+          <text class="button-icon">📱</text>
+          <text>微信授权登录</text>
+        </button>
       </view>
     </view>
   </view>
@@ -136,12 +145,49 @@ const getRankClass = (rank) => {
   return ''
 }
 
-// 跳转到登录页
-const goToLogin = () => {
-  wxAuthLogin(() => {
-    // 登录成功后重新检查登录状态并加载数据
-    checkLoginAndLoadData()
-  })
+// 处理手机号授权 - 静默登录
+const onGetPhoneNumber = async (e) => {
+  console.log('[模拟排名] 获取手机号回调:', e.detail)
+  
+  if (e.detail.errMsg === 'getPhoneNumber:ok') {
+    const phoneCode = e.detail.code
+    console.log('[模拟排名] phoneCode:', phoneCode)
+    
+    uni.showLoading({
+      title: '登录中...',
+      mask: true
+    })
+    
+    try {
+      // 获取微信登录code
+      const loginRes = await uni.login()
+      console.log('[模拟排名] uni.login完整响应:', loginRes)
+      console.log('[模拟排名] 微信登录code:', loginRes.code)
+      
+      if (!loginRes.code) {
+        throw new Error('获取微信登录code失败')
+      }
+      
+      // 调用后端登录接口(只传code和phoneCode)
+      const result = await wxAuthLogin(loginRes.code, phoneCode)      
+      uni.hideLoading()
+      
+      if (result) {
+        // 登录成功,重新加载数据
+        checkLoginAndLoadData()
+      }
+    } catch (error) {
+      uni.hideLoading()
+      console.error('[模拟排名] 登录失败:', error)
+    }
+  } else {
+    // 用户拒绝授权手机号
+    uni.showToast({
+      title: '需要授权手机号才能登录',
+      icon: 'none',
+      duration: 2000
+    })
+  }
 }
 
 // 检查登录状态并加载数据
@@ -473,15 +519,29 @@ onMounted(() => {
   margin-bottom: 32rpx;
 }
 
-.login-button {
+.login-button-native {
   width: 100%;
   height: 80rpx;
-  background: linear-gradient(135deg, #5d55e8, #7568ff);
+  background: linear-gradient(135deg, #4CAF50, #66BB6A);
   color: #ffffff;
   border-radius: 40rpx;
   font-size: 30rpx;
   font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(76, 175, 80, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+
+.login-button-native::after {
   border: none;
-  box-shadow: 0 8rpx 24rpx rgba(93, 85, 232, 0.4);
+}
+
+.button-icon {
+  font-size: 32rpx;
+  margin-right: 12rpx;
 }
 </style>

+ 72 - 15
src/pages/strong/strong.vue

@@ -96,8 +96,17 @@
       <view class="login-prompt">
         <view class="lock-icon">🔒</view>
         <text class="prompt-title">登录后进行模拟交易</text>
-        <text class="prompt-desc">登录后可进行模拟买卖操作,记录您的交易数据</text>
-        <button class="login-button" @click="goToLogin">立即登录</button>
+        <text class="prompt-desc">使用微信授权快速登录</text>
+        
+        <!-- 微信授权登录按钮 -->
+        <button 
+          class="login-button-native" 
+          open-type="getPhoneNumber" 
+          @getphonenumber="onGetPhoneNumber"
+        >
+          <text class="button-icon">📱</text>
+          <text>微信授权登录</text>
+        </button>
       </view>
     </view>
 
@@ -211,10 +220,6 @@ const stockList = ref([
 
 const selectedDate = ref('2025年11月20日')
 const showBuyModalFlag = ref(false)
-const showSellModalFlag = ref(false)
-const currentStock = ref({})
-const buyQuantity = ref('100')
-const sellQuantity = ref('100')
 
 // 检查登录状态
 const checkLogin = () => {
@@ -222,12 +227,50 @@ const checkLogin = () => {
   console.log('[强势池] 登录状态:', isLoggedIn.value)
 }
 
-// 跳转到登录页
-const goToLogin = () => {
-  wxAuthLogin(() => {
-    // 登录成功后重新检查登录状态
-    checkLogin()
-  })
+// 处理手机号授权 - 静默登录
+const onGetPhoneNumber = async (e) => {
+  console.log('[强势池] 获取手机号回调:', e.detail)
+  
+  if (e.detail.errMsg === 'getPhoneNumber:ok') {
+    const phoneCode = e.detail.code
+    console.log('[强势池] phoneCode:', phoneCode)
+    
+    uni.showLoading({
+      title: '登录中...',
+      mask: true
+    })
+    
+    try {
+      // 获取微信登录code
+      const loginRes = await uni.login()
+      console.log('[强势池] uni.login完整响应:', loginRes)
+      console.log('[强势池] 微信登录code:', loginRes.code)
+      
+      if (!loginRes.code) {
+        throw new Error('获取微信登录code失败')
+      }
+      
+      // 调用后端登录接口(只传code和phoneCode)
+      const result = await wxAuthLogin(loginRes.code, phoneCode)
+      
+      uni.hideLoading()
+      
+      if (result) {
+        // 登录成功,重新检查登录状态
+        checkLogin()
+      }
+    } catch (error) {
+      uni.hideLoading()
+      console.error('[强势池] 登录失败:', error)
+    }
+  } else {
+    // 用户拒绝授权手机号
+    uni.showToast({
+      title: '需要授权手机号才能登录',
+      icon: 'none',
+      duration: 2000
+    })
+  }
 }
 
 // 计算买入总金额
@@ -902,15 +945,29 @@ onShow(() => {
   margin-bottom: 32rpx;
 }
 
-.login-button {
+.login-button-native {
   width: 100%;
   height: 80rpx;
-  background: linear-gradient(135deg, #5d55e8, #7568ff);
+  background: linear-gradient(135deg, #4CAF50, #66BB6A);
   color: #ffffff;
   border-radius: 40rpx;
   font-size: 30rpx;
   font-weight: 600;
+  box-shadow: 0 8rpx 24rpx rgba(76, 175, 80, 0.4);
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+  line-height: 80rpx;
+}
+
+.login-button-native::after {
   border: none;
-  box-shadow: 0 8rpx 24rpx rgba(93, 85, 232, 0.4);
+}
+
+.button-icon {
+  font-size: 32rpx;
+  margin-right: 12rpx;
 }
 </style>

+ 18 - 7
src/utils/api.js

@@ -2,7 +2,18 @@
  * API请求工具类
  */
 
-const BASE_URL = 'http://localhost:8080'
+// 开发环境配置
+// 真机调试时,请将 DEV_BASE_URL 改为你电脑的局域网IP地址
+// 例如:const DEV_BASE_URL = 'http://192.168.1.3:8080'
+// 可以通过命令 ipconfig (Windows) 或 ifconfig (Mac/Linux) 查看IP地址
+const DEV_BASE_URL = 'http://192.168.1.3:8080'
+
+// 生产环境配置(部署后的服务器地址)
+const PROD_BASE_URL = 'https://your-domain.com'
+
+// 根据环境自动选择BASE_URL
+// 在微信开发者工具中使用 localhost,真机调试使用局域网IP
+const BASE_URL = DEV_BASE_URL
 
 /**
  * 获取本地存储的token(避免循环依赖)
@@ -50,14 +61,14 @@ const request = (options) => {
           setTimeout(() => {
             uni.showModal({
               title: '登录提示',
-              content: '登录已过期,是否重新登录?',
-              confirmText: '立即登录',
-              cancelText: '暂不登录',
+              content: '登录已过期,请前往"模拟排名"或"强势池"页面重新登录',
+              confirmText: '登录',
+              cancelText: '取消',
               success: (modalRes) => {
                 if (modalRes.confirm) {
-                  // 导入并调用微信授权登录
-                  import('./auth.js').then(auth => {
-                    auth.wxAuthLogin()
+                  // 跳转到模拟排名页面
+                  uni.switchTab({
+                    url: '/pages/rank/rank'
                   })
                 }
               }

+ 78 - 46
src/utils/auth.js

@@ -1,7 +1,11 @@
 /**
  * 认证工具类
  * 用于管理用户登录状态、token存储和登录检查
- * 使用微信自带弹窗登录
+ * 使用微信官方最新登录方式:
+ * 1. wx.login() 获取code
+ * 2. button open-type="chooseAvatar" 获取头像
+ * 3. input type="nickname" 获取昵称
+ * 4. button open-type="getPhoneNumber" 获取手机号
  */
 
 import { wxLogin } from './api.js'
@@ -73,61 +77,87 @@ export const logout = () => {
 }
 
 /**
- * 使用微信授权弹窗登录
- * @param {function} successCallback - 登录成功后的回调函数
- * @param {function} failCallback - 登录失败后的回调函数
+ * 微信静默登录
+ * 流程:
+ * 1. 用户点击授权手机号按钮
+ * 2. 调用 wx.login() 获取 code
+ * 3. 获取手机号授权 phoneCode
+ * 4. 将 code 和 phoneCode 发送到后端
+ * 5. 后端通过 code 获取 openid 和 unionid
+ * 6. 后端通过 phoneCode 获取手机号和用户信息(昵称、头像等)
+ * 7. 后端保存所有信息到数据库并返回 token
+ * 
+ * @param {string} code - 微信登录code(通过wx.login获取)
+ * @param {string} phoneCode - 手机号授权code(通过getPhoneNumber获取)
+ * @returns {Promise<boolean>} 登录是否成功
  */
-export const wxAuthLogin = async (successCallback, failCallback) => {
+export const wxAuthLogin = async (code, phoneCode) => {
   try {
-    // 1. 获取微信登录code
-    const loginRes = await uni.login()
-    console.log('[微信登录] 获取code成功:', loginRes.code)
+    console.log('[微信登录] ========== 开始登录 ==========')
+    console.log('[微信登录] 接收到的参数:')
+    console.log('  - code:', code)
+    console.log('  - phoneCode:', phoneCode)
     
-    // 2. 调用后端登录接口
-    const result = await wxLogin({
-      code: loginRes.code
-    })
+    // 验证必需参数
+    if (!code) {
+      console.error('[微信登录] 错误:code为空!')
+      throw new Error('微信登录code为空,请重试')
+    }
     
-    console.log('[微信登录] 登录成功:', result)
+    if (!phoneCode) {
+      console.error('[微信登录] 错误:phoneCode为空!')
+      throw new Error('手机号授权code为空,请重试')
+    }
     
-    // 3. 保存token和用户信息
-    setToken(result.data.token)
-    setUserInfo(result.data.userInfo)
+    // 构建请求参数
+    const loginParams = {
+      code: code,              // 微信登录code,后端用于获取 openid 和 unionid
+      phoneCode: phoneCode     // 手机号授权code,后端用于获取手机号、昵称、头像等
+    }
+    console.log('[微信登录] 准备发送到后端的参数:', JSON.stringify(loginParams))
     
-    // 4. 显示成功提示
-    uni.showToast({
-      title: '登录成功',
-      icon: 'success',
-      duration: 1500
-    })
+    // 调用后端登录接口
+    const result = await wxLogin(loginParams)
     
-    // 5. 执行成功回调
-    if (successCallback) {
-      setTimeout(() => {
-        successCallback()
-      }, 1500)
-    }
+    console.log('[微信登录] 后端响应:', result)
     
-    return true
+    // 保存token和用户信息
+    if (result.code === 200 && result.data && result.data.token) {
+      setToken(result.data.token)
+      if (result.data.userInfo) {
+        setUserInfo(result.data.userInfo)
+      }
+      
+      console.log('[微信登录] 登录成功,token已保存')
+      
+      // 显示成功提示
+      uni.showToast({
+        title: '登录成功',
+        icon: 'success',
+        duration: 1500
+      })
+      
+      return true
+    } else {
+      console.error('[微信登录] 后端返回格式错误:', result)
+      throw new Error(result.message || '登录返回数据格式错误')
+    }
   } catch (error) {
-    console.error('[微信登录] 登录失败:', error)
+    console.error('[微信登录] ========== 登录失败 ==========')
+    console.error('[微信登录] 错误详情:', error)
     
     uni.showToast({
-      title: error.message || '登录失败',
+      title: error.message || '登录失败,请稍后重试',
       icon: 'none',
       duration: 2000
     })
     
-    if (failCallback) {
-      failCallback(error)
-    }
-    
     return false
   }
 }
 
 /**
- * 检查登录状态,未登录则显示微信授权弹窗
+ * 检查登录状态,未登录则提示用户登录
  * @param {function} callback - 登录成功后的回调函数
  * @returns {boolean} 是否已登录
  */
@@ -136,19 +166,21 @@ export const checkLogin = (callback) => {
     return true
   }
   
-  // 未登录,显示微信授权弹窗
+  // 未登录,提示用户需要登录
   uni.showModal({
     title: '登录提示',
-    content: '此功能需要登录后使用,是否立即登录?',
-    confirmText: '立即登录',
-    cancelText: '暂不登录',
-    success: (res) => {
-      if (res.confirm) {
-        // 用户点击确认,执行微信登录
-        wxAuthLogin(callback)
-      }
-    }
+    content: '此功能需要登录后使用,请点击"立即登录"按钮进行授权',
+    showCancel: false,
+    confirmText: '我知道了'
   })
   
   return false
 }
+
+/**
+ * 显示需要登录的提示(用于页面遮罩层)
+ * 返回一个标识,表示是否需要显示登录按钮
+ */
+export const needLogin = () => {
+  return !isLoggedIn()
+}

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio