mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-05-30 21:50:48 +08:00
【小程序】个人资料
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { getToken } from './auth'
|
||||
|
||||
/**
|
||||
* @description 获取元素节点信息(在组件中的元素必须要传ctx)
|
||||
* @param { String } selector 选择器 '.app' | '#app'
|
||||
@@ -23,3 +25,44 @@ export const getRect = (selector: string, all = false, context?: any) => {
|
||||
.exec()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 上传图片
|
||||
* @param { String } path 选择的本地地址
|
||||
*/
|
||||
export function uploadFile(path: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = getToken()
|
||||
uni.uploadFile({
|
||||
url: `${import.meta.env.VITE_APP_BASE_URL}/api/Upload/image`,
|
||||
filePath: path,
|
||||
name: 'file',
|
||||
header: {
|
||||
token,
|
||||
},
|
||||
fileType: 'image',
|
||||
success: res => {
|
||||
console.log('uploadFile res ==> ', res)
|
||||
let data = JSON.parse(res.data);
|
||||
if (data.code == 1) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
reject()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const getWxCode = (): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
desc: '获取用户信息,完善用户资料',
|
||||
success: (res: Event) => resolve(res.code)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user