|
@@ -1,7 +1,14 @@
|
|
const app = getApp()
|
|
const app = getApp()
|
|
|
|
+import { my_menu } from "../../utils/site";
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
- info: {}
|
|
|
|
|
|
+ logo: '',
|
|
|
|
+ avatarUrl: '',
|
|
|
|
+ user: {},
|
|
|
|
+ // 按钮
|
|
|
|
+ menuList: my_menu,
|
|
|
|
+ // 状态
|
|
|
|
+ statusList: []
|
|
},
|
|
},
|
|
toPath(e) {
|
|
toPath(e) {
|
|
let data = e.detail;
|
|
let data = e.detail;
|
|
@@ -11,19 +18,103 @@ Page({
|
|
else if (data.type == '2') wx.relaunch({ url })
|
|
else if (data.type == '2') wx.relaunch({ url })
|
|
else if (data.type == '3') wx.switchTab({ url })
|
|
else if (data.type == '3') wx.switchTab({ url })
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+ // 我的服务-功能按钮
|
|
|
|
+ toCommon: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ if (that.data.user._id) {
|
|
|
|
+ let { route } = e.currentTarget.dataset;
|
|
|
|
+ if (route) wx.navigateTo({ url: `/${route}` })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `暂无用户信息,无法查看`, icon: 'none' });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 获取头像
|
|
|
|
+ async toAvatarUrl(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { avatarUrl } = e.detail
|
|
|
|
+ let res = await app.$apifile('files/zkzx/schfriend/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' });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onLoad(options) {
|
|
|
|
|
|
+ async onLoad(options) {
|
|
const that = this;
|
|
const that = this;
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
wx.showLoading({ title: '加载中', mask: true })
|
|
- that.search()
|
|
|
|
|
|
+ await that.searchOther();
|
|
|
|
+ await that.searchConfig();
|
|
|
|
+ await that.search()
|
|
wx.hideLoading()
|
|
wx.hideLoading()
|
|
},
|
|
},
|
|
- // 查询通知
|
|
|
|
|
|
+ searchConfig() {
|
|
|
|
+ const that = this;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'config',
|
|
|
|
+ async success(res) {
|
|
|
|
+ // 管理员。
|
|
|
|
+ if (res.data && res.data.logo_url && res.data.logo_url.length > 0) {
|
|
|
|
+ let logo = res.data.logo_url[0].url
|
|
|
|
+ that.setData({ logo })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail(err) {
|
|
|
|
+ console.log(err);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
async search() {
|
|
async search() {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ async success(res) {
|
|
|
|
+ let arr = await app.$api(`user/${res.data._id}`, 'GET', {})
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ let user = arr.data;
|
|
|
|
+ // 审核字段处理
|
|
|
|
+ user.status_name = that.getDict(user.status, 'statusList')
|
|
|
|
+ // 头像字段处理
|
|
|
|
+ if (user.icon && user.icon.length > 0) {
|
|
|
|
+ let avatarUrl = user.icon[0].url
|
|
|
|
+ that.setData({ avatarUrl })
|
|
|
|
+ }
|
|
|
|
+ that.setData({ user })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error' });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ fail(err) {
|
|
|
|
+ console.log(err);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 过滤字典表
|
|
|
|
+ getDict(value, model) {
|
|
|
|
+ const that = this;
|
|
|
|
+ if (value) {
|
|
|
|
+ let list = that.data.statusList
|
|
|
|
+ let data = list.find(i => i.value == value);
|
|
|
|
+ if (data) return data.label
|
|
|
|
+ else return '暂无'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ async searchOther() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let res;
|
|
|
|
+ // 状态
|
|
|
|
+ res = await app.$api(`dictData`, 'GET', { type: 'status', is_use: '0' });
|
|
|
|
+ if (res.errcode == '0') that.setData({ statusList: res.data })
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|