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

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

@ -133,11 +133,7 @@
onShow,
onUnload
} from '@dcloudio/uni-app'
import {
// apiUserInfoGet,
// apiUserInfoSet,
// apiWechatMobileGet,
// apiHasPassword,
import {
getUserInfo,
userEdit,
userBindMobile,
@ -151,38 +147,42 @@
import {
uploadFile
} from '@/utils/util.ts'
import {
getWxCode
} from '@/utils/util'
let wxCode = ref < any | null > ('')
//
let userInfo = ref < any | null > (null)
//
const fieldType = ref(FieldType.NONE)
//
const showNickName = ref < boolean | null > (false)
//
const showUserName = ref < boolean | null > (false)
const fieldType = ref(FieldType.NONE)
//
const sexList = ref < Array < string > | null > (['男', '女'])
//
const showNickName = 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 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 newUsername = ref < string > ('')
//
const newMobile = ref < string > ('')
//
const mobileCode = ref <string > ('')
const codeTips = ref('')
const uCodeRef = shallowRef()
//
const getUser = async (): Promise < void > => {
userInfo.value = await getUserInfo()
}
//
const codeChange = (text: string) => {
codeTips.value = text
}
@ -200,7 +200,7 @@
}
}
//
// -
const changeCodeMobile = async () => {
await userBindMobile({
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 > => {
await userEdit({
@ -229,17 +224,20 @@
const uploaderAvatar = () => {
fieldType.value = FieldType.AVATAR
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 changeSex = () => {
showPicker.value = true
fieldType.value = FieldType.SEX
}
//
const changeSexConfirm = (value) => {
setUserInfoFun(value[0] + 1)
showPicker.value = false
}
//
@ -252,29 +250,25 @@
showUserName.value = false
}
//
const changeSex = () => {
showPicker.value = true
fieldType.value = FieldType.SEX
//
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 changeSexConfirm = (value) => {
setUserInfoFun(value[0] + 1)
showPicker.value = false
}
//
//
const getPhoneNumber = async (e): Promise < void > => {
// wxCode.value = await getWxCode()
console.log('wxCode.value', wxCode.value)
fieldType.value = FieldType.MOBILE
const {
encryptedData,
iv
iv,
code,
} = e.detail
let data = {
code: wxCode.value,
let data = {
code,
encrypted_data: encryptedData,
iv,
}
@ -311,7 +305,6 @@
onShow(async () => {
getUser()
wxCode.value = await getWxCode()
})
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)
})
})
}