浏览代码

Merge branch 'master' of http://git.cc-lotus.info/ball-court/ball-applet

zs 2 年之前
父节点
当前提交
ab49f51fe0

+ 1 - 0
app.json

@@ -55,6 +55,7 @@
         "pages/coaAdmin/course/statuslist",
         "pages/coaAdmin/course/statuslist",
         "pages/coaAdmin/course/statusadd",
         "pages/coaAdmin/course/statusadd",
         "pages/coaAdmin/student/list",
         "pages/coaAdmin/student/list",
+        "pages/coaAdmin/student/add",
         "pages/coaAdmin/lecturestat/list",
         "pages/coaAdmin/lecturestat/list",
         "pages/coaAdmin/incomestat/list",
         "pages/coaAdmin/incomestat/list",
         "pages/coaAdmin/studentstat/list",
         "pages/coaAdmin/studentstat/list",

+ 1 - 0
pages/coaAdmin/course/statusadd.js

@@ -56,6 +56,7 @@ Page({
             return false
             return false
         } else {
         } else {
             console.log(params);
             console.log(params);
+            //  config: { type: Object, required: false, zh: '设置' }, // 打折方式 discount_type:fixed 固定;subtract 减; discount折 ;number
         }
         }
     },
     },
     /**
     /**

+ 3 - 3
pages/coaAdmin/course/statusadd.wxml

@@ -2,19 +2,19 @@
     <view slot="info" class="container main">
     <view slot="info" class="container main">
         <view class="one">
         <view class="one">
             <form catchsubmit="onSubmit">
             <form catchsubmit="onSubmit">
-                <view class="content">
+                <view class="content" style="display: none;">
                     <view class="label">数据id:</view>
                     <view class="label">数据id:</view>
                     <view class="value">
                     <view class="value">
                         <input type="text" name="_id" value="{{form._id}}" placeholder="请输入数据id" />
                         <input type="text" name="_id" value="{{form._id}}" placeholder="请输入数据id" />
                     </view>
                     </view>
                 </view>
                 </view>
-                <view class="content">
+                <view class="content" style="display: none;">
                     <view class="label">学校id:</view>
                     <view class="label">学校id:</view>
                     <view class="value">
                     <view class="value">
                         <input type="text" name="school_id" value="{{form.school_id}}" placeholder="请输入学校id" />
                         <input type="text" name="school_id" value="{{form.school_id}}" placeholder="请输入学校id" />
                     </view>
                     </view>
                 </view>
                 </view>
-                <view class="content">
+                <view class="content" style="display: none;">
                     <view class="label">课程id:</view>
                     <view class="label">课程id:</view>
                     <view class="value">
                     <view class="value">
                         <input type="text" name="lesson_id" value="{{form.lesson_id}}" placeholder="请输入课程id" />
                         <input type="text" name="lesson_id" value="{{form.lesson_id}}" placeholder="请输入课程id" />

+ 89 - 14
pages/coaAdmin/money/add.js

@@ -1,66 +1,141 @@
-// pages/coaAdmin/money/add.js
+const app = getApp()
+import WxValidate from '../../../utils/wxValidate';
+const moment = require("../../../utils/moment.min")
 Page({
 Page({
 
 
     /**
     /**
      * 页面的初始数据
      * 页面的初始数据
      */
      */
     data: {
     data: {
-
+        frameStyle: { useTop: true, name: '账号充值', leftArrow: true, useBar: false },
+        user: {},
+        // 关系信息
+        id: '',
+        rcsInfo: {},
+        form: {}
+    },
+    initValidate() {
+        const rules = { money: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { money: { required: '充值金额' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        const rcsInfo = that.data.rcsInfo;
+        const user = that.data.user;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let obj = { school_id: rcsInfo.school_id, openid: user.openid, payer_id: user.info.id, payer_role: 'Coach', pay_for: '充值', money: params.money, time: moment().format('YYYY-MM-DD HH:mm:ss') }
+            const arr = await app.$post(`/payOrder`, obj)
+            if (arr.errcode == '0') {
+                wx.requestPayment({
+                    "timeStamp": arr.data.wxSign.timestamp,
+                    "nonceStr": arr.data.wxSign.nonceStr,
+                    "package": `prepay_id=${arr.data.wxSign.prepay_id}`,
+                    "signType": arr.data.wxSign.signType,
+                    "paySign": arr.data.wxSign.paySign,
+                    "success": async function (res) {
+                        let money = parseInt(rcsInfo.money || 0) + parseFloat(params.money);
+                        const aee = await app.$post(`/rcs/${rcsInfo._id}`, { money: money });
+                        if (aee.errcode == '0') {
+                            wx.showToast({ title: `支付成功`, icon: 'success', duration: 2000 });
+                            that.back()
+                        } else { wx.showToast({ title: `${aee.errmsg}`, icon: 'error', duration: 2000 }) }
+                    },
+                    "fail": function (res) {
+                        wx.showToast({ title: `支付未成功`, icon: 'error', duration: 2000 })
+                        that.back()
+                    },
+                })
+            }
+        }
     },
     },
-
     /**
     /**
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
-    onLoad(options) {
-
+    onLoad: async function (options) {
+        const that = this;
+        that.setData({ id: options.id || '62ff243908c3ce998df1602a' });
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                that.setData({ user: res.data })
+                let arr;
+                if (that.data.id) {
+                    // 关系信息
+                    arr = await app.$get(`/rcs/${that.data.id}`);
+                    if (arr.errcode == '0') that.setData({ rcsInfo: 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() {
+    onPullDownRefresh: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 页面上拉触底事件的处理函数
      * 页面上拉触底事件的处理函数
      */
      */
-    onReachBottom() {
+    onReachBottom: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 用户点击右上角分享
      * 用户点击右上角分享
      */
      */
-    onShareAppMessage() {
+    onShareAppMessage: function () {
 
 
     }
     }
 })
 })

