guhongwei 2 年之前
父節點
當前提交
3c2220baad

+ 1 - 0
app.json

@@ -3,6 +3,7 @@
         "pages/index/index",
         "pages/register/index",
         "pages/school/index",
+        "pages/school/info",
         "pages/smy/index",
         "pages/suser/list",
         "pages/suser/add",

+ 2 - 0
app.wxss

@@ -31,6 +31,8 @@ page {
     /* 底部菜单背景颜色 */
     --footColor: #f1f1f1;
     /* 字体大小 */
+    --font20Szie: 20px;
+    --font19Szie: 19px;
     --font18Szie: 18px;
     --font17Size: 17px;
     --font16Size: 16px;

+ 12 - 0
pages/register/index.js

@@ -71,6 +71,18 @@ Page({
 
         }
     },
+    // 游客登录
+    touristSubmit: async function () {
+        let wxInfo = app.globalData.wxInfo;
+        let params = { openid: wxInfo.openid, type: '10', name: '游客' };
+        const arr = await app.$post('/user', params)
+        if (arr.errcode == '0') {
+            wx.showToast({ title: `游客注册成功`, icon: 'success', duration: 2000 });
+            wx.redirectTo({ url: '/pages/index/index' });
+        } else {
+            wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+        }
+    },
     /**
      * 生命周期函数--监听页面加载
      */

+ 1 - 1
pages/register/index.wxml

@@ -30,7 +30,7 @@
                 </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交注册</button>
-                    <button type="warn" size="mini">游客登录</button>
+                    <button type="warn" size="mini" bindtap="touristSubmit">游客登录</button>
                 </view>
                 <view class="agree">
                     <label>

+ 35 - 1
pages/school/index.js

@@ -2,7 +2,12 @@ const app = getApp()
 Page({
     data: {
         frameStyle: { useTop: true, name: '羽校', leftArrow: false, useBar: true },
-        user: {}
+        user: {},
+        list: [],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
     },
     // 跳转菜单
     tabPath(e) {
@@ -11,8 +16,31 @@ Page({
     },
     // 进入系统
     toJoin: function () {
+        that.setData({ skip: 0, page: 0, list: [] })
         wx.navigateTo({ url: `/pages/smy/index` })
     },
+    // 查看详情
+    toView: function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        that.setData({ skip: 0, page: 0, list: [] })
+        wx.navigateTo({ url: `/pages/school/info?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 }) }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -36,6 +64,12 @@ Page({
             key: 'user',
             success: async res => {
                 that.setData({ user: res.data })
+                let info = { skip: that.data.skip, limit: that.data.limit };
+                const arr = await app.$get(`/school`, { ...info });
+                if (arr.errcode == '0') {
+                    that.setData({ list: [...that.data.list, ...arr.data] });
+                    that.setData({ total: arr.total })
+                } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 80 - 1
pages/school/index.less

@@ -7,6 +7,7 @@
         flex-direction: row;
         padding: 2vw;
         border-bottom: 1px solid var(--f1Color);
+        margin: 0 0 2vw 0;
 
         .one_1 {
             flex-grow: 1;
@@ -30,6 +31,84 @@
     }
 
     .two {
-        background-color: #ffffff;
+        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;
+
+            .list_1 {
+                .swiper {
+                    height: 30vh;
+
+                }
+
+                .image {
+                    width: 100%;
+                    height: 100%;
+                }
+            }
+
+            .list_2 {
+                position: absolute;
+                top: 2vw;
+                width: 92vw;
+                color: var(--whiteColor);
+
+                .name {
+                    text-align: center;
+                    font-size: var(--font20Szie);
+                    font-weight: bold;
+                    margin: 3vw 0 1vw 0;
+                    overflow: hidden;
+                    text-overflow: ellipsis;
+                    -webkit-line-clamp: 2;
+                    word-break: break-all;
+                    display: -webkit-box;
+                    -webkit-box-orient: vertical;
+                    -webkit-text-stroke: 1px var(--redColor);
+                }
+
+                .address {
+                    text-align: center;
+                    font-size: var(--font18Szie);
+                    margin: 0 0 2vw 0;
+                    overflow: hidden;
+                    text-overflow: ellipsis;
+                    -webkit-line-clamp: 2;
+                    word-break: break-all;
+                    display: -webkit-box;
+                    -webkit-box-orient: vertical;
+                    -webkit-text-stroke: 1px var(--blueColor);
+                }
+
+                .other {
+                    display: flex;
+                    flex-direction: row;
+                    justify-content: space-around;
+                    font-size: var(--font18Szie);
+                    -webkit-text-stroke: 1px var(--blueColor);
+                }
+            }
+        }
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
     }
 }

+ 23 - 1
pages/school/index.wxml

@@ -9,7 +9,29 @@
             </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" wx:for-item="item" wx:for-index="index" bindtap="toView" data-item="{{item}}">
+                        <view class="list_1">
+                            <swiper autoplay="true" circular="true" interval="3000" duration="1000">
+                                <block wx:for="{{item.img_url}}" wx:key="tag" wx:for-item="tag" wx:for-index="tagindex">
+                                    <swiper-item>
+                                        <image class="image" src="{{tag.url}}"></image>
+                                    </swiper-item>
+                                </block>
+                            </swiper>
+                        </view>
+                        <view class="list_2">
+                            <view class="name">{{item.name}}</view>
+                            <view class="address">{{item.address}}</view>
+                            <view class="other">
+                                <view class="other_1"><text>教练人数:</text><text>{{item.coach_num}}</text></view>
+                                <view class="other_1"><text>学员人数:</text><text>{{item.student_num}}</text></view>
+                            </view>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
         </view>
     </view>
 </mobile-main>

+ 68 - 1
pages/school/index.wxss

@@ -7,6 +7,7 @@
   flex-direction: row;
   padding: 2vw;
   border-bottom: 1px solid var(--f1Color);
+  margin: 0 0 2vw 0;
 }
 .main .one .one_1 {
   flex-grow: 1;
@@ -25,5 +26,71 @@
   font-size: var(--font14Size);
 }
 .main .two {
-  background-color: #ffffff;
+  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;
+}
+.main .two .list .list_1 .swiper {
+  height: 30vh;
+}
+.main .two .list .list_1 .image {
+  width: 100%;
+  height: 100%;
+}
+.main .two .list .list_2 {
+  position: absolute;
+  top: 2vw;
+  width: 92vw;
+  color: var(--whiteColor);
+}
+.main .two .list .list_2 .name {
+  text-align: center;
+  font-size: var(--font20Szie);
+  font-weight: bold;
+  margin: 3vw 0 1vw 0;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-text-stroke: 1px var(--redColor);
+}
+.main .two .list .list_2 .address {
+  text-align: center;
+  font-size: var(--font18Szie);
+  margin: 0 0 2vw 0;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-text-stroke: 1px var(--blueColor);
+}
+.main .two .list .list_2 .other {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-around;
+  font-size: var(--font18Szie);
+  -webkit-text-stroke: 1px var(--blueColor);
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
 }

+ 85 - 0
pages/school/info.js

@@ -0,0 +1,85 @@
+const app = getApp()
+Page({
+    data: {
+        frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
+        user: {},
+        id: '',
+        form: {}
+    },
+    // 跳转菜单
+    back(e) {
+        wx.navigateBack({ delta: 1 })
+    },
+
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || null })
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                if (that.data.id) {
+                    const arr = await app.$get(`/school/${that.data.id}`)
+                    if (arr.errcode == '0') {
+                        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 () { },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/school/info.json

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

+ 7 - 0
pages/school/info.less

@@ -0,0 +1,7 @@
+.main {
+
+    background-color: var(--mainColor);
+
+  
+}
+

+ 5 - 0
pages/school/info.wxml

@@ -0,0 +1,5 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        {{form.name}}
+    </view>
+</mobile-main>

+ 3 - 0
pages/school/info.wxss

@@ -0,0 +1,3 @@
+.main {
+  background-color: var(--mainColor);
+}

+ 4 - 0
pages/setting/basic.js

@@ -43,6 +43,10 @@ Page({
             that.setData({ 'form.zhGender': data.label })
         }
     },
+    typeChange: function (e) {
+        const { value } = e.detail;
+        if (value == '0') wx.showToast({ title: `如进行身份切换,请在维护信息成功后退出登录,系统会自动进行身份置换!`, icon: 'none', duration: 2000 })
+    },
     // 提交登录
     onSubmit: async function (e) {
         const that = this;

+ 13 - 0
pages/setting/basic.wxml

@@ -28,6 +28,19 @@
                         <input name="phone" value="{{form.phone}}" placeholder="请输入手机号" />
                     </view>
                 </view>
+                <view class="content" wx:if="{{form.type=='10'}}">
+                    <view class="label">是否成为正式用户:</view>
+                    <view class="value">
+                        <radio-group name="type" bindchange="typeChange">
+                            <label>
+                                <radio value="10" checked="{{form.type=='10'}}" />否
+                            </label>
+                            <label>
+                                <radio value="0" checked="{{form.type=='0'}}" />是
+                            </label>
+                        </radio-group>
+                    </view>
+                </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交保存</button>
                 </view>