feat:微信登录
This commit is contained in:
@@ -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
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
+515
-428
@@ -1,465 +1,552 @@
|
|||||||
<template>
|
<template>
|
||||||
<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
|
||||||
</view>
|
src="/static/logo.png"
|
||||||
<!-- <view style="margin-top: 20rpx;">
|
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>
|
<up-image src="/static/logo_z.png" width="100" height="40" bgColor="#f1f6ff00"></up-image>
|
||||||
</view> -->
|
</view> -->
|
||||||
</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="请输入手机号/账户名称"
|
||||||
</view>
|
border="surround"
|
||||||
<!-- 密码登录 -->
|
v-model="form.name"
|
||||||
<view class="login_info_item" v-if="loginWay === 'password'">
|
:customStyle="inputCss"
|
||||||
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss"
|
@change="checkNameParam"
|
||||||
:type="isShow ? 'text' : 'password'" @change="checkParam">
|
></up-input>
|
||||||
<template #suffix style="margin-right: 10rpx">
|
</view>
|
||||||
<up-image v-if="isShow" src="/static/login/show.png" width="20" height="20" bgColor="#f1f6ff00"
|
<!-- 密码登录 -->
|
||||||
@click="isShow = false"></up-image>
|
<view class="login_info_item" v-if="loginWay === 'password'">
|
||||||
<up-image v-else src="/static/login/hidden.png" width="20" height="20" bgColor="#f1f6ff00"
|
<up-input
|
||||||
@click="isShow = true"></up-image>
|
placeholder="请输入密码"
|
||||||
</template>
|
border="surround"
|
||||||
</up-input>
|
v-model="form.password"
|
||||||
</view>
|
:customStyle="inputCss"
|
||||||
<!-- 验证码登录 -->
|
:type="isShow ? 'text' : 'password'"
|
||||||
<view class="login_info_item" v-else>
|
@change="checkParam"
|
||||||
<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">
|
<up-image
|
||||||
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
|
v-if="isShow"
|
||||||
<text style="margin-left: 10rpx">s</text>
|
src="/static/login/show.png"
|
||||||
</view>
|
width="20"
|
||||||
<view v-else @click="getMobileCode" class="code_msg">
|
height="20"
|
||||||
获取验证码
|
bgColor="#f1f6ff00"
|
||||||
</view>
|
@click="isShow = false"
|
||||||
</template>
|
></up-image>
|
||||||
</up-input>
|
<up-image
|
||||||
</view>
|
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"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
<text style="margin-left: 10rpx">s</text>
|
||||||
|
</view>
|
||||||
|
<view v-else @click="getMobileCode" class="code_msg">
|
||||||
|
获取验证码
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</up-input>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="login_comm_but login_comm_but_yes" @click="loginFun">
|
<view class="login_comm_but login_comm_but_yes" @click="loginFun">
|
||||||
<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 @click="jumpForgot">忘记密码</view>
|
>
|
||||||
<view @click="jumpRegister">注册</view>
|
<view v-if="loginWay === 'code'" @click="loginWay = 'password'"
|
||||||
</view>
|
>密码登录登录</view
|
||||||
</view>
|
>
|
||||||
<view v-if="!isIOS">
|
<view @click="jumpForgot">忘记密码</view>
|
||||||
<view class="other_login">其他登录方式</view>
|
<view @click="jumpRegister">注册</view>
|
||||||
<view class="login_other_icon">
|
</view>
|
||||||
<view class="login_other_item" @click="wechatOneLogin">
|
</view>
|
||||||
<up-image src="/static/login/WXICON.png" width="44" height="44" bgColor="#f1f6ff00"></up-image>
|
<view v-if="!isIOS">
|
||||||
微信登录
|
<view class="other_login">其他登录方式</view>
|
||||||
</view>
|
<view class="login_other_icon">
|
||||||
<view class="login_other_item" @click="alipayOneLogin">
|
<view class="login_other_item" @click="wechatOneLogin">
|
||||||
<up-image src="/static/login/ZFB.png" width="44" height="44" bgColor="#f1f6ff00"></up-image>
|
<up-image
|
||||||
支付宝登录
|
src="/static/login/WXICON.png"
|
||||||
</view>
|
width="44"
|
||||||
</view>
|
height="44"
|
||||||
</view>
|
bgColor="#f1f6ff00"
|
||||||
<view class="policy_warp">
|
></up-image>
|
||||||
<up-checkbox name="isCheck" usedAlone v-model:checked="isPolicy" shape="circle" activeColor="#7934F6"
|
微信登录
|
||||||
size="19" iconSize="18">
|
</view>
|
||||||
<template #label>
|
<view class="login_other_item" @click="alipayOneLogin">
|
||||||
<text>已阅读并同意</text>
|
<up-image
|
||||||
<text class="policy_a_warp" @click="jumpUserAgreement">《服务协议》</text>
|
src="/static/login/ZFB.png"
|
||||||
<text>、</text>
|
width="44"
|
||||||
<text class="policy_a_warp" @click="jumpPrivacyAgreement">《隐私政策》</text>
|
height="44"
|
||||||
<text>、</text>
|
bgColor="#f1f6ff00"
|
||||||
<text class="policy_a_warp" @click="jumpProductAgreement">《售后保障协议》</text>
|
></up-image>
|
||||||
</template>
|
支付宝登录
|
||||||
</up-checkbox>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<up-toast ref="uToastRef"></up-toast>
|
</view>
|
||||||
</view>
|
<view class="policy_warp">
|
||||||
|
<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>、</text>
|
||||||
|
<text class="policy_a_warp" @click="jumpPrivacyAgreement"
|
||||||
|
>《隐私政策》</text
|
||||||
|
>
|
||||||
|
<text>、</text>
|
||||||
|
<text class="policy_a_warp" @click="jumpProductAgreement"
|
||||||
|
>《售后保障协议》</text
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</up-checkbox>
|
||||||
|
</view>
|
||||||
|
<up-toast ref="uToastRef"></up-toast>
|
||||||
|
</view>
|
||||||
</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
|
setStorageFun,
|
||||||
} from "@/api/common.js";
|
TOKEN_NAME,
|
||||||
import {
|
USER_KEY,
|
||||||
loginbysms,
|
USER_DATA,
|
||||||
loginbypw,
|
USER_LOGIN_TIME,
|
||||||
wechatLogin,
|
} from "@/utils/auth.js";
|
||||||
alipayLogin
|
import CryptoJS from "crypto-js";
|
||||||
} from "@/api/auth.js";
|
|
||||||
import {
|
|
||||||
setStorageFun,
|
|
||||||
TOKEN_NAME,
|
|
||||||
USER_KEY,
|
|
||||||
USER_DATA,
|
|
||||||
USER_LOGIN_TIME,
|
|
||||||
} from "@/utils/auth.js";
|
|
||||||
import CryptoJS from "crypto-js";
|
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
const hyyAlipay = uni.requireNativePlugin("Hyy-Alipay");
|
const hyyAlipay = uni.requireNativePlugin("Hyy-Alipay");
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
onLaunch: function () {
|
||||||
InputCodeComm,
|
console.log("App Launch");
|
||||||
},
|
const res = uni.getSystemInfoSync();
|
||||||
data() {
|
uni.setStorageSync("platform", res.platform);
|
||||||
return {
|
// #ifdef APP-PLUS
|
||||||
form: {
|
// 获取应用版本信息
|
||||||
name: null,
|
plus.runtime.getProperty(plus.runtime.appid, function (inf) {
|
||||||
password: null,
|
console.log("版本信息", inf.versionCode);
|
||||||
code: null,
|
uni.setStorageSync("version-1", inf.version); // 大版本号
|
||||||
},
|
uni.setStorageSync("versionCode", inf.versionCode); // 小版本号
|
||||||
inputCss: {
|
});
|
||||||
height: "80rpx",
|
let uuid = plus.device.uuid;
|
||||||
background: "#F3F3F3FF",
|
// #endif
|
||||||
"border-radius": "30rpx",
|
},
|
||||||
border: "0rpx",
|
components: {
|
||||||
"padding-left": "16px",
|
InputCodeComm,
|
||||||
},
|
},
|
||||||
loginWay: "password",
|
data() {
|
||||||
isShow: false, // 是否显示
|
return {
|
||||||
isPolicy: false, // 是否同意
|
form: {
|
||||||
countdown: false, // 清空倒计时
|
name: null,
|
||||||
loading: false,
|
password: null,
|
||||||
};
|
code: null,
|
||||||
},
|
},
|
||||||
methods: {
|
inputCss: {
|
||||||
jumpHome() {
|
height: "80rpx",
|
||||||
// const sysPlatform = getCurrentSysPlatform();
|
background: "#F3F3F3FF",
|
||||||
// if(sysPlatform === "android"){
|
"border-radius": "30rpx",
|
||||||
// uni.switchTab({
|
border: "0rpx",
|
||||||
// url: '/pages/message/message',
|
"padding-left": "16px",
|
||||||
// })
|
},
|
||||||
// }else{
|
loginWay: "password",
|
||||||
uni.switchTab({
|
isShow: false, // 是否显示
|
||||||
url: "/pages/home/home",
|
isPolicy: false, // 是否同意
|
||||||
});
|
countdown: false, // 清空倒计时
|
||||||
// }
|
loading: false,
|
||||||
},
|
};
|
||||||
async loginFun(val = {}) {
|
},
|
||||||
const then = this;
|
methods: {
|
||||||
const form = this.form;
|
jumpHome() {
|
||||||
const params = {};
|
// const sysPlatform = getCurrentSysPlatform();
|
||||||
if (!this.isPolicy) {
|
// if(sysPlatform === "android"){
|
||||||
this.$refs.uToastRef.show({
|
// uni.switchTab({
|
||||||
type: "error",
|
// url: '/pages/message/message',
|
||||||
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
// })
|
||||||
});
|
// }else{
|
||||||
return;
|
uni.switchTab({
|
||||||
}
|
url: "/pages/home/home",
|
||||||
let response = val;
|
});
|
||||||
if (this.loginWay === "password") {
|
// }
|
||||||
params.mobile = form.name;
|
},
|
||||||
params.password = CryptoJS.MD5(form.password).toString();
|
async loginFun(val = {}) {
|
||||||
response = await loginbypw(params);
|
const then = this;
|
||||||
}
|
const form = this.form;
|
||||||
if (this.loginWay === "code") {
|
const params = {};
|
||||||
params.mobile = form.name;
|
if (!this.isPolicy) {
|
||||||
params.smsCode = form.code;
|
this.$refs.uToastRef.show({
|
||||||
response = await loginbysms(params);
|
type: "error",
|
||||||
}
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let response = val;
|
||||||
|
if (this.loginWay === "password") {
|
||||||
|
params.mobile = form.name;
|
||||||
|
params.password = CryptoJS.MD5(form.password).toString();
|
||||||
|
response = await loginbypw(params);
|
||||||
|
}
|
||||||
|
if (this.loginWay === "code") {
|
||||||
|
params.mobile = form.name;
|
||||||
|
params.smsCode = form.code;
|
||||||
|
response = await loginbysms(params);
|
||||||
|
}
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
setStorageFun(TOKEN_NAME, data.token);
|
setStorageFun(TOKEN_NAME, data.token);
|
||||||
// 用于无感登录
|
// 用于无感登录
|
||||||
setStorageFun(USER_KEY, "");
|
setStorageFun(USER_KEY, "");
|
||||||
const userInfo = {
|
const userInfo = {
|
||||||
avatar: data.avatarUrl,
|
avatar: data.avatarUrl,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
grade: data.grade,
|
grade: data.grade,
|
||||||
inviteCode: data.inviteCode,
|
inviteCode: data.inviteCode,
|
||||||
};
|
};
|
||||||
setStorageFun(USER_DATA, userInfo);
|
setStorageFun(USER_DATA, userInfo);
|
||||||
// 当前登录得时间戳
|
// 当前登录得时间戳
|
||||||
let currentTimeStamp = new Date().getTime();
|
let currentTimeStamp = new Date().getTime();
|
||||||
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
|
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "success",
|
|
||||||
message: response.msg,
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
const res = uni.getSystemInfoSync();
|
||||||
then.jumpHome();
|
uni.setStorageSync('platform', res.platform);
|
||||||
}, 2000);
|
// #ifdef APP-PLUS
|
||||||
},
|
// 获取应用版本信息
|
||||||
checkNameParam(val) {
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
||||||
// console.log("val",val);
|
console.log("版本信息",inf.versionCode)
|
||||||
},
|
uni.setStorageSync('version-1', inf.version); // 大版本号
|
||||||
checkParam(val) {
|
uni.setStorageSync('versionCode', inf.versionCode); // 小版本号
|
||||||
// console.log("val",val);
|
});
|
||||||
},
|
let uuid = plus.device.uuid;
|
||||||
/**
|
// #endif
|
||||||
* 获取手机验证码
|
|
||||||
*/
|
|
||||||
async getMobileCode() {
|
|
||||||
const form = this.form;
|
|
||||||
if (!form.name) {
|
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "error",
|
|
||||||
message: "请输入账号",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.countdown = true;
|
|
||||||
|
|
||||||
const params = {
|
this.$refs.uToastRef.show({
|
||||||
mobile: form.name,
|
type: "success",
|
||||||
type: SMS_TYPE.LOGIN,
|
message: response.msg,
|
||||||
};
|
});
|
||||||
const response = await getUserList(params);
|
|
||||||
console.log("responseresponseresponse", response);
|
|
||||||
if (response && response.bizcode === 100) {
|
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "success",
|
|
||||||
message: response.msg,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.countdown = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
jumpForgot() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/rwa_package/setting/forgot-pass?type=3",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
jumpRegister() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/login_package/register/register",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 用户协议
|
|
||||||
jumpUserAgreement() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/mine_package/mine_user_agreement/mine_user_agreement?backPath=login",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 隐私协议
|
|
||||||
jumpPrivacyAgreement() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement?backPath=login",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 售后保障协议
|
|
||||||
jumpProductAgreement() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: "/pages/mine_package/mine_product_agreement/mine_product_agreement?backPath=login",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 微信登录
|
setTimeout(() => {
|
||||||
async wechatOneLogin() {
|
then.jumpHome();
|
||||||
const then = this;
|
}, 2000);
|
||||||
this.loading = true;
|
},
|
||||||
|
checkNameParam(val) {
|
||||||
|
// console.log("val",val);
|
||||||
|
},
|
||||||
|
checkParam(val) {
|
||||||
|
// console.log("val",val);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 获取手机验证码
|
||||||
|
*/
|
||||||
|
async getMobileCode() {
|
||||||
|
const form = this.form;
|
||||||
|
if (!form.name) {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "请输入账号",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.countdown = true;
|
||||||
|
|
||||||
// 检查是否同意协议
|
const params = {
|
||||||
if (!this.isPolicy) {
|
mobile: form.name,
|
||||||
this.$refs.uToastRef.show({
|
type: SMS_TYPE.LOGIN,
|
||||||
type: "error",
|
};
|
||||||
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
const response = await getUserList(params);
|
||||||
});
|
console.log("responseresponseresponse", response);
|
||||||
this.loading = false;
|
if (response && response.bizcode === 100) {
|
||||||
return;
|
this.$refs.uToastRef.show({
|
||||||
}
|
type: "success",
|
||||||
|
message: response.msg,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.countdown = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
jumpForgot() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/rwa_package/setting/forgot-pass?type=3",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
jumpRegister() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/login_package/register/register",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 用户协议
|
||||||
|
jumpUserAgreement() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/mine_package/mine_user_agreement/mine_user_agreement?backPath=login",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 隐私协议
|
||||||
|
jumpPrivacyAgreement() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement?backPath=login",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 售后保障协议
|
||||||
|
jumpProductAgreement() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/mine_package/mine_product_agreement/mine_product_agreement?backPath=login",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
try {
|
// 微信登录
|
||||||
// 1. 调用微信登录API
|
async wechatOneLogin() {
|
||||||
uni.login({
|
const then = this;
|
||||||
provider: "weixin",
|
this.loading = true;
|
||||||
onlyAuthorize: true,
|
|
||||||
success: async (loginRes) => {
|
|
||||||
console.log("微信登录成功:", loginRes);
|
|
||||||
|
|
||||||
// 2. 发送code到后端换取token
|
// 检查是否同意协议
|
||||||
const params = {
|
if (!this.isPolicy) {
|
||||||
isValid: false,
|
this.$refs.uToastRef.show({
|
||||||
token: loginRes.code,
|
type: "error",
|
||||||
// 可以根据需要添加其他参数
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
};
|
});
|
||||||
console.log("微信登录接口返回-1:", params);
|
this.loading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await wechatLogin(params);
|
try {
|
||||||
console.log("微信登录接口返回-2:", response, response.data, response.data.token);
|
// 1. 调用微信登录API
|
||||||
|
uni.login({
|
||||||
|
provider: "weixin",
|
||||||
|
onlyAuthorize: true,
|
||||||
|
success: async (loginRes) => {
|
||||||
|
console.log("微信登录成功:", loginRes);
|
||||||
|
|
||||||
if (response && response.bizcode === 100) {
|
// 2. 发送code到后端换取token
|
||||||
if (response.data.userId !== null) {
|
const params = {
|
||||||
// 登录
|
isValid: false,
|
||||||
this.loginWay = "wechat";
|
token: loginRes.code,
|
||||||
this.loginFun(response);
|
// 可以根据需要添加其他参数
|
||||||
} else {
|
};
|
||||||
// 去微信注册
|
console.log("微信登录接口返回-1:", params);
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=1`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
const response = await wechatLogin(params);
|
||||||
this.$refs.uToastRef.show({
|
console.log(
|
||||||
type: "error",
|
"微信登录接口返回-2:",
|
||||||
message: response.msg || "微信登录失败",
|
response,
|
||||||
});
|
response.data,
|
||||||
}
|
response.data.token
|
||||||
},
|
);
|
||||||
fail: (err) => {
|
|
||||||
this.loading = false;
|
|
||||||
console.error("微信登录失败:", err);
|
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "error",
|
|
||||||
message: "微信登录失败,请重试",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
this.loading = false;
|
|
||||||
console.error("微信登录异常:", error);
|
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "error",
|
|
||||||
message: "微信登录异常,请重试",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 支付宝一键登录
|
|
||||||
async alipayOneLogin() {
|
|
||||||
const then = this;
|
|
||||||
this.loading = true;
|
|
||||||
|
|
||||||
console.log("支付宝登录", hyyAlipay);
|
if (response && response.bizcode === 100) {
|
||||||
|
if (response.data.userId) {
|
||||||
|
// 登录
|
||||||
|
this.loginWay = "wechat";
|
||||||
|
this.loginFun(response);
|
||||||
|
} else {
|
||||||
|
// 去微信注册
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=1`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: response.msg || "微信登录失败",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
this.loading = false;
|
||||||
|
console.error("微信登录失败:", err);
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "微信登录失败,请重试",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
this.loading = false;
|
||||||
|
console.error("微信登录异常:", error);
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: "微信登录异常,请重试",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 支付宝一键登录
|
||||||
|
async alipayOneLogin() {
|
||||||
|
const then = this;
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
// 检查是否同意协议
|
console.log("支付宝登录", hyyAlipay);
|
||||||
if (!this.isPolicy) {
|
|
||||||
this.$refs.uToastRef.show({
|
|
||||||
type: "error",
|
|
||||||
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
|
||||||
});
|
|
||||||
this.loading = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hyyAlipay.openAuthScheme({
|
// 检查是否同意协议
|
||||||
appId: "2021005183625053", // 支付宝分配给开发者的应用 ID
|
if (!this.isPolicy) {
|
||||||
scheme: "trustbridgeapp", // manifest.json -> "App常用其他设置" -> "UrlSchemes"里设置
|
this.$refs.uToastRef.show({
|
||||||
},
|
type: "error",
|
||||||
(res) => {
|
message: "请阅读完相关协议以及政策,并且勾选同意选项",
|
||||||
console.log("支付宝回调", res);
|
});
|
||||||
alipayLogin({
|
this.loading = false;
|
||||||
isValid: false,
|
return;
|
||||||
token: res.auth_code,
|
}
|
||||||
}).then((response) => {
|
|
||||||
console.log("支付宝登录接口返回:", response,response.data.userId !== null);
|
|
||||||
if (response && response.bizcode === 100) {
|
|
||||||
if (response.data.userId !== null) {
|
|
||||||
// 登录
|
|
||||||
this.loginWay = "alipay";
|
|
||||||
this.loginFun(response);
|
|
||||||
} else {
|
|
||||||
// 去微信注册
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=2`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
hyyAlipay.openAuthScheme(
|
||||||
this.$refs.uToastRef.show({
|
{
|
||||||
type: "error",
|
appId: "2021005183625053", // 支付宝分配给开发者的应用 ID
|
||||||
message: response.msg || "微信登录失败",
|
scheme: "trustbridgeapp", // manifest.json -> "App常用其他设置" -> "UrlSchemes"里设置
|
||||||
});
|
},
|
||||||
}
|
(res) => {
|
||||||
});
|
console.log("支付宝回调", res);
|
||||||
}
|
alipayLogin({
|
||||||
);
|
isValid: false,
|
||||||
},
|
token: res.auth_code,
|
||||||
},
|
}).then((response) => {
|
||||||
computed: {
|
console.log("支付宝登录接口返回:", response, !response.data.userId);
|
||||||
isIOS() {
|
if (response && response.bizcode === 100) {
|
||||||
// #ifdef APP-PLUS
|
if (response.data.userId) {
|
||||||
return uni.getSystemInfoSync().platform === "ios";
|
// 登录
|
||||||
// #endif
|
this.loginWay = "alipay";
|
||||||
return false;
|
this.loginFun(response);
|
||||||
},
|
} else {
|
||||||
}
|
// 去微信注册
|
||||||
};
|
uni.navigateTo({
|
||||||
|
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=2`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.$refs.uToastRef.show({
|
||||||
|
type: "error",
|
||||||
|
message: response.msg || "微信登录失败",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isIOS() {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
return uni.getSystemInfoSync().platform === "ios";
|
||||||
|
// #endif
|
||||||
|
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 {
|
||||||
margin-bottom: 40rpx;
|
margin-bottom: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code_msg {
|
.code_msg {
|
||||||
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%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #999999;
|
color: #999999;
|
||||||
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;
|
||||||
|
|
||||||
.login_other_item {
|
.login_other_item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 50%;
|
flex: 50%;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 80rpx;
|
margin-bottom: 80rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -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){
|
||||||
|
|||||||
+122
-115
@@ -1,125 +1,132 @@
|
|||||||
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';
|
||||||
|
|
||||||
function request(options) {
|
function request(options) {
|
||||||
const {
|
const {
|
||||||
url,
|
url,
|
||||||
method = "GET",
|
method = "GET",
|
||||||
data = {},
|
data = {},
|
||||||
headers = {},
|
headers = {},
|
||||||
isShowLoading = true,
|
isShowLoading = true,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
// const token = uni.getStorageSync(tokenKey); // 获取token, 根据实际情况调整获取方式
|
// const token = uni.getStorageSync(tokenKey); // 获取token, 根据实际情况调整获取方式
|
||||||
const token = getStorageFun(TOKEN_NAME); // 获取token, 根据实际情况调整获取方式
|
const token = getStorageFun(TOKEN_NAME); // 获取token, 根据实际情况调整获取方式
|
||||||
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";
|
||||||
}
|
}
|
||||||
if (token) {
|
if (token) {
|
||||||
defaultHeaders["HSM-AUTH"] = token;
|
defaultHeaders["HSM-AUTH"] = token;
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (isShowLoading) {
|
if (isShowLoading) {
|
||||||
// 请求之前做一些事
|
// 请求之前做一些事
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "加载中...",
|
title: "加载中...",
|
||||||
image: "/static/common/loading.gif", // 本地图片路径
|
image: "/static/common/loading.gif", // 本地图片路径
|
||||||
position: "middle", // 可选:top/middle/bottom
|
position: "middle", // 可选:top/middle/bottom
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uni.request({
|
uni.request({
|
||||||
url: BASE_URL + url,
|
url: BASE_URL + url,
|
||||||
method,
|
method,
|
||||||
data,
|
data,
|
||||||
header: {
|
header: {
|
||||||
...defaultHeaders,
|
...defaultHeaders,
|
||||||
...headers, // 使用展开运算符合并默认头和自定义头
|
...headers, // 使用展开运算符合并默认头和自定义头
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('--success-',res)
|
if (isShowLoading) {
|
||||||
if (isShowLoading) {
|
// 请求之前做一些事
|
||||||
// 请求之前做一些事
|
uni.hideToast();
|
||||||
uni.hideToast();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
if (data && typeof data === "string") {
|
if (data && typeof data === "string") {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
}
|
}
|
||||||
if (data.status === 500) {
|
if (data.status === 500) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "系统异常,请稍后再试",
|
title: "系统异常,请稍后再试",
|
||||||
icon: "none", // 可选 success/loading/none
|
icon: "none", // 可选 success/loading/none
|
||||||
duration: 2000, // 持续时长,单位ms
|
duration: 2000, // 持续时长,单位ms
|
||||||
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
||||||
});
|
});
|
||||||
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)) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "登录失效,请重新登录",
|
title: "登录失效,请重新登录",
|
||||||
icon: "none", // 可选 success/loading/none
|
icon: "none", // 可选 success/loading/none
|
||||||
duration: 2000, // 持续时长,单位ms
|
duration: 2000, // 持续时长,单位ms
|
||||||
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
||||||
position: "middle", // 位置,可选 top/middle/bottom
|
position: "middle", // 位置,可选 top/middle/bottom
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: data.msg,
|
title: data.msg,
|
||||||
icon: "none", // 可选 success/loading/none
|
icon: "none", // 可选 success/loading/none
|
||||||
duration: 2000, // 持续时长,单位ms
|
duration: 2000, // 持续时长,单位ms
|
||||||
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
mask: false, // 是否显示透明蒙层,防止触摸穿透
|
||||||
position: "middle", // 位置,可选 top/middle/bottom
|
position: "middle", // 位置,可选 top/middle/bottom
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 205:已经有账号,返回登录页面
|
* 205:已经有账号,返回登录页面
|
||||||
* 200 or 201:token失效,返回登录页面
|
* 200 or 201:token失效,返回登录页面
|
||||||
*/
|
*/
|
||||||
if ([201, 200, 205].includes(data.errcode)) {
|
if ([201, 200, 205].includes(data.errcode)) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/login_package/login/login",
|
url: "/pages/login_package/login/login",
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
console.log("错误-1",data, url)
|
||||||
title: data.msg || "系统错误,请稍后再试",
|
uni.showToast({
|
||||||
icon: "none", // 可选 success/loading/none
|
title: data.msg || "系统错误,请稍后再试",
|
||||||
duration: 2000, // 持续时长,单位ms
|
icon: "none", // 可选 success/loading/none
|
||||||
});
|
duration: 2000, // 持续时长,单位ms
|
||||||
reject(data); // 其他错误情况返回错误信息
|
});
|
||||||
}
|
reject(data); // 其他错误情况返回错误信息
|
||||||
},
|
}
|
||||||
fail: (error) => {
|
},
|
||||||
if (isShowLoading) {
|
fail: (error) => {
|
||||||
// 请求之前做一些事
|
console.log("错误-2", url)
|
||||||
uni.hideToast();
|
if (isShowLoading) {
|
||||||
}
|
// 请求之前做一些事
|
||||||
uni.showToast({
|
uni.hideToast();
|
||||||
title: "服务器异常,稍后再试",
|
}
|
||||||
icon: "none", // 可选 success/loading/none
|
uni.showToast({
|
||||||
duration: 2000, // 持续时长,单位ms
|
title: "服务器异常,稍后再试",
|
||||||
});
|
icon: "none", // 可选 success/loading/none
|
||||||
// reject(error); // 请求失败时返回错误信息
|
duration: 2000, // 持续时长,单位ms
|
||||||
},
|
});
|
||||||
});
|
// reject(error); // 请求失败时返回错误信息
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default request;
|
export default request;
|
||||||
Reference in New Issue
Block a user