+ 4 - 1
pages/coaAdmin/money/add.json

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

+ 34 - 0
pages/coaAdmin/money/add.less

@@ -0,0 +1,34 @@
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+                textarea {
+                    position: static;
+                    width: 73vw;
+                }
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 5vw 0 0 0;
+
+            button {
+                width: 40vw;
+                margin: 0 2vw;
+                padding: 1vw 0;
+            }
+        }
+    }
+}

+ 17 - 2
pages/coaAdmin/money/add.wxml

@@ -1,2 +1,17 @@
-<!--pages/coaAdmin/money/add.wxml-->
-<text>pages/coaAdmin/money/add.wxml</text>
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <form catchsubmit="onSubmit">
+                <view class="content">
+                    <view class="label">充值金额:</view>
+                    <view class="value">
+                        <input type="number" name="money" value="{{form.money}}" placeholder="请输入充值金额" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交充值</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 27 - 1
pages/coaAdmin/money/add.wxss

@@ -1 +1,27 @@
-/* pages/coaAdmin/money/add.wxss */
+.main {
+  background-color: var(--mainColor);
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
+}
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
+}
+.main .one .content .value textarea {
+  position: static;
+  width: 73vw;
+}
+.main .one .btn {
+  text-align: center;
+  margin: 5vw 0 0 0;
+}
+.main .one .btn button {
+  width: 40vw;
+  margin: 0 2vw;
+  padding: 1vw 0;
+}

+ 64 - 12
pages/coaAdmin/money/list.js

