user.js 551 字节
Newer Older
M
MicroMilo 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import * as uniIdPagesStore from '@/uni_modules/uni-id-pages/common/store'
export default {
    namespaced: true,
    state: {},
    mutations: {},
    actions: {
		getUserInfo ({commit}) {
			const db = uniCloud.database()
			return db
				.collection('uni-id-users')
				.where('_id==$cloudEnv_uid')
				.field('username,nickname,mobile,email,role,permission')
				.get()
				.then(({result}) => {
					const [userInfo] = result.data

					uniIdPagesStore.mutations.setUserInfo(userInfo, true)

					return Promise.resolve(userInfo)
				})
		}
	}
}