|
@@ -31,7 +31,7 @@ Page({
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.removeStorage({
|
|
|
- key: 'token',
|
|
|
+ key: 'user',
|
|
|
success(res) {
|
|
|
return wx.redirectTo({ url: '/pagesHome/home/index' })
|
|
|
}
|
|
@@ -45,25 +45,25 @@ Page({
|
|
|
wx.navigateTo({ url: '/pagesCommon/login/index' })
|
|
|
}
|
|
|
},
|
|
|
+ // 去登录
|
|
|
+ toLogin() {
|
|
|
+ wx.navigateTo({ url: '/pagesCommon/login/index' })
|
|
|
+ },
|
|
|
// 获取头像
|
|
|
async toAvatarUrl(e) {
|
|
|
const that = this;
|
|
|
const { avatarUrl } = e.detail
|
|
|
- if (that.data.user._id) {
|
|
|
- let res = await app.$apifile('files/ball/users/upload', null, avatarUrl)
|
|
|
- res = JSON.parse(res);
|
|
|
- if (res.errcode == '0') {
|
|
|
- let icon = [{ id: res.id, name: res.name, uri: res.uri, url: `${app.globalData.fileserverUrl}` + res.uri }]
|
|
|
- let arr = await app.$api(`user/${that.data.user._id}`, 'POST', { icon: icon });
|
|
|
- if (arr.errcode == '0') {
|
|
|
- wx.showToast({ title: `头像上传成功`, icon: 'success' });
|
|
|
- that.search()
|
|
|
- } else {
|
|
|
- wx.showToast({ title: `${arr.errmsg}`, icon: 'error' });
|
|
|
- }
|
|
|
+ let res = await app.$apifile('files/ball/users/upload', null, avatarUrl)
|
|
|
+ res = JSON.parse(res);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let icon = [{ id: res.id, name: res.name, uri: res.uri, url: `${app.globalData.fileserverUrl}` + res.uri }]
|
|
|
+ let arr = await app.$api(`user/${that.data.user._id}`, 'POST', { icon: icon });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `头像上传成功`, icon: 'success' });
|
|
|
+ that.search()
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error' });
|
|
|
}
|
|
|
- } else {
|
|
|
- wx.navigateTo({ url: '/pagesCommon/login/index' })
|
|
|
}
|
|
|
},
|
|
|
// 过滤字典表
|
|
@@ -80,6 +80,12 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
async onLoad(options) {
|
|
|
+
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ async onShow() {
|
|
|
const that = this;
|
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
|
await that.searchConfig();
|
|
@@ -114,7 +120,7 @@ Page({
|
|
|
async search() {
|
|
|
const that = this;
|
|
|
wx.getStorage({
|
|
|
- key: 'token',
|
|
|
+ key: 'user',
|
|
|
async success(res) {
|
|
|
let arr = await app.$api(`user/${res.data._id}`, 'GET', {})
|
|
|
if (arr.errcode == '0') {
|
|
@@ -144,12 +150,6 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow() {
|
|
|
-
|
|
|
- },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|