This commit is contained in:
pengxiaolong
2025-06-24 13:23:49 +08:00
parent 36a240f854
commit 60a14aca83
9 changed files with 51 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
<button class="login-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
使用微信登录
</button>
<view class="return" @click="Return">返回首页</view>
</view>
</template>
@@ -45,8 +46,21 @@ export default {
},
methods: {
// 返回首页
Return() {
uni.reLaunch({
url: "/pages/Home/Home",
});
},
// 获取手机号
async getPhoneNumber(e) {
if (e.detail.code == undefined) {
uni.showToast({
title: "登录失败",
icon: "none",
});
return;
}
uni.showLoading({
title: "登录中...",
mask: true,
@@ -141,4 +155,12 @@ export default {
font-size: 24rpx;
margin-top: 40rpx;
}
.return{
margin-top: 30rpx;
width: 300rpx;
height: 100rpx;
color: rgb(255, 255, 255);
text-align: center;
line-height: 100rpx;
}
</style>

View File

@@ -1 +1 @@
"use strict";const e=require("../../common/vendor.js"),i=require("../../components/request.js"),t=require("../../components/debug/GenerateTestUserSig.js"),n=require("../../components/TUILogin.js"),s=require("../../stores/counter.js").useCounterStore(),o={inject:["$global"],data:()=>({userInfo:{},info:{},userSig:"",lastPage:"",myuserSig:""}),onLoad(){e.index.getUserInfo({provider:"weixin",success:e=>{this.userInfo=e.userInfo}}),e.index.getStorage({key:"lastPage",success:e=>{this.lastPage="/"+e.data},fail:()=>{this.lastPage="/pages/Home/Home"}})},methods:{async getPhoneNumber(o){e.index.showLoading({title:"登录中...",mask:!0});const a=await i.request({url:"user/loginWithPhoneNumber",method:"POST",data:{code:o.detail.code},userInfo:!1});this.info=a;const r=Number(this.info.data.chatInfo.appId);this.userSig=t.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:"administrator"}),this.myuserSig=t.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:String(a.data.info.id)}),e.index.setStorageSync("myuserSig",this.myuserSig),e.index.setStorageSync("chatInfo",this.info.data.chatInfo),e.index.setStorageSync("userSig",this.userSig),e.index.setStorageSync("userinfo",this.info.data.info),s.$patch({myitem:this.info.data.info}),200===this.info.code?this.info.data.newAccount?(e.index.reLaunch({url:"/pages/UserInformation/UserInformation"}),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading()):(e.index.setStorageSync("userinfo",this.info.data.info),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading(),e.index.reLaunch({url:this.lastPage})):e.index.showToast({title:"登录失败",icon:"none"})}}};const a=e._export_sfc(o,[["render",function(i,t,n,s,o,a){return{a:o.userInfo.avatarUrl,b:e.t(o.userInfo.nickName),c:e.o$1(((...e)=>a.getPhoneNumber&&a.getPhoneNumber(...e)))}}]]);wx.createPage(a);
"use strict";const e=require("../../common/vendor.js"),t=require("../../components/request.js"),i=require("../../components/debug/GenerateTestUserSig.js"),n=require("../../components/TUILogin.js"),o=require("../../stores/counter.js").useCounterStore(),s={inject:["$global"],data:()=>({userInfo:{},info:{},userSig:"",lastPage:"",myuserSig:""}),onLoad(){e.index.getUserInfo({provider:"weixin",success:e=>{this.userInfo=e.userInfo}}),e.index.getStorage({key:"lastPage",success:e=>{this.lastPage="/"+e.data},fail:()=>{this.lastPage="/pages/Home/Home"}})},methods:{Return(){e.index.reLaunch({url:"/pages/Home/Home"})},async getPhoneNumber(s){if(null==s.detail.code)return void e.index.showToast({title:"登录失败",icon:"none"});e.index.showLoading({title:"登录中...",mask:!0});const a=await t.request({url:"user/loginWithPhoneNumber",method:"POST",data:{code:s.detail.code},userInfo:!1});this.info=a;const r=Number(this.info.data.chatInfo.appId);this.userSig=i.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:"administrator"}),this.myuserSig=i.genTestUserSig({SDKAPPID:r,SECRETKEY:this.info.data.chatInfo.appKey,userID:String(a.data.info.id)}),e.index.setStorageSync("myuserSig",this.myuserSig),e.index.setStorageSync("chatInfo",this.info.data.chatInfo),e.index.setStorageSync("userSig",this.userSig),e.index.setStorageSync("userinfo",this.info.data.info),o.$patch({myitem:this.info.data.info}),200===this.info.code?this.info.data.newAccount?(e.index.reLaunch({url:"/pages/UserInformation/UserInformation"}),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading()):(e.index.setStorageSync("userinfo",this.info.data.info),n.TUIlogin(this.info.data.chatInfo.appId,this.info.data.info.id,this.myuserSig.userSig),e.index.hideLoading(),e.index.reLaunch({url:this.lastPage})):e.index.showToast({title:"登录失败",icon:"none"})}}};const a=e._export_sfc(s,[["render",function(t,i,n,o,s,a){return{a:s.userInfo.avatarUrl,b:e.t(s.userInfo.nickName),c:e.o$1(((...e)=>a.getPhoneNumber&&a.getPhoneNumber(...e))),d:e.o$1(((...e)=>a.Return&&a.Return(...e)))}}]]);wx.createPage(a);

