Browse Source

add:对接用户个人信息接口

对接修改密码接口
配置信息接(部分)
lihuilin/feature-20251024095243-我的
lihui 4 weeks ago
parent
commit
c78175f93b
  1. 46
      api/member.js
  2. 13
      api/setting/general.js
  3. 16
      api/setting/nextPwd.js
  4. 31
      api/setting/password.js
  5. 15
      pages/home/member.vue
  6. 25
      pages/setting/account.vue
  7. 21
      pages/setting/general.vue
  8. 45
      pages/setting/nextPwd.vue
  9. 46
      pages/setting/password.vue
  10. 7
      utils/http.js

46
api/member.js

@ -0,0 +1,46 @@
import util from '../common/util.js'
/*export const getUserInfo = (data = {}) => {
return util.request(
'/api/my/userInfo',
(res) => {
console.log('用户信息请求成功:', res);
},
{data},
(err) => {
console.log('用户信息请求失败:', err);
}
);
};
*/
import { http } from '../utils/http'
/**
* 用户信息获取接口
* @param data
* @returns {Promise<unknown>}
*/
export const getUserInfo = (data) => {
return http({
method: 'POST',
url: '/api/my/userInfo',
data:
data
,
})
}

13
api/setting/general.js

@ -0,0 +1,13 @@
import { http } from '../utils/http'
export const getSetting = (data) => {
return http({
method: 'POST',
url: '/api/my/getSetting',
data:
data
,
})
}

16
api/setting/nextPwd.js

@ -0,0 +1,16 @@
import {http} from '../../utils/http'
/**
* 修改密码
* @param data
* @returns {*}
*/
export const updatePassword = (data) => {
return http({
method: 'POST',
url: '/api/my/updatePassword',
data:
data
,
})
}

31
api/setting/password.js

@ -0,0 +1,31 @@
import {http} from '../../utils/http'
/**
* 验证码发送
* @param data
* @returns {*}
*/
export const sendEmail = (data) => {
return http({
method: 'POST',
url: '/UserLogin/sendEmail',
data:
data
,
})
}
/**
* 验证码验证
* @param data
* @returns {*}
*/
export const validateCode = (data) => {
return http({
method: 'POST',
url: '/api/my/validateCode',
data:
data
,
})
}

15
pages/home/member.vue

