Browse Source

Merge branch 'wangyi/feature-20251026183100-deepmate王毅' into milestone-20251031-简版功能开发

lihuilin/feature-20251024095243-我的
wangyi 4 weeks ago
parent
commit
c926bc38fb
  1. 30
      api/start/login.js
  2. 2
      components/deepExploration_header.vue
  3. 25
      components/login-prompt.vue
  4. 10
      pages/deepMate/deepMate.vue
  5. 1
      pages/start/Registration/Registration.vue
  6. 95
      pages/start/recoverPassword/recoverPassword.vue
  7. 1
      stores/index.js
  8. 44
      stores/modules/login.js
  9. 13
      utils/http.js

30
api/start/login.js

@ -67,6 +67,36 @@ export const registerApi = (data) => {
}) })
} }
/**
* 忘记密码校验验证码
*/
export const verifyCodeApi = (data) => {
return http({
method: 'POST',
url: '/UserLogin/verifyCode',
data: data,
})
}
/**
* 忘记密码输入新的密码
*/
export const forgetApi = (data) => {
return http({
method: 'POST',
url: '/UserLogin/forget',
data: data,
})
}
/** /**
* 修改密码 * 修改密码
* *

2
components/deepExploration_header.vue

@ -72,6 +72,7 @@
<view class="history-main" @click="itemClick(item)"> <view class="history-main" @click="itemClick(item)">
<text class="history-query">{{ item.stockName }}</text> <text class="history-query">{{ item.stockName }}</text>
<text class="history-query">{{ item.stockCode }}</text> <text class="history-query">{{ item.stockCode }}</text>
<text class="history-query">{{ item.stockCode }}</text>
</view> </view>
<text class="history-time">{{ <text class="history-time">{{
formatTimeForHistory(item.createdTime) formatTimeForHistory(item.createdTime)
@ -98,6 +99,7 @@ const props = defineProps({
}, },
}); });
const showHistoryDrawer = ref(false); const showHistoryDrawer = ref(false);
const modelType = ref('');
const drawerOffsetY = ref(0); const drawerOffsetY = ref(0);
// const handleHistory = () => { // const handleHistory = () => {
// showHistoryDrawer.value = true; // showHistoryDrawer.value = true;

25
components/login-prompt.vue

@ -15,20 +15,40 @@
</template> </template>
<script setup> <script setup>
import { ref, nextTick, onMounted } from "vue";
import { ref, nextTick, onMounted, watch } from "vue";
import { useUserStore } from "../stores/modules/userInfo"; import { useUserStore } from "../stores/modules/userInfo";
import { useDeviceStore } from "../stores/modules/deviceInfo"; import { useDeviceStore } from "../stores/modules/deviceInfo";
import { useLoginStore } from "../stores/modules/login";
import { LoginApi } from "../api/start/login"; import { LoginApi } from "../api/start/login";
const deviceId = ref(""); const deviceId = ref("");
const userStore = useUserStore(); const userStore = useUserStore();
const deviceStore = useDeviceStore(); const deviceStore = useDeviceStore();
const loginStore = useLoginStore();
// //
onMounted(() => { onMounted(() => {
if (!userStore.userInfo) { if (!userStore.userInfo) {
show(); show();
} }
});
}),
// watch(
// () => loginStore.loginInfo,
// (newVal, oldVal) => {
// console.log("");
// if (newVal === "false") {
// console.log("");
// show();
// loginStore.setLoginInfo("true");
// }
// }
// );
loginStore.$subscribe(() => {
if (loginStore.loginInfo === "false") {
console.log("登录失败");
show();
}
});
// //
const showPrompt = ref(false); const showPrompt = ref(false);
@ -84,6 +104,7 @@ const continueAsVisitor = async () => {
if (res.code === 200) { if (res.code === 200) {
userStore.setUserInfo(res.data); userStore.setUserInfo(res.data);
console.log("0loginStore.loginInfo", loginStore.loginInfo);
hide(); hide();
} }
}; };

10
pages/deepMate/deepMate.vue

@ -297,6 +297,13 @@ import {
postHistory, postHistory,
postHistoryDetail, postHistoryDetail,
} from "../../api/deepMate/deepMate"; } from "../../api/deepMate/deepMate";
const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return `<p>${text}</p>`;
};
// marked // marked
marked.setOptions({ marked.setOptions({
renderer: new marked.Renderer(), renderer: new marked.Renderer(),
@ -926,7 +933,10 @@ async function itemClick(item) {
isTyping: false, isTyping: false,
isThinking: false, isThinking: false,
}; };
onDrawerBackClick()
messages.value.push(botMsg); messages.value.push(botMsg);
} }
} }
</script> </script>

1
pages/start/Registration/Registration.vue

@ -198,6 +198,7 @@ import {
SendPhoneCodeApi, SendPhoneCodeApi,
} from "../../../api/start/login"; } from "../../../api/start/login";
import { useDeviceStore} from "../../../stores/modules/deviceInfo" import { useDeviceStore} from "../../../stores/modules/deviceInfo"
import { useUserStore} from "../../../stores/modules/userInfo"
const type = ref(""); const type = ref("");
const email = ref(""); const email = ref("");

95
pages/start/recoverPassword/recoverPassword.vue

@ -209,10 +209,10 @@
</text> </text>
<!-- 或者 --> <!-- 或者 -->
<text class="or-text" @click="goToLogin">已有账号
<text class="link">登录
</text>
</text>
<text class="or-text" @click="goToLogin"
>已有账号
<text class="link">登录 </text>
</text>
<!-- 同意弹窗 --> <!-- 同意弹窗 -->
<uniPopup ref="agreementPopup" type="dialog"> <uniPopup ref="agreementPopup" type="dialog">
@ -235,7 +235,12 @@ import countryList from "../login/list";
import footerBar from "../../../components/footerBar"; import footerBar from "../../../components/footerBar";
import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
import { verificationPhone, verificationEmail } from "../login/verification"; import { verificationPhone, verificationEmail } from "../login/verification";
import { SendEmailCodeApi, SendPhoneCodeApi } from "../../../api/start/login";
import {
SendEmailCodeApi,
SendPhoneCodeApi,
verifyCodeApi,
forgetApi,
} from "../../../api/start/login";
const type = ref(""); const type = ref("");
const email = ref(""); const email = ref("");
@ -254,6 +259,7 @@ const verifyCode = ref("");
const isRecovering = ref(false); const isRecovering = ref(false);
const newPasswordLookFirst = ref(false); const newPasswordLookFirst = ref(false);
const newPasswordLookSecond = ref(false); const newPasswordLookSecond = ref(false);
const account = ref("");
// 使list.js // 使list.js
const countries = ref( const countries = ref(
@ -301,7 +307,7 @@ function switchPhone() {
verifyCode.value = ""; verifyCode.value = "";
} }
function register() {
async function register() {
if (isRecovering.value) { if (isRecovering.value) {
if (!newPasswordFirst.value || !newPasswordSecond.value) { if (!newPasswordFirst.value || !newPasswordSecond.value) {
uni.showToast({ uni.showToast({
@ -319,6 +325,32 @@ function register() {
return; return;
} }
const account = changeAccount();
const res = await forgetApi({
account: account,
password: newPasswordSecond.value,
});
console.log("res", res);
if (res.code !== 200) {
uni.showToast({
title: res.message,
icon: "none",
});
return;
}
uni.showToast({
title: res.message,
icon: "none",
});
uni.navigateTo({
url: "/pages/start/login/login",
});
// //
return; return;
} }
@ -384,13 +416,54 @@ function register() {
console.log("登录:", email.value); console.log("登录:", email.value);
} }
const account = changeAccount();
const loginType = changeLoginType();
const res = await verifyCodeApi({
loginType: loginType, //EMAIL,PHONE
account: account, // /
verifyCode: verifyCode.value,
});
if (res.code !== 200) {
uni.showToast({
title: res.message,
icon: "none",
});
return;
}
isRecovering.value = !isRecovering.value; isRecovering.value = !isRecovering.value;
}
//
// uni.showToast({
// title: "",
// icon: "success",
// });
//
function changeAccount() {
if (switchType.value === "User") {
account.value = deepChartID.value;
}
if (switchType.value === "Phone") {
account.value = `${country.value}${phone.value}`;
}
if (switchType.value === "Email") {
account.value = email.value;
}
return account.value;
}
// type
function changeLoginType() {
if (switchType.value === "User") {
return "DCCODE";
}
if (switchType.value === "Phone") {
return "PHONE";
}
if (switchType.value === "Email") {
return "EMAIL";
}
} }
function goToLogin() { function goToLogin() {

1
stores/index.js

@ -10,5 +10,6 @@ pinia.use(persist)
export * from './modules/userInfo' export * from './modules/userInfo'
export * from './modules/deviceInfo' export * from './modules/deviceInfo'
export * from './modules/deepExploration' export * from './modules/deepExploration'
export * from './modules/login'
// 默认导出,给 main.js 使用 // 默认导出,给 main.js 使用
export default pinia export default pinia

44
stores/modules/login.js

@ -0,0 +1,44 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
// 定义 Store
export const useLoginStore = defineStore(
'login',
() => {
// 会员信息
const loginInfo = ref("true")
// 保存会员信息,登录时使用
const setLoginInfo = (val) => {
loginInfo.value = val
}
// 清理会员信息,退出时使用
const clearLoginInfo = () => {
loginInfo.value = undefined
}
// 记得 return
return {
loginInfo,
setLoginInfo,
clearLoginInfo,
}
},
// TODO: 持久化
{
// 网页端持久化
// persist: true,
// 小程序端持久化
persist: {
storage: {
getItem(key) {
return uni.getStorageSync(key)
},
setItem(key, value) {
uni.setStorageSync(key, value)
},
},
},
},
)

13
utils/http.js

@ -1,5 +1,6 @@
import { useUserStore } from "../stores/modules/userInfo" import { useUserStore } from "../stores/modules/userInfo"
import { useDeviceStore } from "../stores/modules/deviceInfo" import { useDeviceStore } from "../stores/modules/deviceInfo"
import { useLoginStore } from "../stores/modules/login"
const baseURL = "https://dbqb.nfdxy.net/testApi" const baseURL = "https://dbqb.nfdxy.net/testApi"
@ -28,7 +29,7 @@ const httpInterceptor = {
const sys = uni.getSystemInfoSync(); const sys = uni.getSystemInfoSync();
// 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回) // 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回)
const deviceInfo =useDeviceStore()
const deviceInfo = useDeviceStore()
options.header = { options.header = {
@ -37,7 +38,7 @@ const httpInterceptor = {
'content-type': 'application/json', 'content-type': 'application/json',
'contentType': 'application/json', 'contentType': 'application/json',
'version': uni.getSystemInfoSync().appVersion, 'version': uni.getSystemInfoSync().appVersion,
'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android',
'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android',
'deviceId': deviceInfo.deviceInfo.deviceId 'deviceId': deviceInfo.deviceInfo.deviceId
} }
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
@ -64,6 +65,14 @@ export const http = (options) => {
success: (result) => { success: (result) => {
if (result.statusCode >= 200 && result.statusCode < 300) { if (result.statusCode >= 200 && result.statusCode < 300) {
if (result.data.code === 401) { if (result.data.code === 401) {
const loginStore = useLoginStore()
loginStore.setLoginInfo("true")
console.log("1loginStore.loginInfo", loginStore.loginInfo);
loginStore.setLoginInfo("false")
console.log("2loginStore.loginInfo", loginStore.loginInfo);
uni.showToast({ uni.showToast({
title: '请先登录', title: '请先登录',
icon: 'none' icon: 'none'

Loading…
Cancel
Save