Procházet zdrojové kódy

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

guhongwei před 2 roky
rodič
revize
9e02a0dc9c

+ 114 - 23
pagesSchool/stuAdmin/course/list.js

@@ -1,38 +1,135 @@
 const app = getApp();
+import { is_pay } from '../../../utils/dict';
+const moment = require("../../../utils/moment.min")
 Page({
     /**
      * 页面的初始数据
      */
     data: {
         frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
+        // 支付状态
+        is_payList: is_pay,
+        // 课程状态
+        statusList: [],
     },
-    // 跳转菜单
-    back(e) {
-        wx.navigateBack({ delta: 1 })
+    // 返回
+    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: `${route}?id=${item && item.lesson_id ? item.lesson_id : ''}` })
+    },
+    // 支付
+    toPay: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认支付?',
+            async success(res) {
+                if (res.confirm) {
+                    console.log('支付');
+                }
+            }
+        })
+    },
+    // 退款
+    toRefund: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        let time = moment().format('YYYY-MM-DD HH:mm:ss');
+        let data = moment(time).isBefore(item.lesson_id_refund_hour);
+        if (data == true) {
+            wx.showModal({
+                title: '提示',
+                content: '是否确认退款?',
+                async success(res) {
+                    if (res.confirm) {
+                        console.log('退款');
+                    }
+                }
+            })
+        } else {
+            wx.showToast({ title: '超过退款期限无法退款', icon: 'none', duration: 2000 })
+        }
+    },
+    // 分页
+    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: function (options) {
-
-    },
+    onLoad: function (options) { },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
-    onReady: function () {
-
-    },
-
+    onReady: function () { },
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow: function () {
+    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: 'lesson_status' });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let info = { skip: that.data.skip, limit: that.data.limit, student_id: res.data.info._id };
+                let arr = await app.$get(`/lessonStudent`, { ...info });
+                if (arr.errcode == '0') {
+                    let list = [...that.data.list, ...arr.data];
+                    for (const val of list) {
+                        // 课程状态
+                        let status = that.data.statusList.find(i => i.value == val.lesson_id_status)
+                        if (status) val.zhStatus = status.label;
+                        // 支付状态
+                        let pay = is_pay.find(i => i.value == val.is_pay)
+                        if (pay) val.zhPay = pay.label;
+                    }
+                    that.setData({ 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' })
+            }
+        })
     },
-
-
+    /**
+     * 页面上拉触底事件的处理函数
+     */
     /**
      * 生命周期函数--监听页面隐藏
      */
