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