feat:微信登录

This commit is contained in:
2025-09-25 15:40:53 +08:00
parent a22b987ed9
commit fa8c41a4f7
7 changed files with 665 additions and 555 deletions
+2 -1
View File
@@ -7,7 +7,8 @@
// #ifdef APP-PLUS          // #ifdef APP-PLUS         
// 获取应用版本信息 // 获取应用版本信息
plus.runtime.getProperty(plus.runtime.appid, function(inf) { plus.runtime.getProperty(plus.runtime.appid, function(inf) {
uni.setStorageSync('version', inf.version); // 大版本号 console.log("版本信息",inf.versionCode)
uni.setStorageSync('version-1', inf.version); // 大版本号
uni.setStorageSync('versionCode', inf.versionCode); // 小版本号 uni.setStorageSync('versionCode', inf.versionCode); // 小版本号
}); });
let uuid = plus.device.uuid; let uuid = plus.device.uuid;
+2 -1
View File
@@ -313,6 +313,7 @@ export default {
terminal: self.platformType, terminal: self.platformType,
versionCode: localAppVerson, versionCode: localAppVerson,
} }
console.log("wgt更新-0", params)
checkAppVersion(params).then(res => { checkAppVersion(params).then(res => {
console.log("wgt更新-1", res) console.log("wgt更新-1", res)
if (res && res.bizcode === 100) { if (res && res.bizcode === 100) {
@@ -482,7 +483,7 @@ export default {
}, },
computed: { computed: {
isBlockedDate() { isBlockedDate() {
return !useTabber(8); return !useTabber(10);
} }
} }
+18 -4
View File
@@ -62,7 +62,7 @@
<script> <script>
import { SMS_TYPE } from "@/utils/enumUtils.js"; import { SMS_TYPE } from "@/utils/enumUtils.js";
import { getUserList } from "@/api/common.js"; import { getUserList } from "@/api/common.js";
import { wechatLogin,alipayLogin } from "@/api/auth.js"; import { wechatLogin, alipayLogin } from "@/api/auth.js";
import { import {
setStorageFun, setStorageFun,
TOKEN_NAME, TOKEN_NAME,
@@ -96,7 +96,7 @@ export default {
onLoad(option) { onLoad(option) {
this.form.token = option.token; this.form.token = option.token;
this.type = option.type; this.type = option.type;
console.log("-----1", option, this.form.token, this.type ); console.log("-----1", option, this.form.token, this.type);
}, },
methods: { methods: {
jumpMine() { jumpMine() {
@@ -129,7 +129,8 @@ export default {
isValid: true, isValid: true,
token: form.token, token: form.token,
}; };
const response = this.type == 1 ? await wechatLogin(params) : await alipayLogin(params); const response =
this.type == 1 ? await wechatLogin(params) : await alipayLogin(params);
console.log("微信登录接口返回:", params, response); console.log("微信登录接口返回:", params, response);
if (response && response.bizcode === 100) { if (response && response.bizcode === 100) {
const data = response.data; const data = response.data;
@@ -147,6 +148,19 @@ export default {
// 当前登录得时间戳 // 当前登录得时间戳
let currentTimeStamp = new Date().getTime(); let currentTimeStamp = new Date().getTime();
setStorageFun(USER_LOGIN_TIME, currentTimeStamp); setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
const res = uni.getSystemInfoSync();
uni.setStorageSync("platform", res.platform);
// #ifdef APP-PLUS
// 获取应用版本信息
plus.runtime.getProperty(plus.runtime.appid, function (inf) {
console.log("版本信息", inf.versionCode);
uni.setStorageSync("version-1", inf.version); // 大版本号
uni.setStorageSync("versionCode", inf.versionCode); // 小版本号
});
let uuid = plus.device.uuid;
// #endif
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: "success", type: "success",
message: response.msg, message: response.msg,
@@ -176,7 +190,7 @@ export default {
const params = { const params = {
mobile: form.mobile, mobile: form.mobile,
type:this.type == 1 ? SMS_TYPE.WECHAT : SMS_TYPE.ALIPAY, type: this.type == 1 ? SMS_TYPE.WECHAT : SMS_TYPE.ALIPAY,
}; };
const response = await getUserList(params); const response = await getUserList(params);
if (response && response.bizcode === 100) { if (response && response.bizcode === 100) {
+151 -64
View File
@@ -2,7 +2,13 @@
<view class="login_warp"> <view class="login_warp">
<view class="login_logo_warp"> <view class="login_logo_warp">
<view style="text-align: center"> <view style="text-align: center">
<up-image src="/static/logo.png" width="90" height="118" bgColor="#f1f6ff00" radius="10"></up-image> <up-image
src="/static/logo.png"
width="90"
height="118"
bgColor="#f1f6ff00"
radius="10"
></up-image>
</view> </view>
<!-- <view style="margin-top: 20rpx;"> <!-- <view style="margin-top: 20rpx;">
<up-image src="/static/logo_z.png" width="100" height="40" bgColor="#f1f6ff00"></up-image> <up-image src="/static/logo_z.png" width="100" height="40" bgColor="#f1f6ff00"></up-image>
@@ -10,27 +16,59 @@
</view> </view>
<view class="login_info"> <view class="login_info">
<view class="login_info_item"> <view class="login_info_item">
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss" <up-input
@change="checkNameParam"></up-input> placeholder="请输入手机号/账户名称"
border="surround"
v-model="form.name"
:customStyle="inputCss"
@change="checkNameParam"
></up-input>
</view> </view>
<!-- 密码登录 --> <!-- 密码登录 -->
<view class="login_info_item" v-if="loginWay === 'password'"> <view class="login_info_item" v-if="loginWay === 'password'">
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss" <up-input
:type="isShow ? 'text' : 'password'" @change="checkParam"> placeholder="请输入密码"
border="surround"
v-model="form.password"
:customStyle="inputCss"
:type="isShow ? 'text' : 'password'"
@change="checkParam"
>
<template #suffix style="margin-right: 10rpx"> <template #suffix style="margin-right: 10rpx">
<up-image v-if="isShow" src="/static/login/show.png" width="20" height="20" bgColor="#f1f6ff00" <up-image
@click="isShow = false"></up-image> v-if="isShow"
<up-image v-else src="/static/login/hidden.png" width="20" height="20" bgColor="#f1f6ff00" src="/static/login/show.png"
@click="isShow = true"></up-image> width="20"
height="20"
bgColor="#f1f6ff00"
@click="isShow = false"
></up-image>
<up-image
v-else
src="/static/login/hidden.png"
width="20"
height="20"
bgColor="#f1f6ff00"
@click="isShow = true"
></up-image>
</template> </template>
</up-input> </up-input>
</view> </view>
<!-- 验证码登录 --> <!-- 验证码登录 -->
<view class="login_info_item" v-else> <view class="login_info_item" v-else>
<up-input placeholder="请输入验证码" border="surround" v-model="form.code" :customStyle="inputCss"> <up-input
placeholder="请输入验证码"
border="surround"
v-model="form.code"
:customStyle="inputCss"
>
<template #suffix style="margin-right: 10rpx"> <template #suffix style="margin-right: 10rpx">
<view v-if="countdown" class="code-warp"> <view v-if="countdown" class="code-warp">
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down> <up-count-down
:time="60 * 1000"
format="ss"
@finish="countdown = false"
></up-count-down>
<text style="margin-left: 10rpx">s</text> <text style="margin-left: 10rpx">s</text>
</view> </view>
<view v-else @click="getMobileCode" class="code_msg"> <view v-else @click="getMobileCode" class="code_msg">
@@ -44,8 +82,12 @@
<text style="margin-left: 10rpx">登录</text> <text style="margin-left: 10rpx">登录</text>
</view> </view>
<view class="cut_way_warp"> <view class="cut_way_warp">
<view v-if="loginWay === 'password'" @click="loginWay = 'code'">验证码登录</view> <view v-if="loginWay === 'password'" @click="loginWay = 'code'"
<view v-if="loginWay === 'code'" @click="loginWay = 'password'">密码登录登录</view> >验证码登录</view
>
<view v-if="loginWay === 'code'" @click="loginWay = 'password'"
>密码登录登录</view
>
<view @click="jumpForgot">忘记密码</view> <view @click="jumpForgot">忘记密码</view>
<view @click="jumpRegister">注册</view> <view @click="jumpRegister">注册</view>
</view> </view>
@@ -54,25 +96,48 @@
<view class="other_login">其他登录方式</view> <view class="other_login">其他登录方式</view>
<view class="login_other_icon"> <view class="login_other_icon">
<view class="login_other_item" @click="wechatOneLogin"> <view class="login_other_item" @click="wechatOneLogin">
<up-image src="/static/login/WXICON.png" width="44" height="44" bgColor="#f1f6ff00"></up-image> <up-image
src="/static/login/WXICON.png"
width="44"
height="44"
bgColor="#f1f6ff00"
></up-image>
微信登录 微信登录
</view> </view>
<view class="login_other_item" @click="alipayOneLogin"> <view class="login_other_item" @click="alipayOneLogin">
<up-image src="/static/login/ZFB.png" width="44" height="44" bgColor="#f1f6ff00"></up-image> <up-image
src="/static/login/ZFB.png"
width="44"
height="44"
bgColor="#f1f6ff00"
></up-image>
支付宝登录 支付宝登录
</view> </view>
</view> </view>
</view> </view>
<view class="policy_warp"> <view class="policy_warp">
<up-checkbox name="isCheck" usedAlone v-model:checked="isPolicy" shape="circle" activeColor="#7934F6" <up-checkbox
size="19" iconSize="18"> name="isCheck"
usedAlone
v-model:checked="isPolicy"
shape="circle"
activeColor="#7934F6"
size="19"
iconSize="18"
>
<template #label> <template #label>
<text>已阅读并同意</text> <text>已阅读并同意</text>
<text class="policy_a_warp" @click="jumpUserAgreement">《服务协议》</text> <text class="policy_a_warp" @click="jumpUserAgreement"
>《服务协议》</text
>
<text>、</text> <text>、</text>
<text class="policy_a_warp" @click="jumpPrivacyAgreement">《隐私政策》</text> <text class="policy_a_warp" @click="jumpPrivacyAgreement"
>《隐私政策》</text
>
<text>、</text> <text>、</text>
<text class="policy_a_warp" @click="jumpProductAgreement">《售后保障协议》</text> <text class="policy_a_warp" @click="jumpProductAgreement"
>《售后保障协议》</text
>
</template> </template>
</up-checkbox> </up-checkbox>
</view> </view>
@@ -81,33 +146,38 @@
</template> </template>
<script> <script>
import InputCodeComm from "@/components/code-comm/code-comm.vue"; import InputCodeComm from "@/components/code-comm/code-comm.vue";
import { import { SMS_TYPE } from "@/utils/enumUtils.js";
SMS_TYPE import { getUserList } from "@/api/common.js";
} from "@/utils/enumUtils.js"; import { loginbysms, loginbypw, wechatLogin, alipayLogin } from "@/api/auth.js";
import { import {
getUserList
} from "@/api/common.js";
import {
loginbysms,
loginbypw,
wechatLogin,
alipayLogin
} from "@/api/auth.js";
import {
setStorageFun, setStorageFun,
TOKEN_NAME, TOKEN_NAME,
USER_KEY, USER_KEY,
USER_DATA, USER_DATA,
USER_LOGIN_TIME, USER_LOGIN_TIME,
} from "@/utils/auth.js"; } from "@/utils/auth.js";
import CryptoJS from "crypto-js"; import CryptoJS from "crypto-js";
// #ifdef APP-PLUS
const hyyAlipay = uni.requireNativePlugin("Hyy-Alipay");
// #endif
export default {
onLaunch: function () {
console.log("App Launch");
const res = uni.getSystemInfoSync();
uni.setStorageSync("platform", res.platform);
// #ifdef APP-PLUS // #ifdef APP-PLUS
const hyyAlipay = uni.requireNativePlugin("Hyy-Alipay"); // 获取应用版本信息
plus.runtime.getProperty(plus.runtime.appid, function (inf) {
console.log("版本信息", inf.versionCode);
uni.setStorageSync("version-1", inf.version); // 大版本号
uni.setStorageSync("versionCode", inf.versionCode); // 小版本号
});
let uuid = plus.device.uuid;
// #endif // #endif
},
export default {
components: { components: {
InputCodeComm, InputCodeComm,
}, },
@@ -183,6 +253,19 @@
// 当前登录得时间戳 // 当前登录得时间戳
let currentTimeStamp = new Date().getTime(); let currentTimeStamp = new Date().getTime();
setStorageFun(USER_LOGIN_TIME, currentTimeStamp); setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
const res = uni.getSystemInfoSync();
uni.setStorageSync('platform', res.platform);
// #ifdef APP-PLUS         
// 获取应用版本信息
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
console.log("版本信息",inf.versionCode)
uni.setStorageSync('version-1', inf.version); // 大版本号
uni.setStorageSync('versionCode', inf.versionCode); // 小版本号
});
let uuid = plus.device.uuid;
// #endif
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: "success", type: "success",
message: response.msg, message: response.msg,
@@ -288,10 +371,15 @@
console.log("微信登录接口返回-1:", params); console.log("微信登录接口返回-1:", params);
const response = await wechatLogin(params); const response = await wechatLogin(params);
console.log("微信登录接口返回-2:", response, response.data, response.data.token); console.log(
"微信登录接口返回-2:",
response,
response.data,
response.data.token
);
if (response && response.bizcode === 100) { if (response && response.bizcode === 100) {
if (response.data.userId !== null) { if (response.data.userId) {
// 登录 // 登录
this.loginWay = "wechat"; this.loginWay = "wechat";
this.loginFun(response); this.loginFun(response);
@@ -301,7 +389,6 @@
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=1`, url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=1`,
}); });
} }
} else { } else {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: "error", type: "error",
@@ -344,7 +431,8 @@
return; return;
} }
hyyAlipay.openAuthScheme({ hyyAlipay.openAuthScheme(
{
appId: "2021005183625053", // 支付宝分配给开发者的应用 ID appId: "2021005183625053", // 支付宝分配给开发者的应用 ID
scheme: "trustbridgeapp", // manifest.json -> "App常用其他设置" -> "UrlSchemes"里设置 scheme: "trustbridgeapp", // manifest.json -> "App常用其他设置" -> "UrlSchemes"里设置
}, },
@@ -354,9 +442,9 @@
isValid: false, isValid: false,
token: res.auth_code, token: res.auth_code,
}).then((response) => { }).then((response) => {
console.log("支付宝登录接口返回:", response,response.data.userId !== null); console.log("支付宝登录接口返回:", response, !response.data.userId);
if (response && response.bizcode === 100) { if (response && response.bizcode === 100) {
if (response.data.userId !== null) { if (response.data.userId) {
// 登录 // 登录
this.loginWay = "alipay"; this.loginWay = "alipay";
this.loginFun(response); this.loginFun(response);
@@ -366,7 +454,6 @@
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=2`, url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=2`,
}); });
} }
} else { } else {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: "error", type: "error",
@@ -385,22 +472,22 @@
// #endif // #endif
return false; return false;
}, },
} },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.login_warp { .login_warp {
height: calc(100vh - 400rpx); height: calc(100vh - 400rpx);
padding: 150rpx 50rpx 0; padding: 150rpx 50rpx 0;
} }
.login_logo_warp { .login_logo_warp {
display: grid; display: grid;
justify-content: center; justify-content: center;
} }
.login_info { .login_info {
margin-top: 60rpx; margin-top: 60rpx;
.login_info_item { .login_info_item {
@@ -411,9 +498,9 @@
font-size: 36rpx; font-size: 36rpx;
color: $app-bt-bj; color: $app-bt-bj;
} }
} }
.login_comm_but { .login_comm_but {
background: #cccccc; background: #cccccc;
border-radius: 20rpx; border-radius: 20rpx;
width: 100%; width: 100%;
@@ -424,31 +511,31 @@
padding: 28rpx 0; padding: 28rpx 0;
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.login_comm_but_yes { .login_comm_but_yes {
background: $app-bt-bj; background: $app-bt-bj;
color: #ffffff; color: #ffffff;
} }
.cut_way_warp { .cut_way_warp {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-weight: 500; font-weight: 500;
font-size: 28rpx; font-size: 28rpx;
color: #999999; color: #999999;
margin-top: 20rpx; margin-top: 20rpx;
} }
.other_login { .other_login {
font-size: 28rpx; font-size: 28rpx;
text-align: center; text-align: center;
margin-top: 80rpx; margin-top: 80rpx;
margin-bottom: 32rpx; margin-bottom: 32rpx;
color: #999999; color: #999999;
} }
.login_other_icon { .login_other_icon {
display: flex; display: flex;
padding: 0 100rpx; padding: 0 100rpx;
justify-content: center; justify-content: center;
@@ -461,5 +548,5 @@
align-items: center; align-items: center;
margin-bottom: 80rpx; margin-bottom: 80rpx;
} }
} }
</style> </style>
+1 -1
View File
@@ -54,7 +54,7 @@ export default {
async getSearchList(){ async getSearchList(){
const params = { const params = {
page: 1, page: 1,
pageSize: 10000, pageSize: 99,
categoryId:this.id categoryId:this.id
} }
const resp = await searchList(params); const resp = await searchList(params);
+1 -1
View File
@@ -88,7 +88,7 @@ export default {
const params = { const params = {
type: 2, type: 2,
page: 1, page: 1,
pageSize: 10000, pageSize: 99,
isPar: true, isPar: true,
}; };
if(this.curTab != 0){ if(this.curTab != 0){
+14 -7
View File
@@ -1,5 +1,11 @@
import { getStorageFun, TOKEN_NAME } from "./auth.js"; import {
import { BASE_URL, Authorization } from "@/utils/config.js"; getStorageFun,
TOKEN_NAME
} from "./auth.js";
import {
BASE_URL,
Authorization
} from "@/utils/config.js";
// utils/http.js (修改后的版本) // utils/http.js (修改后的版本)
// const baseUrl = 'http://192.168.0.108:8087'; // const baseUrl = 'http://192.168.0.108:8087';
@@ -18,9 +24,9 @@ function request(options) {
let defaultHeaders = { let defaultHeaders = {
Authorization: Authorization, Authorization: Authorization,
"HSM-AUTH": token ? token : "", // 如果存在token, 则添加到请求头中 "HSM-AUTH": token ? token : "", // 如果存在token, 则添加到请求头中
"content-type": ["post", "POST"].includes(method) "content-type": ["post", "POST"].includes(method) ?
? "application/x-www-form-urlencoded" "application/x-www-form-urlencoded" :
: "application/json", "application/json",
}; };
if (options.cha) { if (options.cha) {
defaultHeaders["content-type"] = "application/json"; defaultHeaders["content-type"] = "application/json";
@@ -46,7 +52,6 @@ function request(options) {
...headers, // 使用展开运算符合并默认头和自定义头 ...headers, // 使用展开运算符合并默认头和自定义头
}, },
success: (res) => { success: (res) => {
console.log('--success-',res)
if (isShowLoading) { if (isShowLoading) {
// 请求之前做一些事 // 请求之前做一些事
uni.hideToast(); uni.hideToast();
@@ -66,7 +71,7 @@ function request(options) {
return; return;
} }
// 601 微信登录没注册 // 601 微信登录没注册
if (data.bizcode === 100 ) { if (data.bizcode === 100) {
resolve(data); // 成功时返回数据 resolve(data); // 成功时返回数据
} else if (data.bizcode === 201) { } else if (data.bizcode === 201) {
if ([201, 200].includes(data.errcode)) { if ([201, 200].includes(data.errcode)) {
@@ -98,6 +103,7 @@ function request(options) {
}, 2000); }, 2000);
} }
} else { } else {
console.log("错误-1",data, url)
uni.showToast({ uni.showToast({
title: data.msg || "系统错误,请稍后再试", title: data.msg || "系统错误,请稍后再试",
icon: "none", // 可选 success/loading/none icon: "none", // 可选 success/loading/none
@@ -107,6 +113,7 @@ function request(options) {
} }
}, },
fail: (error) => { fail: (error) => {
console.log("错误-2", url)
if (isShowLoading) { if (isShowLoading) {
// 请求之前做一些事 // 请求之前做一些事
uni.hideToast(); uni.hideToast();