@@ -1,66 +1,118 @@
-// pages/stuAdmin/money/list.js
+const app = getApp()
 Page({
 Page({
 
 
     /**
     /**
      * 页面的初始数据
      * 页面的初始数据
      */
      */
     data: {
     data: {
-
+        frameStyle: { useTop: true, name: '账号余额', leftArrow: true, useBar: false },
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    //添加信息,信息维护
+    toCommon: function (e) {
+        const that = this;
+        const { item, route } = e.currentTarget.dataset;
+        that.setData({ skip: 0, page: 0, list: [] });
+        wx.navigateTo({ url: `/pages/${route}?id=${item && item._id ? item._id : ''}` })
+    },
+    // 分页
+    toPage: function () {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page: page })
+            let skip = page * limit;
+            that.setData({ skip: skip })
+            that.watchLogin();
+            wx.hideLoading()
+        } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
     },
     },
-
     /**
     /**
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
-    onLoad(options) {
+    onLoad: function (options) {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面初次渲染完成
      * 生命周期函数--监听页面初次渲染完成
      */
      */
-    onReady() {
+    onReady: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面显示
      * 生命周期函数--监听页面显示
      */
      */
-    onShow() {
-
+    onShow: async function () {
+        const that = this;
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let info = { skip: that.data.skip, limit: that.data.limit, coach_id: res.data.info.id };
+                let arr = await app.$get(`/rcs`, { ...info });
+                if (arr.errcode == '0') {
+                    let list = [...that.data.list, ...arr.data];
+                    console.log(list);
+                    that.setData({ list: list })
+                    that.setData({ total: arr.total })
+                } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面隐藏
      * 生命周期函数--监听页面隐藏
      */
      */
-    onHide() {
+    onHide: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面卸载
      * 生命周期函数--监听页面卸载
      */
      */
-    onUnload() {
+    onUnload: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      * 页面相关事件处理函数--监听用户下拉动作
      */
      */
-    onPullDownRefresh() {
+    onPullDownRefresh: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 页面上拉触底事件的处理函数
      * 页面上拉触底事件的处理函数
      */
      */
-    onReachBottom() {
+    onReachBottom: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 用户点击右上角分享
      * 用户点击右上角分享
      */
      */
-    onShareAppMessage() {
+    onShareAppMessage: function () {
 
 
     }
     }
 })
 })

+ 4 - 1
pages/coaAdmin/money/list.json

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

+ 91 - 0
pages/coaAdmin/money/list.less

@@ -0,0 +1,91 @@
+.main {
+    height: var(--twoHeight);
+    background-color: var(--mainColor);
+
+    .one {
+        display: flex;
+        flex-direction: row;
+        padding: 2vw;
+        border-bottom: 1px solid var(--f1Color);
+
+        .one_1 {
+            flex-grow: 1;
+
+            input {
+                padding: 1vw 0 2vw 2vw;
+                background-color: var(--f1Color);
+                border-radius: 5px;
+            }
+        }
+
+        .one_2 {
+            width: 20vw;
+
+            button {
+                width: 100%;
+                padding: 2vw;
+                font-size: var(--font14Size);
+            }
+        }
+    }
+
+    .two {
+        flex-grow: 1;
+        position: relative;
+        width: 96vw;
+        margin: 2vw;
+        background-color: var(--mainColor);
+
+        .list {
+            display: flex;
+            flex-direction: column;
+            border: 2px dashed var(--f1Color);
+            padding: 2vw;
+            margin: 0 0 2vw 0;
+            border-radius: 10px;
+
+            .name {
+                font-size: var(--font16Szie);
+                font-weight: bold;
+                margin: 0 0 2vw 0;
+                color: var(--redColor);
+            }
+
+            .other {
+                margin: 0 0 2vw 0;
+
+                .other_1 {
+                    font-size: var(--font14Szie);
+                    margin: 0 0 1vw 0;
+
+                    text:first-child {
+                        color: var(--f85Color);
+                    }
+                }
+            }
+
+            .btn {
+                margin: 2vw 0 0 0;
+                text-align: center;
+
+                button {
+                    margin: 0 2vw;
+                }
+            }
+        }
+
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
+    }
+}

+ 30 - 2
pages/coaAdmin/money/list.wxml

@@ -1,2 +1,30 @@
-<!--pages/stuAdmin/money/list.wxml-->
-<text>pages/stuAdmin/money/list.wxml</text>
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <view class="one_1">
+                <input type="text" placeholder="请输入关键词" />
+            </view>
+            <!-- <view class="one_2">
+                <button type="primary" bindtap="toCommon" data-route="coaAdmin/money/add">充值</button>
+            </view> -->
+        </view>
+        <view class="two">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="item">
+                        <view class="name">{{item.money||0}}元</view>
+                        <view class="other">
+                            <!-- <view class="other_1"><text>教练姓名:</text><text>{{item.coach_id_name}}</text></view>
+                            <view class="other_1"><text>教练联系方式:</text><text>{{item.coach_id_phone}}</text></view> -->
+                            <view class="other_1"><text>学校名称:</text><text>{{item.school_id_name}}</text></view>
+                            <view class="other_1"><text>学校联系方式:</text><text>{{item.school_id_phone}}</text></view>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toCommon" data-route="coaAdmin/money/add" data-item="{{item}}">充值</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+    </view>
+</mobile-main>

+ 75 - 1
pages/coaAdmin/money/list.wxss

@@ -1 +1,75 @@
-/* pages/stuAdmin/money/list.wxss */
+.main {
+  height: var(--twoHeight);
+  background-color: var(--mainColor);
+}
+.main .one {
+  display: flex;
+  flex-direction: row;
+  padding: 2vw;
+  border-bottom: 1px solid var(--f1Color);
+}
+.main .one .one_1 {
+  flex-grow: 1;
+}
+.main .one .one_1 input {
+  padding: 1vw 0 2vw 2vw;
+  background-color: var(--f1Color);
+  border-radius: 5px;
+}
+.main .one .one_2 {
+  width: 20vw;
+}
+.main .one .one_2 button {
+  width: 100%;
+  padding: 2vw;
+  font-size: var(--font14Size);
+}
+.main .two {
+  flex-grow: 1;
+  position: relative;
+  width: 96vw;
+  margin: 2vw;
+  background-color: var(--mainColor);
+}
+.main .two .list {
+  display: flex;
+  flex-direction: column;
+  border: 2px dashed var(--f1Color);
+  padding: 2vw;
+  margin: 0 0 2vw 0;
+  border-radius: 10px;
+}
+.main .two .list .name {
+  font-size: var(--font16Szie);
+  font-weight: bold;
+  margin: 0 0 2vw 0;
+  color: var(--redColor);
+}
+.main .two .list .other {
+  margin: 0 0 2vw 0;
+}
+.main .two .list .other .other_1 {
+  font-size: var(--font14Szie);
+  margin: 0 0 1vw 0;
+}
+.main .two .list .other .other_1 text:first-child {
+  color: var(--f85Color);
+}
+.main .two .list .btn {
+  margin: 2vw 0 0 0;
+  text-align: center;
+}
+.main .two .list .btn button {
+  margin: 0 2vw;
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}

+ 177 - 0
pages/coaAdmin/student/add.js

@@ -0,0 +1,177 @@
+const app = getApp()
+import WxValidate from '../../../utils/wxValidate';
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '学员信息维护', leftArrow: true, useBar: false },
+        id: '',
+        form: {},
+        user: {},
+        // 教练学校
+        coachSchool: {},
+        // 学校学员
+        studentList: [],
+        // 折扣设置
+        discount_typeList: []
+    },
+    initValidate() {
+        const rules = { student_id: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { student_id: { required: '请选择学员' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    // 选择学生
+    stuChange: function (e) {
+        const that = this;
+        let data = that.data.studentList[e.detail.value];
+        if (data) {
+            console.log(data);
+            that.setData({ 'form.student_id': data.student_id })
+            that.setData({ 'form.student_id_name': data.student_id_name })
+        }
+    },
+    // 选择折扣类型
+    typeChange: function (e) {
+        const that = this;
+        let data = that.data.discount_typeList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.config.discount_type': data.value });
+            that.setData({ 'form.config.number': null })
+        }
+    },
+    // 折扣判断
+    moneyInput: function (e) {
+        const that = this;
+        const form = that.data.form;
+        if (form.config && form.config.discount_type && form.config.discount_type == 'discount') {
+            var regex = /^(10|\d)(\.\d{1,1})?$/;
+            if (!regex.test(e.detail.value)) {
+                wx.showToast({ title: `数据不允许`, icon: 'error', duration: 1000 });
+                that.setData({ 'form.config.number': null })
+            }
+        }
+    },
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            params.config = { discount_type: params['config.discount_type'], number: params['config.number'] }
+            let arr;
+            if (that.data.id) arr = await app.$post(`/rsc/${that.data.id}`, params);
+            else arr = await app.$post(`/rsc`, params);
+            if (arr.errcode == '0') {
+                wx.showToast({ title: `信息维护成功`, icon: 'success', duration: 2000 });
+                that.back()
+            } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+        }
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: async function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' });
+        //验证规则函数
+        that.initValidate();
+        // 查询其他信息
+        await that.searchOther();
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        // 折扣设置
+        arr = await app.$get(`/dict`, { code: 'rsc_type' });
+        if (arr.errcode == '0' && arr.total > 0) { that.setData({ discount_typeList: arr.data[0].list }) }
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                that.setData({ user: res.data });
+                // 查询教练学校
+                let arr;
+                arr = await app.$get(`/rcs`, { coach_id: res.data.info.id });
+                if (arr.errcode == '0' && arr.total > 0) that.setData({ coachSchool: arr.data[0] });
+                // 查询学校学员
+                arr = await app.$get(`/rss`, { school_id: that.data.coachSchool.school_id });
+                if (arr.errcode == '0') that.setData({ studentList: arr.data });
+                let form = { school_id: that.data.coachSchool.school_id, coach_id: that.data.user.info.id }
+                if (that.data.id) {
+                    arr = await app.$get(`/rsc/${that.data.id}`);
+                    if (arr.errcode == '0') {
+                        let student = that.data.studentList.find(i => i.student_id == arr.data.student_id);
+                        if (student) arr.data.student_id_name = student.student_id_name;
+                        form = arr.data;
+                    }
+                }
+                that.setData({ form })
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () { },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/coaAdmin/student/add.json

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

+ 34 - 0
pages/coaAdmin/student/add.less

@@ -0,0 +1,34 @@
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+                textarea {
+                    position: static;
+                    width: 73vw;
+                }
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 5vw 0 0 0;
+
+            button {
+                width: 40vw;
+                margin: 0 2vw;
+                padding: 1vw 0;
+            }
+        }
+    }
+}

+ 51 - 0
pages/coaAdmin/student/add.wxml

@@ -0,0 +1,51 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <form catchsubmit="onSubmit">
+                <view class="content" style="display: none;">
+                    <view class="label">数据id:</view>
+                    <view class="value">
+                        <input type="text" name="_id" value="{{form._id}}" placeholder="请输入数据id" />
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">学校id:</view>
+                    <view class="value">
+                        <input type="text" name="school_id" value="{{form.school_id}}" placeholder="请输入学校id" />
+                    </view>
+                </view>
+                <view class="content" style="display: none;">
+                    <view class="label">教练id:</view>
+                    <view class="value">
+                        <input type="text" name="coach_id" value="{{form.coach_id}}" placeholder="请输入教练id" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">学生:</view>
+                    <view class="value">
+                        <picker mode="selector" name="student_id" value="{{form.student_id}}" bindchange="stuChange" range="{{studentList}}" range-key="student_id_name">
+                            <view class="picker">{{form.student_id_name||'请选择学生'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">折扣方式:</view>
+                    <view class="value">
+                        <picker mode="selector" name="config.discount_type" value="{{form.config.discount_type}}" bindchange="typeChange" range="{{discount_typeList}}" range-key="label">
+                            <view class="picker">{{form.config.discount_type||'请选择折扣方式'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">折扣金额:</view>
+                    <view class="value">
+                        <input type="digit" name="config.number" value="{{form.config.number}}" bindblur="moneyInput" placeholder="请输入折扣金额" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 27 - 0
pages/coaAdmin/student/add.wxss

@@ -0,0 +1,27 @@
+.main {
+  background-color: var(--mainColor);
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
+}
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
+}
+.main .one .content .value textarea {
+  position: static;
+  width: 73vw;
+}
+.main .one .btn {
+  text-align: center;
+  margin: 5vw 0 0 0;
+}
+.main .one .btn button {
+  width: 40vw;
+  margin: 0 2vw;
+  padding: 1vw 0;
+}

+ 79 - 12
pages/coaAdmin/student/list.js

@@ -1,66 +1,133 @@
-// pages/coaAdmin/mystudent/list.js
+const app = getApp()
 Page({
 Page({
 
 
     /**
     /**
      * 页面的初始数据
      * 页面的初始数据
      */
      */
     data: {
     data: {
-
+        frameStyle: { useTop: true, name: '学员信息', leftArrow: true, useBar: false },
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
+        // 折扣设置
+        discount_typeList: []
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    //添加信息,信息维护
+    toCommon: function (e) {
+        const that = this;
+        const { item, route } = e.currentTarget.dataset;
+        that.setData({ skip: 0, page: 0, list: [] });
+        wx.navigateTo({ url: `/pages/${route}?id=${item && item._id ? item._id : ''}` })
+    },
+    // 分页
+    toPage: function () {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page: page })
+            let skip = page * limit;
+            that.setData({ skip: skip })
+            that.watchLogin();
+            wx.hideLoading()
+        } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
     },
     },
-
     /**
     /**
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
-    onLoad(options) {
+    onLoad: function (options) {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面初次渲染完成
      * 生命周期函数--监听页面初次渲染完成
      */
      */
-    onReady() {
+    onReady: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面显示
      * 生命周期函数--监听页面显示
      */
      */
-    onShow() {
-
+    onShow: async function () {
+        const that = this;
+        // 查询其他信息
+        await that.searchOther();
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        // 折扣设置
+        arr = await app.$get(`/dict`, { code: 'rsc_type' });
+        if (arr.errcode == '0' && arr.total > 0) { that.setData({ discount_typeList: arr.data[0].list }) }
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        const discount_typeList = that.data.discount_typeList;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let info = { skip: that.data.skip, limit: that.data.limit, coach_id: res.data.info.id };
+                let arr = await app.$get(`/rsc`, { ...info });
+                if (arr.errcode == '0') {
+                    let list = [...that.data.list, ...arr.data];
+                    for (const val of list) {
+                        let discount_type = discount_typeList.find(i => i.value == val.config.discount_type);
+                        if (discount_type) val.config.zhDiscount_type = discount_type.label;
+                    }
+                    that.setData({ list: list })
+                    that.setData({ total: arr.total })
+                } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面隐藏
      * 生命周期函数--监听页面隐藏
      */
      */
-    onHide() {
+    onHide: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 生命周期函数--监听页面卸载
      * 生命周期函数--监听页面卸载
      */
      */
-    onUnload() {
+    onUnload: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      * 页面相关事件处理函数--监听用户下拉动作
      */
      */
-    onPullDownRefresh() {
+    onPullDownRefresh: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 页面上拉触底事件的处理函数
      * 页面上拉触底事件的处理函数
      */
      */
-    onReachBottom() {
+    onReachBottom: function () {
 
 
     },
     },
 
 
     /**
     /**
      * 用户点击右上角分享
      * 用户点击右上角分享
      */
      */
-    onShareAppMessage() {
+    onShareAppMessage: function () {
 
 
     }
     }
 })
 })

+ 4 - 1
pages/coaAdmin/student/list.json

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

+ 91 - 0
pages/coaAdmin/student/list.less

@@ -0,0 +1,91 @@
+.main {
+    height: var(--twoHeight);
+    background-color: var(--mainColor);
+
+    .one {
+        display: flex;
+        flex-direction: row;
+        padding: 2vw;
+        border-bottom: 1px solid var(--f1Color);
+
+        .one_1 {
+            flex-grow: 1;
+
+            input {
+                padding: 1vw 0 2vw 2vw;
+                background-color: var(--f1Color);
+                border-radius: 5px;
+            }
+        }
+
+        .one_2 {
+            width: 20vw;
+
+            button {
+                width: 100%;
+                padding: 2vw;
+                font-size: var(--font14Size);
+            }
+        }
+    }
+
+    .two {
+        flex-grow: 1;
+        position: relative;
+        width: 96vw;
+        margin: 2vw;
+        background-color: var(--mainColor);
+
+        .list {
+            display: flex;
+            flex-direction: column;
+            border: 2px dashed var(--f1Color);
+            padding: 2vw;
+            margin: 0 0 2vw 0;
+            border-radius: 10px;
+
+            .name {
+                font-size: var(--font16Szie);
+                font-weight: bold;
+                margin: 0 0 2vw 0;
+                color: var(--redColor);
+            }
+
+            .other {
+                margin: 0 0 2vw 0;
+
+                .other_1 {
+                    font-size: var(--font14Szie);
+                    margin: 0 0 1vw 0;
+
+                    text:first-child {
+                        color: var(--f85Color);
+                    }
+                }
+            }
+
+            .btn {
+                margin: 2vw 0 0 0;
+                text-align: center;
+
+                button {
+                    margin: 0 2vw;
+                }
+            }
+        }
+
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
+    }
+}

+ 29 - 2
pages/coaAdmin/student/list.wxml

@@ -1,2 +1,29 @@
-<!--pages/coaAdmin/mystudent/list.wxml-->
-<text>pages/coaAdmin/mystudent/list.wxml</text>
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <view class="one_1">
+                <input type="text" placeholder="请输入关键词" />
+            </view>
+            <view class="one_2">
+                <button type="primary" bindtap="toCommon" data-route="coaAdmin/student/add">添加</button>
+            </view>
+        </view>
+        <view class="two">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="item">
+                        <view class="name">{{item.student_id_name}}</view>
+                        <view class="other">
+                            <view class="other_1"><text>折扣类型:</text><text>{{item.config.zhDiscount_type}}</text></view>
+                            <view class="other_1"><text>折扣金额:</text><text>{{item.config.number}}</text></view>
+                            <view class="other_1"><text>所在学校:</text><text>{{item.school_id_name}}</text></view>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toCommon" data-route="coaAdmin/student/add" data-item="{{item}}">信息维护</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+    </view>
+</mobile-main>

+ 75 - 1
pages/coaAdmin/student/list.wxss

@@ -1 +1,75 @@
-/* pages/coaAdmin/mystudent/list.wxss */
+.main {
+  height: var(--twoHeight);
+  background-color: var(--mainColor);
+}
+.main .one {
+  display: flex;
+  flex-direction: row;
+  padding: 2vw;
+  border-bottom: 1px solid var(--f1Color);
+}
+.main .one .one_1 {
+  flex-grow: 1;
+}
+.main .one .one_1 input {
+  padding: 1vw 0 2vw 2vw;
+  background-color: var(--f1Color);
+  border-radius: 5px;
+}
+.main .one .one_2 {
+  width: 20vw;
+}
+.main .one .one_2 button {
+  width: 100%;
+  padding: 2vw;
+  font-size: var(--font14Size);
+}
+.main .two {
+  flex-grow: 1;
+  position: relative;
+  width: 96vw;
+  margin: 2vw;
+  background-color: var(--mainColor);
+}
+.main .two .list {
+  display: flex;
+  flex-direction: column;
+  border: 2px dashed var(--f1Color);
+  padding: 2vw;
+  margin: 0 0 2vw 0;
+  border-radius: 10px;
+}
+.main .two .list .name {
+  font-size: var(--font16Szie);
+  font-weight: bold;
+  margin: 0 0 2vw 0;
+  color: var(--redColor);
+}
+.main .two .list .other {
+  margin: 0 0 2vw 0;
+}
+.main .two .list .other .other_1 {
+  font-size: var(--font14Szie);
+  margin: 0 0 1vw 0;
+}
+.main .two .list .other .other_1 text:first-child {
+  color: var(--f85Color);
+}
+.main .two .list .btn {
+  margin: 2vw 0 0 0;
+  text-align: center;
+}
+.main .two .list .btn button {
+  margin: 0 2vw;
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}