This commit is contained in:
commie
2025-11-23 01:01:52 +08:00
parent 6ec389ff41
commit 0783e46b4b
21 changed files with 6409 additions and 1264 deletions
+1
View File
@@ -76,6 +76,7 @@
"updateSentGroupApplition", "updateSentGroupApplition",
]), ]),
setGlobalIMlistener() { setGlobalIMlistener() {
this.$store.dispatch("system/getConfig");
console.log("setGlobalIMlistener"); console.log("setGlobalIMlistener");
// init // init
const kickHander = (message) => { const kickHander = (message) => {
+11 -9
View File
@@ -1,18 +1,20 @@
// 登录 // 登录
export const businessConfig = (params) =>
uni.$u?.http.post("/common/init", JSON.stringify(params));
export const businessLogin = (params) => export const businessLogin = (params) =>
uni.$u?.http.post("/account/login", JSON.stringify(params)); uni.$u?.http.post("/common/login", JSON.stringify(params));
export const businessSendSms = (params) => export const businessSendSms = (params) =>
uni.$u?.http.post("/account/code/send", JSON.stringify(params)); uni.$u?.http.post("/common/captcha", JSON.stringify(params));
export const businessVerifyCode = (params) => export const businessVerifyCode = (params) =>
uni.$u?.http.post("/account/code/verify", JSON.stringify(params)); uni.$u?.http.post("/common/verify_captcha", JSON.stringify(params));
export const businessRegister = (params) => export const businessRegister = (params) =>
uni.$u?.http.post("/account/register", JSON.stringify(params)); uni.$u?.http.post("/common/register", JSON.stringify(params));
export const businessReset = (params) => export const businessReset = (params) =>
uni.$u?.http.post("/account/password/reset", JSON.stringify(params)); uni.$u?.http.post("/common/resetpwd", JSON.stringify(params));
export const businessModify = (params) => export const businessModify = (params) =>
uni.$u?.http.post( uni.$u?.http.post(
"/account/password/change", "/user/change_password",
JSON.stringify({ JSON.stringify({
...params, ...params,
}), { }), {
@@ -25,7 +27,7 @@ export const businessModify = (params) =>
// 用户信息 // 用户信息
export const businessInfoUpdate = (params) => export const businessInfoUpdate = (params) =>
uni.$u?.http.post( uni.$u?.http.post(
"/user/update", "/user/profile",
JSON.stringify({ JSON.stringify({
...params, ...params,
}), { }), {
@@ -36,7 +38,7 @@ export const businessInfoUpdate = (params) =>
); );
export const businessGetUserInfo = (userID) => export const businessGetUserInfo = (userID) =>
uni.$u?.http.post( uni.$u?.http.post(
"/user/find/full", "/user/find",
JSON.stringify({ JSON.stringify({
userIDs: [userID], userIDs: [userID],
}), { }), {
@@ -48,7 +50,7 @@ export const businessGetUserInfo = (userID) =>
export const businessSearchUserInfo = (keyword) => export const businessSearchUserInfo = (keyword) =>
uni.$u?.http.post( uni.$u?.http.post(
"/user/search/full", "/user/search",
JSON.stringify({ JSON.stringify({
keyword, keyword,
pagination: { pagination: {
+5 -5
View File
@@ -3,15 +3,15 @@
// const API_URL = `http://${BASE_HOST}:10002` // const API_URL = `http://${BASE_HOST}:10002`
// const WS_URL = `ws://${BASE_HOST}:10001` // const WS_URL = `ws://${BASE_HOST}:10001`
const BASE_DOMAIN = '156.238.245.175' const BASE_DOMAIN = 'www.axzc.xyz'
// const CHAT_URL = `https://${BASE_DOMAIN}/chat` // const CHAT_URL = `https://${BASE_DOMAIN}/chat`
// const API_URL = `https://${BASE_DOMAIN}/api` // const API_URL = `https://${BASE_DOMAIN}/api`
// const WS_URL = `wss://${BASE_DOMAIN}/msg_gateway` // const WS_URL = `wss://${BASE_DOMAIN}/msg_gateway`
const CHAT_URL = `http://${BASE_DOMAIN}:10008` const CHAT_URL = `http://${BASE_DOMAIN}:8585/api`
const API_URL = `http://${BASE_DOMAIN}:10002` const API_URL = `http://${BASE_DOMAIN}/imapi`
const WS_URL = `ws://${BASE_DOMAIN}:10001` const WS_URL = `ws://${BASE_DOMAIN}/ws`
const version = 'Uniapp-Demo' const version = '2.0.6'
const getRegisterUrl = () => uni.getStorageSync("IMRegisteUrl") || CHAT_URL; const getRegisterUrl = () => uni.getStorageSync("IMRegisteUrl") || CHAT_URL;
const getApiUrl = () => uni.getStorageSync("IMApiUrl") || API_URL; const getApiUrl = () => uni.getStorageSync("IMApiUrl") || API_URL;
Generated
+4959
View File
File diff suppressed because it is too large Load Diff
+42 -67
View File
@@ -3,72 +3,35 @@
<view class="login"> <view class="login">
<view class="logo"> <view class="logo">
<img src="static/images/logo.png" alt="" /> <img src="static/images/logo.png" alt="" />
<view class="title">欢迎使用OpenCorp</view> <view class="title">欢迎使用{{config.name}}</view>
</view> </view>
<u-tabs :list="list" @click="click"></u-tabs> <u-tabs :list="list" :current="active" @click="click"></u-tabs>
<u-form <u-form class="loginForm" labelPosition="top" :model="loginInfo" :labelStyle="{
class="loginForm"
labelPosition="top"
:model="loginInfo"
:labelStyle="{
fontSize: '14px', fontSize: '14px',
marginTop: '20rpx', marginTop: '20rpx',
width: 'max-content', width: 'max-content',
}" }" ref="loginForm">
ref="loginForm"
>
<u-form-item v-if="active === 0" label="" prop="phoneNumber"> <u-form-item v-if="active === 0" label="" prop="phoneNumber">
<u-input <u-input v-model="loginInfo.phoneNumber" border="surround" placeholder="请输入手机号码" clearable>
v-model="loginInfo.phoneNumber" <view slot="prefix" class="phoneNumber_areacode" @click="showPicker">
border="surround"
placeholder="请输入手机号码"
clearable
>
<view
slot="prefix"
class="phoneNumber_areacode"
@click="showPicker"
>
<text class="areacode_content">+{{ loginInfo.areaCode }}</text> <text class="areacode_content">+{{ loginInfo.areaCode }}</text>
<u-icon class="arrow_down" name="arrow-down"></u-icon> <u-icon class="arrow_down" name="arrow-down"></u-icon>
</view> </view>
</u-input> </u-input>
</u-form-item> </u-form-item>
<u-form-item v-if="active === 1" label="" prop="email"> <u-form-item v-if="active === 1" label="" prop="email">
<u-input <u-input v-model="loginInfo.email" border="surround" placeholder="请输入您的邮箱" clearable>
v-model="loginInfo.email"
border="surround"
placeholder="请输入您的邮箱"
clearable
>
</u-input> </u-input>
</u-form-item> </u-form-item>
<u-form-item v-if="active > 1 || isPwdLogin" label="" prop="password"> <u-form-item v-if="active > 1 || isPwdLogin" label="" prop="password">
<u-input <u-input v-model="loginInfo.password" border="surround" placeholder="请输入密码" :password="!eying"
v-model="loginInfo.password" clearable>
border="surround" <u-icon @click="updateEye" slot="suffix" :name="eying ? 'eye-off' : 'eye'">
placeholder="请输入密码"
:password="!eying"
clearable
>
<u-icon
@click="updateEye"
slot="suffix"
:name="eying ? 'eye-off' : 'eye'"
>
</u-icon> </u-icon>
</u-input> </u-input>
</u-form-item> </u-form-item>
<u-form-item <u-form-item v-if="active <= 1 && !isPwdLogin" label="" prop="verificationCode">
v-if="active <= 1 && !isPwdLogin" <u-input v-model="loginInfo.verificationCode" border="surround" placeholder="请输入验证码">
label=""
prop="verificationCode"
>
<u-input
v-model="loginInfo.verificationCode"
border="surround"
placeholder="请输入验证码"
>
<view class="code_btn" slot="suffix" @click="getCode"> <view class="code_btn" slot="suffix" @click="getCode">
{{ count !== 0 ? `${count} s` : "获取验证码" }} {{ count !== 0 ? `${count} s` : "获取验证码" }}
</view> </view>
@@ -80,12 +43,7 @@
<text class="forget" @click="toggleLoginMethod">{{ isPwdLogin ? "验证码登录" : "密码登录" }}</text> <text class="forget" @click="toggleLoginMethod">{{ isPwdLogin ? "验证码登录" : "密码登录" }}</text>
</view> </view>
<view class="login-btn"> <view class="login-btn">
<u-button <u-button :loading="loading" type="primary" @click="startLogin" :disabled="!canLogin">
:loading="loading"
type="primary"
@click="startLogin"
:disabled="!canLogin"
>
登录 登录
</u-button> </u-button>
</view> </view>
@@ -101,6 +59,7 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import md5 from "md5"; import md5 from "md5";
import { version } from '@/common/config' import { version } from '@/common/config'
@@ -134,12 +93,15 @@ export default {
loading: false, loading: false,
count: 0, count: 0,
isPwdLogin: true, isPwdLogin: true,
active: 0, active: 1,
}; };
}, },
computed: { computed: {
...mapGetters([
"config",
]),
v() { v() {
return version return this.config.name+' '+version
}, },
canLogin() { canLogin() {
return ( return (
@@ -156,7 +118,9 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
click({ index }) { click({
index
}) {
this.active = index; this.active = index;
}, },
copy() { copy() {
@@ -175,6 +139,11 @@ export default {
this.loginInfo.areaCode = uni.getStorageSync("last_areaCode") || "86"; this.loginInfo.areaCode = uni.getStorageSync("last_areaCode") || "86";
this.loginInfo.email = uni.getStorageSync("last_email") || ""; this.loginInfo.email = uni.getStorageSync("last_email") || "";
this.loginInfo.phoneNumber = uni.getStorageSync("last_phoneNumber") || ""; this.loginInfo.phoneNumber = uni.getStorageSync("last_phoneNumber") || "";
if(process.env.NODE_ENV == 'development'){
this.loginInfo.email = "commiu@outlook.com";
this.loginInfo.password = "qwe123";
}
}, },
updateEye() { updateEye() {
this.eying = !this.eying; this.eying = !this.eying;
@@ -191,14 +160,18 @@ export default {
let data = {}; let data = {};
try { try {
data = await businessLogin({ data = await businessLogin({
phoneNumber: this.loginInfo.phoneNumber, mobile: this.loginInfo.phoneNumber,
email: this.loginInfo.email, email: this.loginInfo.email,
areaCode: `+${this.loginInfo.areaCode}`, areaCode: `+${this.loginInfo.areaCode}`,
password: this.isPwdLogin ? md5(this.loginInfo.password) : "", password: this.isPwdLogin ? md5(this.loginInfo.password) : "",
platform: uni.$u.os() === "ios" ? 1 : 2, platform: uni.$u.os() === "ios" ? 1 : 2,
verifyCode: this.loginInfo.verificationCode, type: this.active === 0 ? 'mobile' : 'email',
code: this.loginInfo.verificationCode,
}); });
const { imToken, userID } = data; const {
imToken,
userID
} = data;
await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), { await IMSDK.asyncApi(IMSDK.IMMethods.Login, uuidv4(), {
userID, userID,
token: imToken, token: imToken,
@@ -227,7 +200,11 @@ export default {
// }); // });
}, },
saveLoginProfile(data) { saveLoginProfile(data) {
const { imToken, chatToken, userID } = data; const {
imToken,
token,
userID
} = data;
uni.setStorage({ uni.setStorage({
key: "IMUserID", key: "IMUserID",
data: userID, data: userID,
@@ -238,7 +215,7 @@ export default {
}); });
uni.setStorage({ uni.setStorage({
key: "BusinessToken", key: "BusinessToken",
data: chatToken, data: token,
}); });
}, },
saveLoginInfo() { saveLoginInfo() {
@@ -311,11 +288,9 @@ export default {
.login { .login {
color: #0c1c33; color: #0c1c33;
padding: 10vh 80rpx 0; padding: 10vh 80rpx 0;
background: linear-gradient( background: linear-gradient(180deg,
180deg,
rgba(0, 137, 255, 0.1) 0%, rgba(0, 137, 255, 0.1) 0%,
rgba(255, 255, 255, 0) 100% rgba(255, 255, 255, 0) 100%);
);
.title { .title {
font-size: 34rpx; font-size: 34rpx;
+19 -3
View File
@@ -10,7 +10,11 @@
marginTop: '20rpx', marginTop: '20rpx',
minWidth: '200rpx', minWidth: '200rpx',
}" ref="registerForm"> }" ref="registerForm">
<u-form-item prop="phoneNumber" label="手机号码"> <u-form-item prop="email" label="邮箱" v-if="userInfo.type == 'email'">
<u-input v-model="userInfo.email" border="surround" placeholder="请输入邮箱" clearable>
</u-input>
</u-form-item>
<u-form-item prop="phoneNumber" label="手机号码" v-if="userInfo.type == 'mobile'">
<u-input v-model="userInfo.phoneNumber" border="surround" placeholder="请输入手机号码" clearable> <u-input v-model="userInfo.phoneNumber" border="surround" placeholder="请输入手机号码" clearable>
<view slot="prefix" class="phoneNumber_areacode" @click="showPicker"> <view slot="prefix" class="phoneNumber_areacode" @click="showPicker">
<text class="areacode_content">+{{ userInfo.areaCode }}</text> <text class="areacode_content">+{{ userInfo.areaCode }}</text>
@@ -50,6 +54,7 @@
email: "", email: "",
areaCode: "86", areaCode: "86",
invitationCode: "", invitationCode: "",
type:'email',
}, },
checked: [true], checked: [true],
rules: { rules: {
@@ -60,6 +65,12 @@
trigger: ["blur", "change"], trigger: ["blur", "change"],
pattern: /^\d{11}$/, pattern: /^\d{11}$/,
}, ], }, ],
email: [{
type: "email",
required: true,
message: "请输入邮箱",
trigger: ["blur", "change"]
}, ],
}, },
isRegister: true, isRegister: true,
pageStatus: "normal", pageStatus: "normal",
@@ -67,15 +78,20 @@
}, },
onLoad(param) { onLoad(param) {
this.isRegister = JSON.parse(param.isRegister); this.isRegister = JSON.parse(param.isRegister);
if(process.env.NODE_ENV == 'development'){
this.userInfo.email = "commiu@outlook.com";
}
}, },
methods: { methods: {
sendSms() { sendSms() {
this.$refs.registerForm.validate().then((valid) => { this.$refs.registerForm.validate().then((valid) => {
const options = { const options = {
phoneNumber: this.userInfo.phoneNumber, mobile: this.userInfo.mobile,
email: this.userInfo.email,
areaCode: `+${this.userInfo.areaCode}`, areaCode: `+${this.userInfo.areaCode}`,
usedFor: this.isRegister ? SmsUserFor.Register : SmsUserFor.Reset, event: this.isRegister ? 'register' : "reset_pwd",
invitationCode: this.userInfo.invitationCode, invitationCode: this.userInfo.invitationCode,
type:this.userInfo.type
}; };
businessSendSms(options) businessSendSms(options)
.then(() => { .then(() => {
+25 -43
View File
@@ -1,45 +1,23 @@
<template> <template>
<view class="set_password_container content_with_back"> <view class="set_password_container content_with_back">
<view class="title">重置密码</view> <view class="title">重置密码</view>
<u-form <u-form class="loginForm commonPage-form" labelPosition="top" :model="formData" :rules="rules" :labelStyle="{
class="loginForm commonPage-form"
labelPosition="top"
:model="formData"
:rules="rules"
:labelStyle="{
fontSize: '14px', fontSize: '14px',
marginTop: '20rpx', marginTop: '20rpx',
minWidth: '200rpx', minWidth: '200rpx',
}" }" ref="loginForm">
ref="loginForm"
>
<u-form-item label="密码" prop="password"> <u-form-item label="密码" prop="password">
<u-input <u-input v-model="formData.password" border="surround" placeholder="请输入密码" :password="!passwordEying">
v-model="formData.password" <u-icon @click="updateEye('passwordEying')" slot="suffix"
border="surround" :name="passwordEying ? 'eye-off' : 'eye'"></u-icon>
placeholder="请输入密码"
:password="!passwordEying"
>
<u-icon
@click="updateEye('passwordEying')"
slot="suffix"
:name="passwordEying ? 'eye-off' : 'eye'"
></u-icon>
</u-input> </u-input>
</u-form-item> </u-form-item>
<view class="feild_desc">620至少包含数字字母</view> <view class="feild_desc">620至少包含数字字母</view>
<u-form-item label="确认密码" prop="confirmPassword"> <u-form-item label="确认密码" prop="confirmPassword">
<u-input <u-input v-model="formData.confirmPassword" border="surround" placeholder="请输入密码"
v-model="formData.confirmPassword" :password="!comfirmEying">
border="surround" <u-icon @click="updateEye('comfirmEying')" slot="suffix"
placeholder="请输入密码" :name="comfirmEying ? 'eye-off' : 'eye'"></u-icon>
:password="!comfirmEying"
>
<u-icon
@click="updateEye('comfirmEying')"
slot="suffix"
:name="comfirmEying ? 'eye-off' : 'eye'"
></u-icon>
</u-input> </u-input>
</u-form-item> </u-form-item>
</u-form> </u-form>
@@ -52,7 +30,9 @@
</template> </template>
<script> <script>
import { businessReset } from "@/api/login"; import {
businessReset
} from "@/api/login";
export default { export default {
data() { data() {
return { return {
@@ -60,6 +40,7 @@ export default {
codeValue: "", codeValue: "",
userInfo: { userInfo: {
phoneNumber: "", phoneNumber: "",
email:"",
areaCode: "", areaCode: "",
}, },
formData: { formData: {
@@ -69,8 +50,7 @@ export default {
passwordEying: false, passwordEying: false,
comfirmEying: false, comfirmEying: false,
rules: { rules: {
password: [ password: [{
{
type: "string", type: "string",
required: true, required: true,
message: "请输入密码", message: "请输入密码",
@@ -85,8 +65,7 @@ export default {
trigger: ["change", "blur"], trigger: ["change", "blur"],
}, },
], ],
confirmPassword: [ confirmPassword: [{
{
type: "string", type: "string",
required: true, required: true,
message: "请输入确认密码", message: "请输入确认密码",
@@ -105,7 +84,11 @@ export default {
}; };
}, },
onLoad(options) { onLoad(options) {
const { userInfo, isRegister, codeValue } = options; const {
userInfo,
isRegister,
codeValue
} = options;
this.userInfo = JSON.parse(userInfo); this.userInfo = JSON.parse(userInfo);
this.isRegister = JSON.parse(isRegister); this.isRegister = JSON.parse(isRegister);
this.codeValue = codeValue; this.codeValue = codeValue;
@@ -118,9 +101,10 @@ export default {
this.$refs.loginForm.validate().then((valid) => { this.$refs.loginForm.validate().then((valid) => {
if (valid) { if (valid) {
const options = { const options = {
phoneNumber: this.userInfo.phoneNumber, mobile: this.userInfo.phoneNumber,
email: this.userInfo.em,
areaCode: `+${this.userInfo.areaCode}`, areaCode: `+${this.userInfo.areaCode}`,
VerifyCode: this.codeValue, code: this.codeValue,
password: this.formData.password, password: this.formData.password,
platform: uni.$u.os() === "ios" ? 1 : 2, platform: uni.$u.os() === "ios" ? 1 : 2,
operationID: Date.now() + "", operationID: Date.now() + "",
@@ -146,11 +130,9 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.set_password_container { .set_password_container {
margin-top: var(--status-bar-height); margin-top: var(--status-bar-height);
background: linear-gradient( background: linear-gradient(180deg,
180deg,
rgba(0, 137, 255, 0.1) 0%, rgba(0, 137, 255, 0.1) 0%,
rgba(255, 255, 255, 0) 100% rgba(255, 255, 255, 0) 100%);
);
padding-top: 150rpx; padding-top: 150rpx;
.title { .title {
+19 -6
View File
@@ -54,6 +54,7 @@
codeValue: "", codeValue: "",
userInfo: { userInfo: {
phoneNumber: "", phoneNumber: "",
email: "",
areaCode: "", areaCode: "",
nickname: "", nickname: "",
password: "", password: "",
@@ -71,7 +72,7 @@
required: true, required: true,
message: "请输入密码", message: "请输入密码",
trigger: ["blur", "change"], trigger: ["blur", "change"],
pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{7,}$/, pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{6,}$/,
}, },
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
@@ -86,7 +87,7 @@
required: true, required: true,
message: "请输入确认密码", message: "请输入确认密码",
trigger: ["blur", "change"], trigger: ["blur", "change"],
pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{7,}$/, pattern: /^(?=.*\d)(?=.*[a-zA-Z]).{6,}$/,
}, },
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
@@ -109,6 +110,12 @@
...JSON.parse(userInfo), ...JSON.parse(userInfo),
}; };
this.codeValue = codeValue; this.codeValue = codeValue;
if(process.env.NODE_ENV == 'development'){
this.userInfo.email = "commiu@outlook.com";
this.userInfo.nickname = "commiu";
this.userInfo.password = "qwe123";
this.userInfo.confirmPassword = "qwe123";
}
}, },
onBackPress() { onBackPress() {
return true; return true;
@@ -127,14 +134,13 @@
async doRegister() { async doRegister() {
this.loading = true; this.loading = true;
const options = { const options = {
verifyCode: this.codeValue, code: this.codeValue,
platform: uni.$u.os() === "ios" ? 1 : 2, platform: uni.$u.os() === "ios" ? 1 : 2,
autoLogin: true, autoLogin: true,
user: {
...this.userInfo, ...this.userInfo,
areaCode: `+${this.userInfo.areaCode}`, areaCode: `+${this.userInfo.areaCode}`,
password: md5(this.userInfo.password), password: md5(this.userInfo.password),
}, mobile: `+${this.userInfo.phoneNumber}`,
}; };
try { try {
await businessRegister(options); await businessRegister(options);
@@ -143,7 +149,14 @@
uni.$u.route("/pages/login/index") uni.$u.route("/pages/login/index")
} catch (err) { } catch (err) {
console.log(err); console.log(err);
uni.$u.toast(checkLoginError(err)); if(err.msg=="验证码过期" || err.msg=="验证码错误"){
uni.$u.route("/pages/login/verifyCode/index", {
userInfo: JSON.stringify(this.userInfo),
isRegister: true,
resend: 1,
})
return ;
}
// uni.$u.toast('注册失败') // uni.$u.toast('注册失败')
} finally { } finally {
this.loading = false; this.loading = false;
+21 -6
View File
@@ -22,6 +22,7 @@
</view> </view>
</template> </template>
<script> <script>
import user from "../../../store/modules/user";
import { import {
businessSendSms, businessSendSms,
businessVerifyCode businessVerifyCode
@@ -41,6 +42,9 @@
userInfo: { userInfo: {
phoneNumber: "", phoneNumber: "",
areaCode: "", areaCode: "",
email: "",
code: "",
type: "email",
}, },
isRegister: false, isRegister: false,
}; };
@@ -48,11 +52,18 @@
onLoad(options) { onLoad(options) {
const { const {
userInfo, userInfo,
isRegister isRegister,
resend
} = options; } = options;
console.log(userInfo,isRegister)
this.userInfo = JSON.parse(userInfo); this.userInfo = JSON.parse(userInfo);
this.isRegister = JSON.parse(isRegister); this.isRegister = JSON.parse(isRegister);
if(resend == 1){
this.count = 0;
this.getSmsAgain();
}else{
this.startCount(); this.startCount();
}
}, },
onReady() {}, onReady() {},
methods: { methods: {
@@ -63,10 +74,12 @@
}, },
checkCode(value) { checkCode(value) {
const options = { const options = {
phoneNumber: this.userInfo.phoneNumber, mobile: this.userInfo.phoneNumber,
email: this.userInfo.email,
type: this.userInfo.type,
areaCode: `+${this.userInfo.areaCode}`, areaCode: `+${this.userInfo.areaCode}`,
usedFor: this.isRegister ? SmsUserFor.Register : SmsUserFor.Reset, event: this.isRegister ? 'register' : 'reset_pwd',
verifyCode: value, code: value,
}; };
businessVerifyCode(options) businessVerifyCode(options)
.then(() => { .then(() => {
@@ -102,9 +115,11 @@
getSmsAgain() { getSmsAgain() {
if (this.count === 0) { if (this.count === 0) {
const options = { const options = {
phoneNumber: this.userInfo.phoneNumber, mobile: this.userInfo.phoneNumber,
email: this.userInfo.email,
type: this.userInfo.type,
areaCode: `+${this.userInfo.areaCode}`, areaCode: `+${this.userInfo.areaCode}`,
usedFor: this.isRegister ? SmsUserFor.Register : SmsUserFor.Reset, event: this.isRegister ? 'register' : 'reset_pwd',
}; };
businessSendSms(options) businessSendSms(options)
.then(() => { .then(() => {
+1
View File
@@ -19,4 +19,5 @@ export default {
storeReinstall: (state) => state.user.reinstall, storeReinstall: (state) => state.user.reinstall,
storeProgress: (state) => state.user.progress, storeProgress: (state) => state.user.progress,
storeAuthData: (state) => state.user.authData, storeAuthData: (state) => state.user.authData,
config: (state) => state.system.config,
}; };
+2
View File
@@ -4,6 +4,7 @@ import user from "./modules/user";
import contact from "./modules/contact"; import contact from "./modules/contact";
import conversation from "./modules/conversation"; import conversation from "./modules/conversation";
import message from "./modules/message"; import message from "./modules/message";
import system from "./modules/system";
import getters from "./getters"; import getters from "./getters";
Vue.use(Vuex); Vue.use(Vuex);
@@ -14,6 +15,7 @@ const store = new Vuex.Store({
contact, contact,
conversation, conversation,
message, message,
system,
}, },
getters, getters,
}); });
+131 -47
View File
@@ -1,4 +1,6 @@
import { v4 as uuidv4 } from "uuid"; import {
v4 as uuidv4
} from "uuid";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
const state = { const state = {
@@ -38,14 +40,18 @@ const mutations = {
}; };
const actions = { const actions = {
async getFriendList({ commit }) { async getFriendList({
commit
}) {
let offset = 0; let offset = 0;
let friendInfoList = []; let friendInfoList = [];
let initialFetch = true; let initialFetch = true;
while (true) { while (true) {
try { try {
const count = initialFetch ? 10000 : 1000; const count = initialFetch ? 10000 : 1000;
const { data } = await IMSDK.asyncApi("getFriendListPage", uuidv4(), { const {
data
} = await IMSDK.asyncApi("getFriendListPage", uuidv4(), {
offset, offset,
count, count,
}); });
@@ -62,15 +68,18 @@ const actions = {
} }
commit("SET_FRIEND_LIST", friendInfoList); commit("SET_FRIEND_LIST", friendInfoList);
}, },
async getGrouplist({ commit }) { async getGrouplist({
commit
}) {
let offset = 0; let offset = 0;
let groupList = []; let groupList = [];
while (true) { while (true) {
try { try {
const { data } = await IMSDK.asyncApi( const {
data
} = await IMSDK.asyncApi(
"getJoinedGroupListPage", "getJoinedGroupListPage",
uuidv4(), uuidv4(), {
{
offset, offset,
count: 1000, count: 1000,
} }
@@ -84,51 +93,80 @@ const actions = {
} }
commit("SET_GROUP_LIST", groupList); commit("SET_GROUP_LIST", groupList);
}, },
getBlacklist({ commit }) { getBlacklist({
IMSDK.asyncApi(IMSDK.IMMethods.GetBlackList, uuidv4()).then(({ data }) => { commit
}) {
IMSDK.asyncApi(IMSDK.IMMethods.GetBlackList, uuidv4()).then(({
data
}) => {
commit("SET_BLACK_LIST", data); commit("SET_BLACK_LIST", data);
}); });
}, },
getRecvFriendApplications({ commit }) { getRecvFriendApplications({
commit
}) {
IMSDK.asyncApi( IMSDK.asyncApi(
IMSDK.IMMethods.GetFriendApplicationListAsRecipient, IMSDK.IMMethods.GetFriendApplicationListAsRecipient,
uuidv4(), uuidv4(),
).then(({ data }) => { ).then(({
data
}) => {
commit("SET_RECV_FRIEND_APPLICATIONS", data); commit("SET_RECV_FRIEND_APPLICATIONS", data);
}); });
}, },
getSentFriendApplications({ commit }) { getSentFriendApplications({
commit
}) {
IMSDK.asyncApi( IMSDK.asyncApi(
IMSDK.IMMethods.GetFriendApplicationListAsApplicant, IMSDK.IMMethods.GetFriendApplicationListAsApplicant,
uuidv4(), uuidv4(),
).then(({ data }) => { ).then(({
data
}) => {
commit("SET_SENT_FRIEND_APPLICATIONS", data); commit("SET_SENT_FRIEND_APPLICATIONS", data);
}); });
}, },
getRecvGroupApplications({ commit }) { getRecvGroupApplications({
commit
}) {
IMSDK.asyncApi( IMSDK.asyncApi(
IMSDK.IMMethods.GetGroupApplicationListAsRecipient, IMSDK.IMMethods.GetGroupApplicationListAsRecipient,
uuidv4(), uuidv4(),
).then(({ data }) => { ).then(({
data
}) => {
commit("SET_RECV_GROUP_APPLICATIONS", data); commit("SET_RECV_GROUP_APPLICATIONS", data);
}); });
}, },
getSentGroupApplications({ commit }) { getSentGroupApplications({
commit
}) {
IMSDK.asyncApi( IMSDK.asyncApi(
IMSDK.IMMethods.GetGroupApplicationListAsApplicant, IMSDK.IMMethods.GetGroupApplicationListAsApplicant,
uuidv4(), uuidv4(),
).then(({ data }) => { ).then(({
data
}) => {
commit("SET_SENT_GROUP_APPLICATIONS", data); commit("SET_SENT_GROUP_APPLICATIONS", data);
}); });
}, },
pushNewFriend({ commit, state }, friendInfo) { pushNewFriend({
commit,
state
}, friendInfo) {
const tmpList = [...state.friendList]; const tmpList = [...state.friendList];
const idx = tmpList.findIndex((item) => item.userID === friendInfo.userID); const idx = tmpList.findIndex((item) => item.userID === friendInfo.userID);
if (idx === -1) { if (idx === -1) {
commit("SET_FRIEND_LIST", [...tmpList, friendInfo]); commit("SET_FRIEND_LIST", [...tmpList, friendInfo]);
} }
}, },
updateFriendInfo({ commit, state }, { friendInfo, isRemove = false }) { updateFriendInfo({
commit,
state
}, {
friendInfo,
isRemove = false
}) {
const tmpList = [...state.friendList]; const tmpList = [...state.friendList];
const idx = tmpList.findIndex((item) => item.userID === friendInfo.userID); const idx = tmpList.findIndex((item) => item.userID === friendInfo.userID);
@@ -143,14 +181,23 @@ const actions = {
commit("SET_FRIEND_LIST", tmpList); commit("SET_FRIEND_LIST", tmpList);
} }
}, },
pushNewBlack({ commit, state }, blackInfo) { pushNewBlack({
commit,
state
}, blackInfo) {
const tmpList = [...state.blackList]; const tmpList = [...state.blackList];
const idx = tmpList.findIndex((item) => item.userID === blackInfo.userID); const idx = tmpList.findIndex((item) => item.userID === blackInfo.userID);
if (idx === -1) { if (idx === -1) {
commit("SET_BLACK_LIST", [...tmpList, blackInfo]); commit("SET_BLACK_LIST", [...tmpList, blackInfo]);
} }
}, },
updateBlackInfo({ commit, state }, { blackInfo, isRemove = false }) { updateBlackInfo({
commit,
state
}, {
blackInfo,
isRemove = false
}) {
const tmpList = [...state.blackList]; const tmpList = [...state.blackList];
const idx = tmpList.findIndex((item) => item.userID === blackInfo.userID); const idx = tmpList.findIndex((item) => item.userID === blackInfo.userID);
@@ -165,22 +212,31 @@ const actions = {
commit("SET_BLACK_LIST", tmpList); commit("SET_BLACK_LIST", tmpList);
} }
}, },
pushNewGroup({ commit, state }, groupInfo) { pushNewGroup({
commit,
state
}, groupInfo) {
const tmpList = [...state.groupList]; const tmpList = [...state.groupList];
const idx = tmpList.findIndex((item) => item.groupID === groupInfo.groupID); const idx = tmpList.findIndex((item) => item.groupID === groupInfo.groupID);
if (idx === -1) { if (idx === -1) {
commit("SET_GROUP_LIST", [...tmpList, groupInfo]); commit("SET_GROUP_LIST", [...tmpList, groupInfo]);
} }
}, },
updateGroupInfo( updateGroupInfo({
{ commit, state, rootState }, commit,
{ groupInfo, isRemove = false }, state,
) { rootState
}, {
groupInfo,
isRemove = false
}, ) {
const tmpList = [...state.groupList]; const tmpList = [...state.groupList];
const idx = tmpList.findIndex((item) => item.groupID === groupInfo.groupID); const idx = tmpList.findIndex((item) => item.groupID === groupInfo.groupID);
if (rootState.conversation.currentGroup.groupID === groupInfo.groupID) { if (rootState.conversation.currentGroup.groupID === groupInfo.groupID) {
commit("conversation/SET_CURRENT_GROUP", groupInfo, { root: true }); commit("conversation/SET_CURRENT_GROUP", groupInfo, {
root: true
});
} }
if (idx !== -1) { if (idx !== -1) {
@@ -194,7 +250,10 @@ const actions = {
commit("SET_GROUP_LIST", tmpList); commit("SET_GROUP_LIST", tmpList);
} }
}, },
pushNewRecvFriendApplition({ commit, state }, application) { pushNewRecvFriendApplition({
commit,
state
}, application) {
const tmpList = [...state.recvFriendApplications]; const tmpList = [...state.recvFriendApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.fromUserID === application.fromUserID, (item) => item.fromUserID === application.fromUserID,
@@ -204,10 +263,14 @@ const actions = {
} }
commit("SET_RECV_FRIEND_APPLICATIONS", [...tmpList, application]); commit("SET_RECV_FRIEND_APPLICATIONS", [...tmpList, application]);
}, },
updateRecvFriendApplition( updateRecvFriendApplition({
{ commit, state, rootState }, commit,
{ application, isRemove = false }, state,
) { rootState
}, {
application,
isRemove = false
}, ) {
const tmpList = [...state.recvFriendApplications]; const tmpList = [...state.recvFriendApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.fromUserID === application.fromUserID, (item) => item.fromUserID === application.fromUserID,
@@ -224,7 +287,10 @@ const actions = {
commit("SET_RECV_FRIEND_APPLICATIONS", tmpList); commit("SET_RECV_FRIEND_APPLICATIONS", tmpList);
} }
}, },
pushNewSentFriendApplition({ commit, state }, application) { pushNewSentFriendApplition({
commit,
state
}, application) {
const tmpList = [...state.sentFriendApplications]; const tmpList = [...state.sentFriendApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.toUserID === application.toUserID, (item) => item.toUserID === application.toUserID,
@@ -234,10 +300,14 @@ const actions = {
} }
commit("SET_SENT_FRIEND_APPLICATIONS", [...tmpList, application]); commit("SET_SENT_FRIEND_APPLICATIONS", [...tmpList, application]);
}, },
updateSentFriendApplition( updateSentFriendApplition({
{ commit, state, rootState }, commit,
{ application, isRemove = false }, state,
) { rootState
}, {
application,
isRemove = false
}, ) {
const tmpList = [...state.sentFriendApplications]; const tmpList = [...state.sentFriendApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.toUserID === application.toUserID, (item) => item.toUserID === application.toUserID,
@@ -254,7 +324,10 @@ const actions = {
commit("SET_SENT_FRIEND_APPLICATIONS", tmpList); commit("SET_SENT_FRIEND_APPLICATIONS", tmpList);
} }
}, },
pushNewRecvGroupApplition({ commit, state }, application) { pushNewRecvGroupApplition({
commit,
state
}, application) {
const tmpList = [...state.recvGroupApplications]; const tmpList = [...state.recvGroupApplications];
const idx = tmpList.findIndex((item) => item.userID === application.userID); const idx = tmpList.findIndex((item) => item.userID === application.userID);
if (idx !== -1) { if (idx !== -1) {
@@ -262,10 +335,14 @@ const actions = {
} }
commit("SET_RECV_GROUP_APPLICATIONS", [...tmpList, application]); commit("SET_RECV_GROUP_APPLICATIONS", [...tmpList, application]);
}, },
updateRecvGroupApplition( updateRecvGroupApplition({
{ commit, state, rootState }, commit,
{ application, isRemove = false }, state,
) { rootState
}, {
application,
isRemove = false
}, ) {
const tmpList = [...state.recvGroupApplications]; const tmpList = [...state.recvGroupApplications];
const idx = tmpList.findIndex((item) => item.userID === application.userID); const idx = tmpList.findIndex((item) => item.userID === application.userID);
@@ -280,7 +357,10 @@ const actions = {
commit("SET_RECV_GROUP_APPLICATIONS", tmpList); commit("SET_RECV_GROUP_APPLICATIONS", tmpList);
} }
}, },
pushNewSentGroupApplition({ commit, state }, application) { pushNewSentGroupApplition({
commit,
state
}, application) {
const tmpList = [...state.sentGroupApplications]; const tmpList = [...state.sentGroupApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.groupID === application.groupID, (item) => item.groupID === application.groupID,
@@ -290,10 +370,14 @@ const actions = {
} }
commit("SET_SENT_GROUP_APPLICATIONS", [...tmpList, application]); commit("SET_SENT_GROUP_APPLICATIONS", [...tmpList, application]);
}, },
updateSentGroupApplition( updateSentGroupApplition({
{ commit, state, rootState }, commit,
{ application, isRemove = false }, state,
) { rootState
}, {
application,
isRemove = false
}, ) {
const tmpList = [...state.sentGroupApplications]; const tmpList = [...state.sentGroupApplications];
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(item) => item.groupID === application.groupID, (item) => item.groupID === application.groupID,
+21 -6
View File
@@ -46,7 +46,10 @@ const mutations = {
}; };
const actions = { const actions = {
async getConversationList({ state, commit }, isFirstPage = true) { async getConversationList({
state,
commit
}, isFirstPage = true) {
try { try {
const { const {
data data
@@ -68,7 +71,9 @@ const actions = {
return []; return [];
} }
}, },
getCurrentGroup({ commit }, groupID) { getCurrentGroup({
commit
}, groupID) {
IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupsInfo, uuidv4(), [ IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupsInfo, uuidv4(), [
groupID, groupID,
]).then(({ ]).then(({
@@ -77,7 +82,10 @@ const actions = {
commit("SET_CURRENT_GROUP", data[0] ?? {}); commit("SET_CURRENT_GROUP", data[0] ?? {});
}); });
}, },
getCurrentMemberInGroup({ commit, rootState }, groupID) { getCurrentMemberInGroup({
commit,
rootState
}, groupID) {
IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupMembersInfo, uuidv4(), { IMSDK.asyncApi(IMSDK.IMMethods.GetSpecifiedGroupMembersInfo, uuidv4(), {
groupID, groupID,
userIDList: [rootState.user.selfInfo.userID], userIDList: [rootState.user.selfInfo.userID],
@@ -87,7 +95,9 @@ const actions = {
commit("SET_CURRENT_MEMBER_IN_GROUP", data[0] ?? {}); commit("SET_CURRENT_MEMBER_IN_GROUP", data[0] ?? {});
}); });
}, },
getUnReadCount({ commit }) { getUnReadCount({
commit
}) {
IMSDK.asyncApi(IMSDK.IMMethods.GetTotalUnreadMsgCount, uuidv4()).then( IMSDK.asyncApi(IMSDK.IMMethods.GetTotalUnreadMsgCount, uuidv4()).then(
(res) => { (res) => {
console.log(res); console.log(res);
@@ -95,7 +105,10 @@ const actions = {
}, },
); );
}, },
updateCurrentMemberInGroup({ commit, state }, memberInfo) { updateCurrentMemberInGroup({
commit,
state
}, memberInfo) {
console.log(memberInfo); console.log(memberInfo);
if ( if (
memberInfo.groupID === state.currentMemberInGroup.groupID && memberInfo.groupID === state.currentMemberInGroup.groupID &&
@@ -104,7 +117,9 @@ const actions = {
commit("SET_CURRENT_MEMBER_IN_GROUP", memberInfo); commit("SET_CURRENT_MEMBER_IN_GROUP", memberInfo);
} }
}, },
resetConversationState({ commit }) { resetConversationState({
commit
}) {
commit("SET_CURRENT_MEMBER_IN_GROUP", {}); commit("SET_CURRENT_MEMBER_IN_GROUP", {});
commit("SET_CURRENT_GROUP", {}); commit("SET_CURRENT_GROUP", {});
commit("SET_CURRENT_CONVERSATION", {}); commit("SET_CURRENT_CONVERSATION", {});
+29 -12
View File
@@ -1,6 +1,13 @@
import IMSDK, { MessageStatus, MessageType } from "openim-uniapp-polyfill"; import IMSDK, {
import { v4 as uuidv4 } from "uuid"; MessageStatus,
import { UpdateMessageTypes } from "@/constant"; MessageType
} from "openim-uniapp-polyfill";
import {
v4 as uuidv4
} from "uuid";
import {
UpdateMessageTypes
} from "@/constant";
const state = { const state = {
historyMessageList: [], historyMessageList: [],
@@ -17,12 +24,17 @@ const mutations = {
}; };
const actions = { const actions = {
async getHistoryMesageList({ commit, state }, params) { async getHistoryMesageList({
commit,
state
}, params) {
let emptyFlag = true; let emptyFlag = true;
try { try {
console.log("getHistoryMesageList:::"); console.log("getHistoryMesageList:::");
console.log(params); console.log(params);
const { data } = await IMSDK.asyncApi( const {
data
} = await IMSDK.asyncApi(
IMSDK.IMMethods.GetAdvancedHistoryMessageList, IMSDK.IMMethods.GetAdvancedHistoryMessageList,
uuidv4(), uuidv4(),
params, params,
@@ -43,18 +55,21 @@ const actions = {
emptyFlag, emptyFlag,
}; };
}, },
pushNewMessage({ commit, state }, message) { pushNewMessage({
commit,
state
}, message) {
commit("SET_HISTORY_MESSAGE_LIST", [...state.historyMessageList, message]); commit("SET_HISTORY_MESSAGE_LIST", [...state.historyMessageList, message]);
}, },
updateOneMessage( updateOneMessage({
{ commit, state }, commit,
{ state
}, {
message, message,
type = UpdateMessageTypes.Overall, type = UpdateMessageTypes.Overall,
keyWords = [], keyWords = [],
isSuccess = false, isSuccess = false,
}, }, ) {
) {
const tmpList = state.historyMessageList; const tmpList = state.historyMessageList;
const idx = tmpList.findIndex( const idx = tmpList.findIndex(
(msg) => msg.clientMsgID === message.clientMsgID, (msg) => msg.clientMsgID === message.clientMsgID,
@@ -73,7 +88,9 @@ const actions = {
commit("SET_HISTORY_MESSAGE_LIST", tmpList); commit("SET_HISTORY_MESSAGE_LIST", tmpList);
} }
}, },
resetMessageState({ commit }) { resetMessageState({
commit
}) {
commit("SET_HISTORY_MESSAGE_LIST", []); commit("SET_HISTORY_MESSAGE_LIST", []);
commit("SET_HAS_MORE_MESSAGE", true); commit("SET_HAS_MORE_MESSAGE", true);
}, },
+42
View File
@@ -0,0 +1,42 @@
import IMSDK from "openim-uniapp-polyfill";
import {
businessConfig
} from "@/api/login";
import {
filterEmptyValue
} from "@/util/common";
const state = {
config: {}
};
const mutations = {
SET_CONFIG(state, info) {
state.config = {
...info,
};
}
};
const actions = {
async getConfig({
commit
}) {
try {
const data = await businessConfig();
//filterEmptyValue(businessData);
commit("SET_CONFIG", data);
} catch (e) {
console.log(e);
uni.$u.toast("获取系统信息失败");
}
},
};
export default {
namespaced: true,
state,
mutations,
actions,
};
+19 -5
View File
@@ -1,7 +1,13 @@
import { v4 as uuidv4} from "uuid"; import {
v4 as uuidv4
} from "uuid";
import IMSDK from "openim-uniapp-polyfill"; import IMSDK from "openim-uniapp-polyfill";
import { businessGetUserInfo} from "@/api/login"; import {
import { filterEmptyValue} from "@/util/common"; businessGetUserInfo
} from "@/api/login";
import {
filterEmptyValue
} from "@/util/common";
const state = { const state = {
selfInfo: {}, selfInfo: {},
@@ -9,9 +15,13 @@ const state = {
isSyncing: false, isSyncing: false,
reinstall: false, reinstall: false,
progress: 0, progress: 0,
token: ""
}; };
const mutations = { const mutations = {
SET_TOKEN(state, info) {
state.token = info;
},
SET_SELF_INFO(state, info) { SET_SELF_INFO(state, info) {
state.selfInfo = { state.selfInfo = {
...info, ...info,
@@ -34,7 +44,9 @@ const mutations = {
}; };
const actions = { const actions = {
async getSelfInfo({ commit }) { async getSelfInfo({
commit
}) {
try { try {
const { const {
data data
@@ -42,7 +54,9 @@ const actions = {
IMSDK.IMMethods.GetSelfUserInfo, IMSDK.IMMethods.GetSelfUserInfo,
uuidv4(), uuidv4(),
); );
const {users} = await businessGetUserInfo(data.userID); const {
users
} = await businessGetUserInfo(data.userID);
console.log(users); console.log(users);
const businessData = users[0] ?? {}; const businessData = users[0] ?? {};
filterEmptyValue(businessData); filterEmptyValue(businessData);
@@ -1,11 +1,6 @@
// 此版本发布于2022-00-24 // 此版本发布于2022-00-24
const version = '2.0.34' const version = '2.0.34'
// 开发环境才提示,生产环境不会提示
if (process.env.NODE_ENV === 'development') {
console.log(`\n %c uView V${version} %c https://uviewui.com/ \n\n`, 'color: #ffffff; background: #3c9cff; padding:5px 0; border-radius: 5px;');
}
export default { export default {
v: version, v: version,
version, version,
+4 -2
View File
@@ -37,8 +37,7 @@ export const getDbDir = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => { plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => {
fs.root.getDirectory( fs.root.getDirectory(
"user", "user", {
{
create: true, create: true,
}, },
(entry) => { (entry) => {
@@ -177,6 +176,9 @@ export const toastWithCallback = (message, callBack, duration = 1000) => {
}; };
export const checkLoginError = (error) => { export const checkLoginError = (error) => {
if (error?.msg) {
return error.msg
}
if (!error?.errCode) { if (!error?.errCode) {
return "操作失败"; return "操作失败";
} }
+4 -4
View File
@@ -1,5 +1,7 @@
import appConfig from "@/common/config"; import appConfig from "@/common/config";
import { v4 as uuidV4 } from "uuid"; import {
v4 as uuidV4
} from "uuid";
/** /**
* 请求拦截 * 请求拦截
* @param {Object} http * @param {Object} http
@@ -13,11 +15,9 @@ module.exports = (vm) => {
if (config.custom.isIMApi) { if (config.custom.isIMApi) {
config.baseURL = appConfig.getApiUrl(); config.baseURL = appConfig.getApiUrl();
} }
if (config.custom.isPgyerApi) {
config.baseURL = "https://www.pgyer.com";
}
config.header = { config.header = {
...config.header, ...config.header,
token:uni.getStorageSync("BusinessToken"),
operationID: uuidV4(), operationID: uuidV4(),
}; };
// 可以在此通过vm引用vuex中的变量,具体值在vm.$store.state中 // 可以在此通过vm引用vuex中的变量,具体值在vm.$store.state中
+12 -2
View File
@@ -3,13 +3,23 @@
* @param {Object} http * @param {Object} http
*/ */
module.exports = (vm) => { module.exports = (vm) => {
uni.$u.http.interceptors.response.use( uni.$u.http.interceptors.response.use((response) => {
(response) => { console.log("\n-"
+"\n============================================================="
+"\nurl:"+response.config.fullPath
+"\nparams:"+JSON.stringify(response.config.params)
+"\ndata:"+JSON.stringify(response.config.data)
+"\nheader:"+JSON.stringify(response.config.header)
+"\nresponse:"+JSON.stringify(response.data)
+"\n=============================================================\n");
/* 对响应成功做点什么 可使用async await 做异步操作*/ /* 对响应成功做点什么 可使用async await 做异步操作*/
const data = response.data; const data = response.data;
// 自定义参数 // 自定义参数
const custom = response.config?.custom; const custom = response.config?.custom;
if (data.errCode !== 0 && data.code !== 0) { if (data.errCode !== 0 && data.code !== 0) {
if(data?.msg){
uni.$u.toast(data.msg)
}
// 服务端返回的状态码不等于200,则reject() // 服务端返回的状态码不等于200,则reject()
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示 // 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
// if (custom.toast !== false) { // if (custom.toast !== false) {