|
@@ -1,38 +1,88 @@
|
|
|
-const app = getApp();
|
|
|
+const app = getApp()
|
|
|
Page({
|
|
|
- /**
|
|
|
- * 页面的初始数据
|
|
|
- */
|
|
|
data: {
|
|
|
- frameStyle: { useTop: true, name: '教练详细信息', leftArrow: true, useBar: false },
|
|
|
+ frameStyle: { useTop: true, name: '教练信息', leftArrow: true, useBar: false },
|
|
|
+ id: '',
|
|
|
+ form: {},
|
|
|
+ // 性别
|
|
|
+ genderList: [],
|
|
|
+ //教练等级
|
|
|
+ levelList: [],
|
|
|
},
|
|
|
// 跳转菜单
|
|
|
back(e) {
|
|
|
wx.navigateBack({ delta: 1 })
|
|
|
},
|
|
|
-
|
|
|
+ // 预览
|
|
|
+ toView(e) {
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ wx.previewImage({
|
|
|
+ current: '',
|
|
|
+ urls: [item.url]
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
-
|
|
|
+ onLoad: async function (options) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ id: options.id || '' })
|
|
|
+ // 查询其他信息
|
|
|
+ await that.searchOther();
|
|
|
+ // 监听用户是否登录
|
|
|
+ await that.watchLogin();
|
|
|
+ },
|
|
|
+ searchOther: async function () {
|
|
|
+ const that = this;
|
|
|
+ let arr;
|
|
|
+ // 性别
|
|
|
+ arr = await app.$get(`/dict`, { code: 'gender' });
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ genderList: arr.data[0].list });
|
|
|
+ // 教练等级
|
|
|
+ arr = await app.$get(`/dict`, { code: 'coach_grade' });
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ levelList: arr.data[0].list });
|
|
|
+ },
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchLogin: async function () {
|
|
|
+ const that = this;
|
|
|
+ let genderList = that.data.genderList;
|
|
|
+ let levelList = that.data.levelList;
|
|
|
+ let id = that.data.id;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ success: async res => {
|
|
|
+ if (id) {
|
|
|
+ let arr = await app.$get(`/coach/${id}`);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let gender = genderList.find(i => i.value == arr.data.gender)
|
|
|
+ if (gender) arr.data.zhGender = gender.label;
|
|
|
+ let level = levelList.find(i => i.value == arr.data.level)
|
|
|
+ if (level) arr.data.zhLevel = level.label;
|
|
|
+ that.setData({ form: arr.data })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: async res => {
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
- onReady: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
+ onReady: function () { },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- const that = this;
|
|
|
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
@@ -54,13 +104,6 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|