修改用户地址设置判断
This commit is contained in:
parent
c1ffa7606b
commit
a18787d6fd
@ -77,17 +77,7 @@ export default defineComponent({
|
|||||||
async onLoad(option) {
|
async onLoad(option) {
|
||||||
this.getArea()
|
this.getArea()
|
||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
console.log(option)
|
|
||||||
this.type = Number.parseInt(option.type) || 0
|
this.type = Number.parseInt(option.type) || 0
|
||||||
console.log('type值', this.type)
|
|
||||||
if (this.type === 1) {
|
|
||||||
// 跳转登录
|
|
||||||
this.show = true
|
|
||||||
} else {
|
|
||||||
// 点击进入
|
|
||||||
this.show = false
|
|
||||||
}
|
|
||||||
console.log('type值', this.show)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logout() {
|
logout() {
|
||||||
@ -120,7 +110,6 @@ export default defineComponent({
|
|||||||
this.hasLogin = userStore.userInfo?.nickname
|
this.hasLogin = userStore.userInfo?.nickname
|
||||||
const res = await getInfoAPI()
|
const res = await getInfoAPI()
|
||||||
if (res.code === 1) {
|
if (res.code === 1) {
|
||||||
console.log('用户信息:', res.data)
|
|
||||||
this.userInfo = res.data
|
this.userInfo = res.data
|
||||||
this.addressinfo.group_id = res.data.group_id
|
this.addressinfo.group_id = res.data.group_id
|
||||||
this.addressinfo.phone = res.data.phone
|
this.addressinfo.phone = res.data.phone
|
||||||
@ -132,6 +121,15 @@ export default defineComponent({
|
|||||||
this.userInfo.phone = '去绑定'
|
this.userInfo.phone = '去绑定'
|
||||||
this.phone = '去绑定'
|
this.phone = '去绑定'
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
this.userInfo.village === 0 ||
|
||||||
|
this.userInfo.village === null ||
|
||||||
|
this.userInfo.village === ''
|
||||||
|
) {
|
||||||
|
this.show = true
|
||||||
|
} else {
|
||||||
|
this.show = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -144,19 +142,15 @@ export default defineComponent({
|
|||||||
// console.log(value.value.length)
|
// console.log(value.value.length)
|
||||||
// this.addressNumber = value.value.length
|
// this.addressNumber = value.value.length
|
||||||
this.address_string = value.selectedItems.map((item) => item.label).join('')
|
this.address_string = value.selectedItems.map((item) => item.label).join('')
|
||||||
console.log(value)
|
|
||||||
this.addressinfo.district = this.address[0]
|
this.addressinfo.district = this.address[0]
|
||||||
this.addressinfo.street = this.address[1]
|
this.addressinfo.street = this.address[1]
|
||||||
this.addressinfo.village = this.address[2]
|
this.addressinfo.village = this.address[2]
|
||||||
|
|
||||||
// console.log(this.addressinfo)
|
|
||||||
this.submitGroup()
|
this.submitGroup()
|
||||||
},
|
},
|
||||||
// 图片上传
|
// 图片上传
|
||||||
uploadSuccess(res) {
|
uploadSuccess(res) {
|
||||||
const response = JSON.parse(res.file.response)
|
const response = JSON.parse(res.file.response)
|
||||||
if (response.code === 1) {
|
if (response.code === 1) {
|
||||||
console.log('上传图片成功:', response)
|
|
||||||
// formData.image.push(response.data.uri)
|
// formData.image.push(response.data.uri)
|
||||||
this.imgSrc = response.data.uri
|
this.imgSrc = response.data.uri
|
||||||
} else {
|
} else {
|
||||||
@ -180,7 +174,6 @@ export default defineComponent({
|
|||||||
avatar: this.imgSrc,
|
avatar: this.imgSrc,
|
||||||
}
|
}
|
||||||
const res = await setBaseAPI(data)
|
const res = await setBaseAPI(data)
|
||||||
console.log(res)
|
|
||||||
|
|
||||||
if (res.code === 1) {
|
if (res.code === 1) {
|
||||||
// 重新调用
|
// 重新调用
|
||||||
@ -204,9 +197,7 @@ export default defineComponent({
|
|||||||
avatar: this.userInfo.avatar,
|
avatar: this.userInfo.avatar,
|
||||||
}
|
}
|
||||||
const res = await setBaseAPI(data)
|
const res = await setBaseAPI(data)
|
||||||
console.log(res)
|
|
||||||
if (res.code === 1) {
|
if (res.code === 1) {
|
||||||
// 重新调用
|
|
||||||
userStore.getUserInfo()
|
userStore.getUserInfo()
|
||||||
}
|
}
|
||||||
this.showName = false
|
this.showName = false
|
||||||
@ -230,12 +221,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
this.userInfo.phone = this.phone
|
this.userInfo.phone = this.phone
|
||||||
const res = await setPhoneAPI(this.phone)
|
const res = await setPhoneAPI(this.phone)
|
||||||
console.log(res)
|
|
||||||
this.showPhone = false
|
this.showPhone = false
|
||||||
},
|
},
|
||||||
async submitGroup() {
|
async submitGroup() {
|
||||||
const res = await setGroupAPI(this.addressinfo)
|
const res = await setGroupAPI(this.addressinfo)
|
||||||
// console.log(res)
|
|
||||||
this.show = false
|
this.show = false
|
||||||
// 重新获取地址信息
|
// 重新获取地址信息
|
||||||
userStore.getUserInfo()
|
userStore.getUserInfo()
|
||||||
|
@ -16,23 +16,6 @@ export function http<T>(options: CustomRequestOptions) {
|
|||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
// 2.1 提取核心数据 res.data
|
// 2.1 提取核心数据 res.data
|
||||||
resolve(res.data as IResData<T>)
|
resolve(res.data as IResData<T>)
|
||||||
} else if (res.statusCode === 401) {
|
|
||||||
// 401错误 -> 清理用户信息,跳转到登录页
|
|
||||||
const userStore = useUserStore()
|
|
||||||
await userStore.logout()
|
|
||||||
uni.showToast({
|
|
||||||
icon: 'none',
|
|
||||||
title: (res.data as IResData<T>).msg || '请登录',
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
// #ifdef H5
|
|
||||||
uni.navigateTo({ url: '/pages/login/mpLogin' })
|
|
||||||
// #endif
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
uni.navigateTo({ url: '/pages/login/login' })
|
|
||||||
// #endif
|
|
||||||
}, 1500)
|
|
||||||
// reject(res)
|
|
||||||
} else {
|
} else {
|
||||||
// 其他错误 -> 根据后端错误信息轻提示
|
// 其他错误 -> 根据后端错误信息轻提示
|
||||||
!options.hideErrorToast &&
|
!options.hideErrorToast &&
|
||||||
@ -52,6 +35,26 @@ export function http<T>(options: CustomRequestOptions) {
|
|||||||
reject(err)
|
reject(err)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
}).catch((err) => {
|
||||||
|
if (err.statusCode === 401) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.data.msg,
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
// #ifdef H5
|
||||||
|
uni.navigateTo({ url: '/pages/login/mpLogin' })
|
||||||
|
// #endif
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
uni.navigateTo({ url: '/pages/login/login' })
|
||||||
|
// #endif
|
||||||
|
}, 1500)
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.data.msg,
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,17 +20,15 @@ function http<T>(options: CustomRequestOptions) {
|
|||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
// 2.1 提取核心数据 res.data
|
// 2.1 提取核心数据 res.data
|
||||||
resolve(res.data as T)
|
resolve(res.data as T)
|
||||||
}
|
} else if (res.statusCode === 401) {
|
||||||
else if (res.statusCode === 401) {
|
|
||||||
// 401错误 -> 清理用户信息,跳转到登录页
|
// 401错误 -> 清理用户信息,跳转到登录页
|
||||||
// userStore.clearUserInfo()
|
// userStore.clearUserInfo()
|
||||||
// uni.navigateTo({ url: '/pages/login/login' })
|
// uni.navigateTo({ url: '/pages/login/login' })
|
||||||
reject(res)
|
reject(res)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// 其他错误 -> 根据后端错误信息轻提示
|
// 其他错误 -> 根据后端错误信息轻提示
|
||||||
!options.hideErrorToast
|
!options.hideErrorToast &&
|
||||||
&& uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: (res.data as T & { msg?: string })?.msg || '请求错误',
|
title: (res.data as T & { msg?: string })?.msg || '请求错误',
|
||||||
})
|
})
|
||||||
@ -39,6 +37,7 @@ function http<T>(options: CustomRequestOptions) {
|
|||||||
},
|
},
|
||||||
// 响应失败
|
// 响应失败
|
||||||
fail(err) {
|
fail(err) {
|
||||||
|
console.log('err', err)
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '网络错误,换个网络试试',
|
title: '网络错误,换个网络试试',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user