@ -79,11 +79,22 @@
ArrowRight ArrowRight
} from '@element-plus/icons-vue' } from '@element-plus/icons-vue'
import footerBar from '../../components/footerBar.vue' import footerBar from '../../components/footerBar.vue'
import {getUserInfo} from "@/api/member";
const type = ref('member') const type = ref('member')
const iSMT = ref(0) const iSMT = ref(0)
const username = ref('演示机EVA')
const dccode = ref('90047681')
const username = ref('')
const dccode = ref('')
const userInfoRes = ref()
userInfoRes.value = getUserInfo()
userInfoRes.value.then(res => {
username.value = res.data.username
dccode.value = res.data.dccode
console.log('用户信息', res.data)
})
const goToGeneral = () => { const goToGeneral = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/setting/general' url: '/pages/setting/general'

25
pages/setting/account.vue

@ -15,21 +15,21 @@
<view class="setting-item"> <view class="setting-item">
<text class="item-label">昵称</text> <text class="item-label">昵称</text>
<view class="item-right"> <view class="item-right">
<text class="item-text">DeepChart</text>
<text class="item-text">{{userInfoRes.dcname}}</text>
<uni-icons type="arrowright" size="16" class="arrow"></uni-icons> <uni-icons type="arrowright" size="16" class="arrow"></uni-icons>
</view> </view>
</view> </view>
<view class="setting-item"> <view class="setting-item">
<text class="item-label">ID</text> <text class="item-label">ID</text>
<view class="item-right"> <view class="item-right">
<text class="item-text">{{ jwcode }}</text>
<text class="item-text">{{ userInfoRes.dccode }}</text>
<uni-icons type="arrowright" size="16" class="arrow"></uni-icons> <uni-icons type="arrowright" size="16" class="arrow"></uni-icons>
</view> </view>
</view> </view>
<view class="setting-item"> <view class="setting-item">
<text class="item-label">密码</text> <text class="item-label">密码</text>
<view class="item-right"> <view class="item-right">
<text class="item-text">qwertyuiop</text>
<text class="item-text">{{userInfoRes.password}}</text>
<uni-icons type="eye" size="16" class="eye-icon"></uni-icons> <uni-icons type="eye" size="16" class="eye-icon"></uni-icons>
</view> </view>
</view> </view>
@ -71,10 +71,27 @@
ref, ref,
onMounted onMounted
} from 'vue' } from 'vue'
import {getUserInfo} from "@/api/member";
const iSMT = ref(0) const iSMT = ref(0)
const jwcode = ref('90047681')
// const dccode = ref('')
const userInfoRes = ref({})
const showLogout = ref(false) const showLogout = ref(false)
const userInfoPromise = getUserInfo()
userInfoPromise.then(res => {
if (res.code === 200){
userInfoRes.value.dccode = res.data.dccode;
userInfoRes.value.dcname = res.data.dcname;
userInfoRes.value.password = res.data.password;
console.log('用户信息', res.data)
}else{
uni.showToast({
title: '用户信息请求失败',
icon: 'none',
})
}
})
const handleConfirmLogout = () => { const handleConfirmLogout = () => {
showLogout.value = false showLogout.value = false
uni.showToast({ uni.showToast({

21
pages/setting/general.vue

@ -4,7 +4,7 @@
<view class="top"> <view class="top">
<view class="top-list"> <view class="top-list">
<text>语言</text> <text>语言</text>
<text class="language">中文简体</text>
<text class="language">{{settingRes.language}}</text>
<uni-icons type="arrowright" size="16" class="arrow" /> <uni-icons type="arrowright" size="16" class="arrow" />
</view> </view>
<view class="top-list" @click="goToFont"> <view class="top-list" @click="goToFont">
@ -44,9 +44,26 @@
ref, ref,
onMounted onMounted
} from 'vue' } from 'vue'
import {getUserInfo} from "@/api/member";
const iSMT = ref(0) const iSMT = ref(0)
const cache = ref('45.5') const cache = ref('45.5')
const settingRes = ref({})
const settingPromise = getUserInfo()
settingPromise.then(res => {
if (res.code === 200){
settingRes.value.language = res.data.language;
settingRes.value.fontSize = res.data.fontSize;
settingRes.value.theme = res.data.theme;
settingRes.value.serverSelection = res.data.serverSelection;
console.log('用户信息', res.data)
}else {
console.log('用户信息请求失败:', res.message);
}
})
const goToFont = () => { const goToFont = () => {
uni.navigateTo({ uni.navigateTo({
url: '/pages/setting/font' url: '/pages/setting/font'
@ -109,7 +126,7 @@
} }
.language { .language {
margin-left: 55%;
margin-left: 70%;
font-size: 14px; font-size: 14px;
color: rgb(203, 203, 203); color: rgb(203, 203, 203);
} }

45
pages/setting/nextPwd.vue

@ -9,10 +9,13 @@
</view> </view>
<view class="top"> <view class="top">
<view class="top-list"> <view class="top-list">
<view class="left"> <view class="left">
<img src="/static/my/unlock.png"/> <img src="/static/my/unlock.png"/>
<input type="password" :type="pwdType" placeholder="请输入新密码" class="input" />
<input type="password" :type="pwdType" placeholder="请输入新密码" class="input" v-model="oldPassword"
/>
<img :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'" <img :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'"
@click="changeEye(1)"/> @click="changeEye(1)"/>
</view> </view>
@ -21,7 +24,7 @@
<view class="top-list"> <view class="top-list">
<view class="left"> <view class="left">
<img src="/static/my/unlock.png"/> <img src="/static/my/unlock.png"/>
<input type="password" :type="pwdType2" placeholder="再次确认" class="input" />
<input type="password" :type="pwdType2" placeholder="再次确认" class="input" v-model="newPassword"/>
<img :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'" <img :src="pwdType === 1 ? '/static/my/hideEye.png' : '/static/my/openEye.png'"
@click="changeEye(2)"/> @click="changeEye(2)"/>
</view> </view>
@ -31,21 +34,49 @@
</view> </view>
<view class="bottom"> <view class="bottom">
<button class="change-btn">确认</button>
<button class="change-btn" @click="confirmChange">确认</button>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import {
ref,
onMounted
} from 'vue'
import {onMounted, ref} from 'vue'
import {updatePassword} from "@/api/setting/nextPwd";
const iSMT = ref(0) const iSMT = ref(0)
const pwdType = ref('password') const pwdType = ref('password')
const pwdType2 = ref('password') const pwdType2 = ref('password')
//
const oldPassword = ref('')
const newPassword = ref('')
//
const confirmChange = async () => {
if (newPassword.value !== oldPassword.value) {
uni.showToast({title: '两次输入的密码不一致', icon: 'none'})
return
}
const updatePasswordPromise = updatePassword({
oldPassword: oldPassword.value,
newPassword: newPassword.value
})
updatePasswordPromise
.then(res => {
if (res.code === 200) {
uni.showToast({ title: '修改成功', icon: 'success' });
} else {
uni.showToast({ title: res.message,icon: 'none' });
}
})
.catch(err => {
console.log('修改密码失败:', err);
});
}
const changeEye = (type) => { const changeEye = (type) => {
if (type === 1) { if (type === 1) {
pwdType.value = pwdType.value === 'password' ? 'text' : 'password' pwdType.value = pwdType.value === 'password' ? 'text' : 'password'

46
pages/setting/password.vue

@ -10,7 +10,7 @@
<view class="switch-tab"> <view class="switch-tab">
<view class="input-list" v-if="activeTab === 'email'"> <view class="input-list" v-if="activeTab === 'email'">
<image src="/static/my/changeEmail.png" mode="aspectFit"></image> <image src="/static/my/changeEmail.png" mode="aspectFit"></image>
<input type="text" placeholder="请输入邮箱" class="input" />
<input type="text" placeholder="请输入邮箱" class="input" v-model="userEmail"/>
<button class="code-btn" :class="{disabled: gettingCode}" @click="getCode" :disabled="gettingCode"> <button class="code-btn" :class="{disabled: gettingCode}" @click="getCode" :disabled="gettingCode">
{{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }} {{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
</button> </button>
@ -18,7 +18,7 @@
<view class="input-list" v-else> <view class="input-list" v-else>
<image src="/static/my/changeBindPhone.png" mode="aspectFit"></image> <image src="/static/my/changeBindPhone.png" mode="aspectFit"></image>
<input type="number" placeholder="请输入手机号" class="input" />
<input type="number" placeholder="请输入手机号" class="input" v-model="userPhone"/>
<button class="code-btn" :class="{disabled: gettingCode}" @click="getCode" :disabled="gettingCode"> <button class="code-btn" :class="{disabled: gettingCode}" @click="getCode" :disabled="gettingCode">
{{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }} {{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
</button> </button>
@ -26,7 +26,7 @@
<view class="input-list"> <view class="input-list">
<image src="/static/my/verification.png" mode="aspectFit"></image> <image src="/static/my/verification.png" mode="aspectFit"></image>
<input type="text" placeholder="请输入验证码" class="input" />
<input type="text" placeholder="请输入验证码" class="input" v-model="verifyCode"/>
</view> </view>
</view> </view>
@ -41,33 +41,69 @@
ref, ref,
onMounted onMounted
} from 'vue' } from 'vue'
import {sendEmail, validateCode} from "@/api/setting/password";
const iSMT = ref(0) const iSMT = ref(0)
const activeTab = ref('email') const activeTab = ref('email')
const gettingCode = ref(false) const gettingCode = ref(false)
const time = ref(60) const time = ref(60)
const userEmail = ref('')
const userPhone = ref('')
const verifyCode = ref('')
const getCode = () => { const getCode = () => {
if (gettingCode.value) return if (gettingCode.value) return
gettingCode.value = true gettingCode.value = true
time.value = 60
time.value = 2
const timer = setInterval(() => { const timer = setInterval(() => {
time.value-- time.value--
if (time.value <= 0) { if (time.value <= 0) {
clearInterval(timer) clearInterval(timer)
gettingCode.value = false gettingCode.value = false
time.value = 60
time.value = 2
} }
}, 1000) }, 1000)
sendEmail({email: userEmail.value})
} }
const goToPwdNext = () => { const goToPwdNext = () => {
if (!userEmail.value) {
uni.showToast({title: '请输入邮箱', icon: 'none'})
return
}
if (!verifyCode.value) {
uni.showToast({title: '请输入验证码', icon: 'none'})
return
}
try {
const res = validateCode({
loginType:'EMAIL',
account: userEmail.value,
verifyCode: verifyCode.value
})
console.log('validateCode 返回:', res)
//
if (res.code === 200) {
uni.showToast({title: '验证成功', icon: 'success'})
uni.navigateTo({ uni.navigateTo({
url: '../setting/nextPwd' url: '../setting/nextPwd'
}) })
} else {
uni.showToast({title: res.msg || '验证失败', icon: 'none'})
}
} catch (err) {
console.error(err)
uni.showToast({title: '请求出错', icon: 'none'})
} }
}
onMounted(() => { onMounted(() => {
// //

7
utils/http.js

@ -1,6 +1,7 @@
import { useUserStore } from "../stores/modules/userInfo" import { useUserStore } from "../stores/modules/userInfo"
const baseURL = "https://hwjb.homilychart.com/testApi"
// const baseURL = "https://hwjb.homilychart.com/testApi"
const baseURL = "http://192.168.40.8:9000"
const httpInterceptor = { const httpInterceptor = {
@ -39,8 +40,8 @@ const httpInterceptor = {
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore() const memberStore = useUserStore()
// const token = memberStore.userInfo?.token || options.data?.token // const token = memberStore.userInfo?.token || options.data?.token
options.header.token = '790750702588f1ea79f24dc56ccd5d8a'
const token = '790750702588f1ea79f24dc56ccd5d8a'
options.header.token = '1'
const token = '1'
if (token) { if (token) {
options.header.token = token options.header.token = token
} }

Loading…
Cancel
Save