【移动端】个人资料页面调整

This commit is contained in:
洪树泽 2022-09-09 15:51:52 +08:00
parent 2f272503a6
commit 0a1cf3fb1a
2 changed files with 49 additions and 65 deletions

View File

@ -134,10 +134,6 @@
onUnload onUnload
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import { import {
// apiUserInfoGet,
// apiUserInfoSet,
// apiWechatMobileGet,
// apiHasPassword,
getUserInfo, getUserInfo,
userEdit, userEdit,
userBindMobile, userBindMobile,
@ -151,38 +147,42 @@
import { import {
uploadFile uploadFile
} from '@/utils/util.ts' } from '@/utils/util.ts'
import {
getWxCode
} from '@/utils/util'
let wxCode = ref < any | null > ('')
// //
let userInfo = ref < any | null > (null) let userInfo = ref < any | null > (null)
// //
const fieldType = ref(FieldType.NONE) const fieldType = ref(FieldType.NONE)
// //
const sexList = ref < Array < string > | null > (['男', '女'])
//
const showNickName = ref < boolean | null >(false) const showNickName = ref < boolean | null >(false)
// //
const showUserName = ref < boolean | null >(false) const showUserName = ref < boolean | null >(false)
//
const showPicker = ref < boolean | null >(false)
//
const showMobilePop = ref < boolean | null > (false)
// //
const newNickname = ref < string > ('') const newNickname = ref < string > ('')
// //
const newUsername = ref < string > ('') const newUsername = ref < string > ('')
//
const mobile = ref < string > ('')
//
const showPicker = ref < boolean | null > (false)
//
const sexList = ref < Array < string > | null > (['男', '女'])
//
const showMobilePop = ref < boolean | null > (true)
// //
const newMobile = ref < string > ('') const newMobile = ref < string > ('')
// //
const mobileCode = ref <string > ('') const mobileCode = ref <string > ('')
const codeTips = ref('') const codeTips = ref('')
const uCodeRef = shallowRef() const uCodeRef = shallowRef()
//
const getUser = async (): Promise < void > => {
userInfo.value = await getUserInfo()
}
//
const codeChange = (text: string) => { const codeChange = (text: string) => {
codeTips.value = text codeTips.value = text
} }
@ -200,7 +200,7 @@
} }
} }
// // -
const changeCodeMobile = async () => { const changeCodeMobile = async () => {
await userBindMobile({ await userBindMobile({
type: userInfo.mobile ? 'change' : 'bind', type: userInfo.mobile ? 'change' : 'bind',
@ -211,11 +211,6 @@
} }
//
const getUser = async (): Promise < void > => {
userInfo.value = await getUserInfo()
}
// //
const setUserInfoFun = async (value: string): Promise < void > => { const setUserInfoFun = async (value: string): Promise < void > => {
await userEdit({ await userEdit({
@ -229,29 +224,10 @@
const uploaderAvatar = () => { const uploaderAvatar = () => {
fieldType.value = FieldType.AVATAR fieldType.value = FieldType.AVATAR
uni.navigateTo({ uni.navigateTo({
url: '/uni_modules/uview-ui/components/u-avatar-cropper/u-avatar-cropper?destWidth=300&rectWidth=200&fileType=jpg', url: '/uni_modules/vk-uview-ui/components/u-avatar-cropper/u-avatar-cropper?destWidth=300&rectWidth=200&fileType=jpg',
}) })
} }
//
const changeNameConfirm = () => {
if (newNickname.value == '') return toast('昵称不能为空')
if (newNickname.value.length > 10) return toast('昵称长度不得超过十位数')
showNickName.value = false
fieldType.value = FieldType.NICKNAME
setUserInfoFun(newNickname.value)
}
//
const changeUserNameConfirm = () => {
if (newUsername.value == '') return toast('账号不能为空')
if (newUsername.value.length > 10) return toast('账号长度不得超过十位数')
fieldType.value = FieldType.USERNAME
setUserInfoFun(newUsername.value)
showUserName.value = false
}
// //
const changeSex = () => { const changeSex = () => {
showPicker.value = true showPicker.value = true
@ -264,17 +240,35 @@
showPicker.value = false showPicker.value = false
} }
// //
const changeUserNameConfirm = () => {
if (newUsername.value == '') return toast('账号不能为空')
if (newUsername.value.length > 10) return toast('账号长度不得超过十位数')
fieldType.value = FieldType.USERNAME
setUserInfoFun(newUsername.value)
showUserName.value = false
}
//
const changeNameConfirm = () => {
if (newNickname.value == '') return toast('昵称不能为空')
if (newNickname.value.length > 10) return toast('昵称长度不得超过十位数')
showNickName.value = false
fieldType.value = FieldType.NICKNAME
setUserInfoFun(newNickname.value)
}
//
const getPhoneNumber = async (e): Promise < void > => { const getPhoneNumber = async (e): Promise < void > => {
// wxCode.value = await getWxCode()
console.log('wxCode.value', wxCode.value)
fieldType.value = FieldType.MOBILE fieldType.value = FieldType.MOBILE
const { const {
encryptedData, encryptedData,
iv iv,
code,
} = e.detail } = e.detail
let data = { let data = {
code: wxCode.value, code,
encrypted_data: encryptedData, encrypted_data: encryptedData,
iv, iv,
} }
@ -311,7 +305,6 @@
onShow(async () => { onShow(async () => {
getUser() getUser()
wxCode.value = await getWxCode()
}) })
onUnload(() => { onUnload(() => {

View File

@ -136,12 +136,3 @@ export function uploadFile(path: any) {
}) })
}) })
} }
export const getWxCode = (): Promise<void> => {
return new Promise((resolve, reject) => {
uni.login({
desc: '获取用户信息,完善用户资料',
success: (res: Event) => resolve(res.code)
})
})
}