View File

@@ -1 +1 @@
<view class="container"><image class="logo" src="{{a}}"></image><view class="nickname">{{b}}</view><button class="login-btn" open-type="getPhoneNumber" bindgetphonenumber="{{c}}"> 使用微信登录 </button></view>
<view class="container"><image class="logo" src="{{a}}"></image><view class="nickname">{{b}}</view><button class="login-btn" open-type="getPhoneNumber" bindgetphonenumber="{{c}}"> 使用微信登录 </button><view class="return" bindtap="{{d}}">返回首页</view></view>

View File

@@ -1 +1 @@
.container{width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:linear-gradient(to bottom,rgba(17,203,42,.43),rgba(37,116,252,.427))}.logo{width:200rpx;height:200rpx;border-radius:50%}.nickname{width:300rpx;height:100rpx;color:#fff;border-radius:0;padding:20rpx 40rpx;font-size:30rpx;text-align:center;line-height:100rpx}.login-btn{background-color:rgba(255,255,255,0);border:1px solid #00ff0000;color:#fff}.tips{color:#666;font-size:24rpx;margin-top:40rpx}
.container{width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:linear-gradient(to bottom,rgba(17,203,42,.43),rgba(37,116,252,.427))}.logo{width:200rpx;height:200rpx;border-radius:50%}.nickname{width:300rpx;height:100rpx;color:#fff;border-radius:0;padding:20rpx 40rpx;font-size:30rpx;text-align:center;line-height:100rpx}.login-btn{background-color:rgba(255,255,255,0);border:1px solid #00ff0000;color:#fff}.tips{color:#666;font-size:24rpx;margin-top:40rpx}.return{margin-top:30rpx;width:300rpx;height:100rpx;color:#fff;text-align:center;line-height:100rpx}

File diff suppressed because one or more lines are too long

View File

@@ -8012,7 +8012,7 @@ function isConsoleWritable() {
function initRuntimeSocketService() {
const hosts = "192.168.1.112,127.0.0.1";
const port = "8090";
const id = "mp-weixin_pcSXnJ";
const id = "mp-weixin_UBq38n";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();

View File

@@ -34,8 +34,21 @@ const _sfc_main = {
});
},
methods: {
// 返回首页
Return() {
common_vendor.index.reLaunch({
url: "/pages/Home/Home"
});
},
// 获取手机号
async getPhoneNumber(e) {
if (e.detail.code == void 0) {
common_vendor.index.showToast({
title: "登录失败",
icon: "none"
});
return;
}
common_vendor.index.showLoading({
title: "登录中...",
mask: true
@@ -94,7 +107,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.userInfo.avatarUrl,
b: common_vendor.t($data.userInfo.nickName),
c: common_vendor.o$1((...args) => $options.getPhoneNumber && $options.getPhoneNumber(...args))
c: common_vendor.o$1((...args) => $options.getPhoneNumber && $options.getPhoneNumber(...args)),
d: common_vendor.o$1((...args) => $options.Return && $options.Return(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);

View File

@@ -1 +1 @@
<view class="container"><image class="logo" src="{{a}}"></image><view class="nickname">{{b}}</view><button class="login-btn" open-type="getPhoneNumber" bindgetphonenumber="{{c}}"> 使用微信登录 </button></view>
<view class="container"><image class="logo" src="{{a}}"></image><view class="nickname">{{b}}</view><button class="login-btn" open-type="getPhoneNumber" bindgetphonenumber="{{c}}"> 使用微信登录 </button><view class="return" bindtap="{{d}}">返回首页</view></view>

View File

@@ -33,3 +33,11 @@
font-size: 24rpx;
margin-top: 40rpx;
}
.return{
margin-top: 30rpx;
width: 300rpx;
height: 100rpx;
color: rgb(255, 255, 255);
text-align: center;
line-height: 100rpx;
}