zs 2 лет назад
Родитель
Сommit
30d9f5f5d0

+ 64 - 26
pages/school/coachInfo.js

@@ -1,66 +1,104 @@
-// pages/school/coachInfo.js
+const app = getApp()
 Page({
-
-    /**
-     * 页面的初始数据
-     */
     data: {
-
+        frameStyle: { useTop: true, name: '教练信息', leftArrow: true, useBar: false },
+        id: '',
+        form: {},
+        // 性别
+        genderList: [],
+        //运动等级
+        levelList: [],
+    },
+    // 跳转菜单
+    back(e) {
+        wx.navigateBack({ delta: 1 })
     },
-
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
-
+    onLoad: async function (options) {
+        const that = this;
+        await that.setData({ id: options.id || null })
+        // 查询其他信息
+        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: 'student_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;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                if (that.data.id) {
+                    const arr = await app.$get(`/coach/${that.data.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() {
-
-    },
-
+    onReady: function () { },
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow() {
+    onShow: function () {
 
     },
 
+    /**
+     * 页面上拉触底事件的处理函数
+     */
     /**
      * 生命周期函数--监听页面隐藏
      */
-    onHide() {
+    onHide: function () {
 
     },
 
     /**
      * 生命周期函数--监听页面卸载
      */
-    onUnload() {
+    onUnload: function () {
 
     },
 
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
-    onPullDownRefresh() {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
+    onPullDownRefresh: function () {
 
     },
 
     /**
      * 用户点击右上角分享
      */
-    onShareAppMessage() {
+    onShareAppMessage: function () {
 
     }
 })

+ 5 - 2
pages/school/coachInfo.json

@@ -1,3 +1,6 @@
 {
-    "usingComponents": {}
-}
+    "component": true,
+    "usingComponents": {
+      "mobile-main": "/commpents/mobile-frame/index"
+    }
+  }

+ 32 - 0
pages/school/coachInfo.less

@@ -0,0 +1,32 @@
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        width: 96vw;
+        padding: 0 2vw;
+
+        .one_1 {
+            display: flex;
+            flex-direction: row;
+            justify-content: space-between;
+            border: 1px dashed var(--f85Color);
+            border-radius: 5px;
+            margin: 0 0 10px 0;
+            padding: 10px;
+
+            .text {
+                color: var(--f85Color);
+                font-size: var(--font16Size);
+            }
+
+            .text1 {
+                font-size: var(--font16Size);
+            }
+
+            .image {
+                width: 15vw;
+                height: 15vw;
+            }
+        }
+    }
+}

+ 42 - 2
pages/school/coachInfo.wxml

@@ -1,2 +1,42 @@
-<!--pages/school/coachInfo.wxml-->
-<text>pages/school/coachInfo.wxml</text>
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <view class="one_1">
+                <text class="text">头像:</text>
+                <image class="image" src="{{form.icon&&form.icon.length>0?form.icon[0].url:''}}"></image>
+            </view>
+            <view class="one_1">
+                <text class="text">姓名:</text>
+                <text class="text1">{{form.name||'暂无昵称'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">性别:</text>
+                <text class="text1">{{form.zhGender||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">年龄:</text>
+                <text class="text1">{{form.age||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">电话:</text>
+                <text class="text1">{{form.phone||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">等级:</text>
+                <text class="text1">{{form.zhLevel||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">简介:</text>
+                <text class="text1">{{form.brief||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">荣誉:</text>
+                <text class="text1">{{form.honor||'暂无'}}</text>
+            </view>
+            <view class="one_1">
+                <text class="text">教学经历:</text>
+                <text class="text1">{{form.exp||'暂无'}}</text>
+            </view>
+        </view>
+    </view>
+</mobile-main>

+ 27 - 1
pages/school/coachInfo.wxss

@@ -1 +1,27 @@
-/* pages/school/coachInfo.wxss */
+.main {
+  background-color: var(--mainColor);
+}
+.main .one {
+  width: 96vw;
+  padding: 0 2vw;
+}
+.main .one .one_1 {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  border: 1px dashed var(--f85Color);
+  border-radius: 5px;
+  margin: 0 0 10px 0;
+  padding: 10px;
+}
+.main .one .one_1 .text {
+  color: var(--f85Color);
+  font-size: var(--font16Size);
+}
+.main .one .one_1 .text1 {
+  font-size: var(--font16Size);
+}
+.main .one .one_1 .image {
+  width: 15vw;
+  height: 15vw;
+}

+ 7 - 0
pages/school/info.js

@@ -43,6 +43,7 @@ Page({
         let data = e.detail;
         that.setData({ 'tabs.active': data.active })
     },
+    
     // 图片预览
     imgView: function (e) {
         const that = this;
@@ -78,6 +79,12 @@ Page({
         const { item } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/stuAdmin/course/sign?id=${item._id}` })
     },
+    //教练详细信息
+    coachView: function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pages/stuAdmin/coach/info?id=${item.coach_id}` })
+    },
     // 分页
     toPage: function () {
         const that = this;

+ 1 - 1
pages/stuAdmin/coach/info.less

@@ -3,7 +3,7 @@
 
     .one {
         width: 96vw;
-        padding: 0 2vw;
+        padding: 2vw;
 
         .one_1 {
             display: flex;

+ 1 - 1
pages/stuAdmin/coach/info.wxss

@@ -3,7 +3,7 @@
 }
 .main .one {
   width: 96vw;
-  padding: 0 2vw;
+  padding: 2vw;
 }
 .main .one .one_1 {
   display: flex;