浏览代码

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

guhongwei 2 年之前
父节点
当前提交
fec1183f4b

+ 2 - 5
pages/stuAdmin/course/sign.js

@@ -1,4 +1,5 @@
 const app = getApp()
+const moment = require("../../../utils/moment.min")
 Page({
     data: {
         frameStyle: { useTop: true, name: '详细信息', leftArrow: true, useBar: false },
@@ -56,13 +57,9 @@ Page({
         const that = this;
         const form = that.data.form;
         const user = that.data.user;
-        var payer_role = '';
         var money = '';
         if (form.type == '0') money = form.real_money;
         else if (form.type == '1') money = form.money;
-        if (user.type == '0') payer_role = 'User';
-        else if (user.type == '2') payer_role = 'Coach';
-        else if (user.type == '3') payer_role = 'Student';
         wx.showModal({
             title: '提示',
             content: '您是否确定报名?',
@@ -71,7 +68,7 @@ Page({
                     wx.getStorage({
                         key: 'user',
                         success: async (res) => {
-                            let obj = { openid: res.data.openid, money: 0.1, school_id: form.school_id, payer_id: user.info.id, payer_role: payer_role, pay_for: 'lessonStudent' }
+                            let obj = { openid: res.data.openid, money: money, school_id: form.school_id, payer_id: user.info.id, payer_role: 'Student', pay_for: 'lessonStudent', time: moment().format('YYYY-MM-DD HH:mm:ss') }
                             const arr = await app.$post(`/payOrder`, obj)
                             if (arr.errcode == '0') {
                                 wx.requestPayment({

+ 1 - 1
pages/stuAdmin/course/sign.wxml

@@ -48,7 +48,7 @@
                                 <text class="text">是否试课:</text>
                                 <button type="primary" size="mini" bindtap="toClass">试课</button>
                             </view>
-                            <view class="btn" wx:if="{{user.type=='3'&&form.sign=='0'}}">
+                            <view class="btn" wx:if="{{form.type_try=='0'&&user.type=='3'&&form.sign=='0'}}">
                                 <button type="primary" size="mini" formType="submit">报名</button>
                             </view>
                         </form>

+ 111 - 17
pages/stuAdmin/money/add.js

@@ -1,66 +1,160 @@
-// pages/stuAdmin/money/add.js
+const app = getApp()
+import WxValidate from '../../../utils/wxValidate';
+const moment = require("../../../utils/moment.min")
 Page({
-
-    /**
-     * 页面的初始数据
-     */
     data: {
-
+        frameStyle: { useTop: true, name: '充值', leftArrow: true, useBar: false },
+        id: '',
+        form: {},
+        user: {},
+    },
+    initValidate() {
+        const rules = { paymoney: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { paymoney: { required: '请输入金额' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    //提交
+    onSubmit: async function (e) {
+        const that = this;
+        const user = that.data.user;
+        const form = that.data.form;
+        const params = e.detail.value;
+        var money = params.paymoney;
+        if (form.money) money = Number(form.money) + Number(params.paymoney);
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            wx.showModal({
+                title: '提示',
+                content: '您确定是否充值?',
+                async success(res) {
+                    if (res.confirm) {
+                        wx.getStorage({
+                            key: 'user',
+                            success: async (res) => {
+                                let obj = { openid: res.data.openid, money: params.paymoney, school_id: params.school_id, payer_role: 'Student', pay_for: '充值', payer_id: user.info.id, 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) {
+                                            const rss = await app.$post(`/rss/${that.data.id}`, { money: money });
+                                            if (rss.errcode == '0') {
+                                                wx.showToast({ title: `充值成功`, icon: 'success', duration: 2000 });
+                                                that.back();
+                                            }
+                                        },
+                                        "fail": async function (res) {
+                                            wx.showToast({ title: `充值未成功`, icon: 'error', duration: 2000 })
+                                            that.watchLogin()
+                                        },
+                                    })
+                                }
+                            },
+                            fail: async (res) => {
+                                wx.redirectTo({ url: '/pages/index/index' });
+                            },
+                        });
+                    } else if (res.cancel) { }
+                }
+            });
+        }
     },
-
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
-
+    onLoad: async function (options) {
+        const that = this;
+        that.setData({ id: options.id || null })
+        //验证规则函数
+        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(`/rss/${that.data.id}`);
+                    if (arr.errcode == '0') {
+                        that.setData({ form: arr.data });
+                    }
+                };
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+    // 查询其他信息
+    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 })
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
-    onReady() {
+    onReady: function () {
 
     },
 
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow() {
+    onShow: function () {
 
     },
 
     /**
      * 生命周期函数--监听页面隐藏
      */
-    onHide() {
+    onHide: function () {
 
     },
 
     /**
      * 生命周期函数--监听页面卸载
      */
-    onUnload() {
+    onUnload: function () {
 
     },
 
     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
-    onPullDownRefresh() {
+    onPullDownRefresh: function () {
 
     },
 
     /**
      * 页面上拉触底事件的处理函数
      */
-    onReachBottom() {
+    onReachBottom: function () {
 
     },
 
     /**
      * 用户点击右上角分享
      */
-    onShareAppMessage() {
+    onShareAppMessage: function () {
 
     }
 })

+ 5 - 2
pages/stuAdmin/money/add.json

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

+ 50 - 0
pages/stuAdmin/money/add.less

@@ -0,0 +1,50 @@
+.main {
+    .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);
+            }
+        }
+
+        .contentmoney {
+            display: flex;
+            flex-direction: column;
+            background-color: var(--mainColor);
+            width: 96vw;
+            margin: 2vw;
+            border-radius: 10px;
+
+            .label {
+                padding: 10px 5px;
+            }
+
+            .value {
+                display: flex;
+                padding: 20px 5px;
+
+                text {
+                    font-size: var(--font18Szie);
+                }
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 5vw 0 0 0;
+
+            button {
+                width: 40vw;
+                margin: 0 2vw;
+                padding: 1vw 0;
+                background: #1E90FF;
+            }
+        }
+    }
+}

+ 35 - 2
pages/stuAdmin/money/add.wxml

@@ -1,2 +1,35 @@
-<!--pages/stuAdmin/money/add.wxml-->
-<text>pages/stuAdmin/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" 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="student_id" value="{{form.student_id}}" placeholder="请输入学生id" />
+                    </view>
+                </view>
+                <view class="contentmoney">
+                    <view class="label">充值金额:</view>
+                    <view class="value">
+                        <text>¥</text><input type="number" name="paymoney" value="{{form.paymoney}}" placeholder="请输入充值金额" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">充值</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 39 - 1
pages/stuAdmin/money/add.wxss

@@ -1 +1,39 @@
-/* pages/stuAdmin/money/add.wxss */
+.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 .contentmoney {
+  display: flex;
+  flex-direction: column;
+  background-color: var(--mainColor);
+  width: 96vw;
+  margin: 2vw;
+  border-radius: 10px;
+}
+.main .one .contentmoney .label {
+  padding: 10px 5px;
+}
+.main .one .contentmoney .value {
+  display: flex;
+  padding: 20px 5px;
+}
+.main .one .contentmoney .value text {
+  font-size: var(--font18Szie);
+}
+.main .one .btn {
+  text-align: center;
+  margin: 5vw 0 0 0;
+}
+.main .one .btn button {
+  width: 40vw;
+  margin: 0 2vw;
+  padding: 1vw 0;
+  background: #1E90FF;
+}

+ 63 - 12
pages/stuAdmin/money/list.js

@@ -1,66 +1,117 @@
-// pages/stuAdmin/money/list.js
+const app = getApp()
 Page({
 
     /**
      * 页面的初始数据
      */
     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, student_id: res.data.info.id };
+                let arr = await app.$get(`/rss`, { ...info });
+                if (arr.errcode == '0') {
+                    let list = [...that.data.list, ...arr.data];
+                    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/stuAdmin/money/list.json

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

+ 77 - 0
pages/stuAdmin/money/list.less

@@ -0,0 +1,77 @@
+.main {
+    height: var(--twoHeight);
+    background-color: var(--mainColor);
+
+    .one {
+        width: 96vw;
+        padding: 2vw;
+
+        input {
+            padding: 2vw;
+            background-color: var(--f1Color);
+            border-radius: 5px;
+        }
+    }
+
+
+    .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;
+            }
+
+            .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;
+                    font-size: var(--font14Size);
+                    background: -webkit-linear-gradient(right, lightblue, #53C9F8);
+                }
+            }
+        }
+
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
+    }
+}

+ 24 - 2
pages/stuAdmin/money/list.wxml

@@ -1,2 +1,24 @@
-<!--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">
+            <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.school_id_name||'暂无'}}</view>
+                        <view class="other">
+                            <view class="other_1"><text>联系电话:</text><text>{{item.school_id_phone||'暂无'}}</text></view>
+                            <view class="other_1"><text>学校地址:</text><text>{{item.school_id_address||'暂无'}}</text></view>
+                            <view class="other_1"><text>账号余额:</text><text>{{item.money||0}}元</text></view>
+                        </view>
+                        <view class="btn">
+                            <button size="mini" type="primary" bindtap="toCommon" data-item="{{item}}" data-route="stuAdmin/money/add">充值</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+    </view>
+</mobile-main>

+ 63 - 1
pages/stuAdmin/money/list.wxss

@@ -1 +1,63 @@
-/* pages/stuAdmin/money/list.wxss */
+.main {
+  height: var(--twoHeight);
+  background-color: var(--mainColor);
+}
+.main .one {
+  width: 96vw;
+  padding: 2vw;
+}
+.main .one input {
+  padding: 2vw;
+  background-color: var(--f1Color);
+  border-radius: 5px;
+}
+.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;
+}
+.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;
+  font-size: var(--font14Size);
+  background: -webkit-linear-gradient(right, lightblue, #53C9F8);
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}