@@ -44,7 +141,8 @@ Page({
      * 生命周期函数--监听页面卸载
      */
     onUnload: function () {
-
+        const that = this;
+        that.setData({ skip: 0, page: 0, list: [] })
     },
 
     /**
@@ -54,13 +152,6 @@ Page({
 
     },
 
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom: function () {
-
-    },
-
     /**
      * 用户点击右上角分享
      */

+ 82 - 1
pagesSchool/stuAdmin/course/list.less

@@ -1 +1,82 @@
-@import (css) "/app.wxss";
+@import (css) "/app.wxss";
+
+.main {
+    height: var(--twoHeight);
+    background-color: var(--mainColor);
+
+
+    .one {
+        width: 96vw;
+        padding: 2vw;
+        border-bottom: 1px solid var(--f1Color);
+
+        input {
+            padding: 1vw 0 2vw 2vw;
+            background-color: var(--f1Color);
+            border-radius: 5px;
+        }
+    }
+
+    .two {
+        position: relative;
+        flex-grow: 1;
+        background-color: var(--whiteColor);
+        padding: 0 2vw;
+
+        .list {
+            background-color: var(--f9Color);
+            margin: 0 0 2vw 0;
+            padding: 2vw;
+            margin: 0 2vw 2vw 2vw;
+            border-radius: 5px;
+            text-align: center;
+
+            .name {
+                font-size: var(--font16Szie);
+                font-weight: bold;
+                margin: 0 0 2vw 0;
+            }
+
+            .time {
+                margin: 0 0 1vw 0;
+                font-size: var(--font14Size);
+            }
+
+            .other {
+                display: flex;
+                justify-content: space-around;
+                margin: 0 0 2vw 0;
+
+                .other_1 {
+                    margin: 0 0 1vw 0;
+                    font-size: var(--font14Size);
+
+                    text:first-child {
+                        color: var(--f85Color);
+                    }
+                }
+            }
+
+            .btn {
+
+                button {
+                    margin: 0 2vw;
+                    font-size: var(--font14Size);
+                }
+            }
+        }
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
+    }
+}

+ 28 - 1
pagesSchool/stuAdmin/course/list.wxml

@@ -1,5 +1,32 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
-        <view>课程信息</view>
+        <view class="one">
+            <input type="text" placeholder="请输入关键词" />
+        </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.lesson_id_title||'暂无'}}</view>
+                        <view class="time">{{item.lesson_id_time_start||'暂无'}} - {{item.lesson_id_time_end||'暂无'}}</view>
+                        <view class="other">
+                            <view class="other_1">
+                                <text>课程状态:</text>
+                                <text>{{item.zhStatus||'暂无'}}</text>
+                            </view>
+                            <view class="other_1">
+                                <text>支付状态:</text>
+                                <text>{{item.zhPay||'暂无'}}</text>
+                            </view>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toCommon" data-route="/pagesSchool/common/lessoninfo" data-item="{{item}}">详细信息</button>
+                            <button wx:if="{{item.is_pay=='0'}}" type="primary" size="mini" bindtap="toPay" data-item="{{item}}">支付</button>
+                            <button wx:if="{{item.lesson_id_status=='1'||item.lesson_id_status=='2'}}" type="warn" size="mini" bindtap="toRefund" data-item="{{item}}">退课</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </mobile-main>

+ 65 - 1
pagesSchool/stuAdmin/course/list.wxss

@@ -1 +1,65 @@
-@import "/app.wxss";
+@import "/app.wxss";
+.main {
+  height: var(--twoHeight);
+  background-color: var(--mainColor);
+}
+.main .one {
+  width: 96vw;
+  padding: 2vw;
+  border-bottom: 1px solid var(--f1Color);
+}
+.main .one input {
+  padding: 1vw 0 2vw 2vw;
+  background-color: var(--f1Color);
+  border-radius: 5px;
+}
+.main .two {
+  position: relative;
+  flex-grow: 1;
+  background-color: var(--whiteColor);
+  padding: 0 2vw;
+}
+.main .two .list {
+  background-color: var(--f9Color);
+  margin: 0 0 2vw 0;
+  padding: 2vw;
+  margin: 0 2vw 2vw 2vw;
+  border-radius: 5px;
+  text-align: center;
+}
+.main .two .list .name {
+  font-size: var(--font16Szie);
+  font-weight: bold;
+  margin: 0 0 2vw 0;
+}
+.main .two .list .time {
+  margin: 0 0 1vw 0;
+  font-size: var(--font14Size);
+}
+.main .two .list .other {
+  display: flex;
+  justify-content: space-around;
+  margin: 0 0 2vw 0;
+}
+.main .two .list .other .other_1 {
+  margin: 0 0 1vw 0;
+  font-size: var(--font14Size);
+}
+.main .two .list .other .other_1 text:first-child {
+  color: var(--f85Color);
+}
+.main .two .list .btn button {
+  margin: 0 2vw;
+  font-size: var(--font14Size);
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}

+ 7 - 0
utils/dict.js

@@ -216,6 +216,13 @@ export const pay_status = [
     { value: '-2', label: '申请退款' },
     { value: '-3', label: '退款成功' },
 ]
+// 课程支付状态
+export const is_pay = [
+    { value: '0', label: '未支付' },
+    { value: '1', label: '已支付' },
+    { value: '-1', label: '支付失败' },
+    { value: '-3', label: '已退款' },
+]
 export const is_use = [
     { label: '启用', value: '0' },
     { label: '禁用', value: '1' },