zs пре 1 година
родитељ
комит
1c9db46759

+ 2 - 3
app.json

@@ -40,15 +40,14 @@
             "root": "pagesCommon",
             "independent": true,
             "pages": [
-                "login/index",
-                "register/index"
+                "login/index"
             ]
         }
     ],
     "lazyCodeLoading": "requiredComponents",
     "window": {
         "backgroundTextStyle": "dark",
-        "navigationBarBackgroundColor": "#000000",
+        "navigationBarBackgroundColor": "#48D1CC",
         "navigationBarTitleText": "羽毛球比赛",
         "navigationBarTextStyle": "white"
     },

+ 4 - 9
app.wxss

@@ -21,13 +21,8 @@ page {
     --rgb111: #111111;
     --rgbfff: #ffffff;
     --rgbf1f: #f1f1f1;
-    --rgb161: #161616;
-    --rgbfa4: #FA4343;
-    --rgb67c: #67c23a;
-    --rgb313: #31312e;
-    --rgbffd: #FFD700;
-    --rgbff0: #ff0000;
-    --rgb314: #31479C;
-    --rgb8B0: #8B0000;
-    --rgb466: #46679F;
+    --rgb40E: #40E0D0;
+    --rgb3AB: #3ABDB8;
+    --rgb8b8: #8b8b8b;
+    --rgbD8D: #D8D8D8;
 }

+ 1 - 1
components/common/home-frame.wxml

@@ -6,7 +6,7 @@
         <view class="list" wx:for="{{list}}" wx:if="{{item.is_use=='0'}}" wx:key="item" wx:for-index="index" bindtap="toPath" data-index="{{index}}">
             <image class="image" src="{{item.normal}}" mode="" wx:if="{{active!=index}}" />
             <image class="image" src="{{item.active}}" mode="" wx:else />
-            <view class="name" style="color:{{active==index?'var(--rgb67c)':''}}">{{item.title}}</view>
+            <view class="name" style="color:{{active==index?'var(--rgb40E)':''}}">{{item.title}}</view>
         </view>
     </view>
 </view>

+ 3 - 2
components/common/home-frame.wxss

@@ -4,6 +4,7 @@
     width: 100vw;
     height: 92vh;
     overflow: auto;
+    background-color: #f1f1f1;
 }
 
 .content .foot {
@@ -12,8 +13,8 @@
     width: 100vw;
     height: 8vh;
     overflow: hidden;
-    background-color: #000000;
-    color: #ffffff;
+    background-color: #ffffff;
+    color: #cdcdcd;
     display: flex;
     flex-direction: row;
     justify-content: space-around;

BIN
image/tabs/home_1.png


BIN
image/tabs/match_1.png


BIN
image/tabs/my_1.png


BIN
image/tabs/team_1.png


+ 18 - 4
pages/index/index.js

@@ -28,7 +28,9 @@ Page({
     async onShow() {
         const that = this;
         wx.showLoading({ title: '加载中', mask: true })
-        await this.searchConfig()
+        await that.searchConfig()
+        // 监听用户是否登录
+        await this.watchLogin();
         wx.hideLoading()
     },
     async searchConfig() {
@@ -36,14 +38,26 @@ Page({
         const res = await app.$api('config', 'GET', {});
         if (res.errcode == '0') {
             // index,长图。
-            if (res.data && res.data.longlogo_url && res.data.longlogo_url.length > 0) {
-                let logo = res.data.longlogo_url[0].url
+            if (res.data && res.data.logo_url && res.data.logo_url.length > 0) {
+                let logo = res.data.logo_url[0].url
                 that.setData({ logo })
-                wx.redirectTo({ url: '/pagesCommon/login/index'})
             }
             wx.setStorage({ key: "config", data: res.data })
         }
     },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'token',
+            success: async res => {
+                wx.redirectTo({ url: '/pagesHome/home/index' })
+            },
+            fail: res => {
+                return wx.redirectTo({ url: '/pagesCommon/login/index' })
+            }
+        })
+    },
     /**
      * 生命周期函数--监听页面隐藏
      */

+ 86 - 15
pagesCommon/login/index.js

@@ -1,31 +1,104 @@
+import WxValidate from '../../utils/wxValidate'
 const app = getApp()
 Page({
     data: {
-        info: {}
+        form: {},
+        current: 1,
+        // 用户类别
+        typeList: [],
     },
-    toPath(e) {
-        let data = e.detail;
-        let url = `/${data.route}`;
-        if (data.type == '0') wx.navigateTo({ url })
-        else if (data.type == '1') wx.redirectTo({ url })
-        else if (data.type == '2') wx.relaunch({ url })
-        else if (data.type == '3') wx.switchTab({ url })
+    // 登陆注册监听
+    click(e) {
+        const that = this;
+        let index = e.currentTarget.dataset.code;
+        that.setData({ current: index })
+    },
+    // 验证表单
+    initValidate() {
+        const rules = { account: { required: true }, password: { required: true, } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { account: { required: '请输入账号', }, password: { required: '请输入密码', } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 选择用户类别
+    typeChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let data = that.data.typeList[index];
+        if (data) that.setData({ 'form.type': data.value });
+        that.setData({ 'form.type_name': data.label });
+    },
+    // 提交登录
+    onSubmit: async function (e) {
+        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 {
+            const res = await app.$api('user/login', 'POST', params);
+            if (res.errcode === 0) {
+                app.globalData.userInfo = res.data;//存用户信息到app.js
+                wx.setStorage({ key: "token", data: res.data })// 存用户信息到storage,以便之后判断用户是否登录
+                wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 }) //登录成功提示
+                wx.redirectTo({ url: '/pagesHome/home/index' })
+            } else {
+                wx.showToast({ title: res.errmsg, icon: 'none', duration: 2000 })
+            }
+        }
+    },
+    // 提交注册
+    reSubmit: 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 {
+            if (params.password !== params.is_password) {
+                wx.showToast({ title: '密码输入不一致', duration: 2000, icon: 'error', })
+            } else {
+                delete params.is_password
+                const res = await app.$api('user', 'POST', params);
+                if (res.errcode === 0) {
+                    wx.showToast({ title: `账号注册成功`, icon: 'success', duration: 2000 }) //登录成功提示
+                    that.setData({ current: 1 })
+                } else {
+                    wx.showToast({ title: res.errmsg, icon: 'none', duration: 2000 })
+                }
+            }
+        }
+    },
+    // 忘记密码
+    forgot() {
+        wx.showToast({ title: `暂未开放`, icon: 'error', duration: 2000 })
     },
-
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
+    async onLoad(options) {
         const that = this;
         wx.showLoading({ title: '加载中', mask: true })
-        that.search()
+        //验证规则函数
+        await that.initValidate()
+        await that.searchOther()
+        await that.search()
         wx.hideLoading()
     },
+    async searchOther() {
+        const that = this;
+        let res;
+        // 类别
+        res = await app.$api('dictData', 'GET', { type: 'type', is_use: '0' })
+        if (res.errcode == '0') {
+            that.setData({ typeList: res.data })
+        }
+    },
     // 查询通知
     async search() {
         const that = this;
     },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -36,9 +109,7 @@ Page({
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow() {
-
-    },
+    onShow() { },
 
     /**
      * 生命周期函数--监听页面隐藏

+ 58 - 2
pagesCommon/login/index.wxml

@@ -1,3 +1,59 @@
-<view class="main">
-    登录
+<view class="content main">
+    <view class="one">
+        <view>Hi</view>
+        <view class="text">欢迎使用!羽毛球比赛</view>
+    </view>
+    <!-- 登录、注册 -->
+    <view class="two">
+        <view class="two_1">
+            <view class="left {{current==1?'select':''}}" bindtap="click" data-code="1">
+                <text>登录</text>
+            </view>
+            <view class="right {{current==0?'select':''}}" bindtap="click" data-code="0">
+                <text>注册</text>
+            </view>
+        </view>
+        <!-- 登录 -->
+        <form bindsubmit="onSubmit">
+            <view class="two_2" hidden="{{current==0}}">
+                <view class="value">
+                    <input class="input" type='text' name="account" value="{{form.account}}" placeholder="请输入账号" />
+                </view>
+                <view class="value">
+                    <input class="input" type='text' name="password" value="{{form.password}}" password placeholder="请输入密码" />
+                </view>
+                <view class="forget">
+                    <text bindtap="forgot">忘记密码?</text>
+                </view>
+            </view>
+            <view class="button" hidden="{{current==0}}">
+                <button class="btn" type="primary" form-type="submit">立即登录</button>
+            </view>
+        </form>
+        <!-- 注册 -->
+        <form bindsubmit="reSubmit">
+            <view class="two_2" hidden="{{current==1}}">
+                <view class="value">
+                    <input class="input" type='text' name="account" value="{{form.account}}" placeholder="请输入账号" />
+                </view>
+                <view class="value">
+                    <input class="input" type='text' name="password" value="{{form.password}}" password placeholder="请输入密码" />
+                </view>
+                <view class="value">
+                    <input class="input" type='text' name="is_password" value="{{form.is_password}}" placeholder="再次输入密码" password></input>
+                </view>
+                <view class="value">
+                    <picker class="picker" mode="selector" bindchange="typeChange" name="type" range-key="label" range="{{typeList}}">
+                        <view class="weui-select">{{form.type_name||'请选择用户类别'}}</view>
+                    </picker>
+                </view>
+            </view>
+            <view class="button" hidden="{{current==1}}">
+                <button class="btn" type="primary" form-type="submit">立即注册</button>
+            </view>
+        </form>
+    </view>
+    <!-- 重影 -->
+    <view class="shadow shadow-1"></view>
+    <view class="shadow shadow-2"></view>
 </view>

+ 135 - 2
pagesCommon/login/index.wxss

@@ -1,3 +1,136 @@
-.main {
-    padding: 1vw;
+@import "../../app.wxss";
+
+page {
+    height: 100%;
+    background-color: #ffffff;
+    margin: 0px;
+    padding: 0px;
+}
+
+/* 顶部背景 */
+.main .one {
+    height: 30%;
+    background-image: linear-gradient(to bottom, var(--rgb40E), var(--rgb3AB));
+    padding: 3vw;
+    color: #ffffff;
+    font-weight: bold;
+}
+
+.main .one .text {
+    margin-top: 15rpx;
+}
+
+/* 内容 */
+.main .two {
+    background-color: white;
+    margin: -20% 20rpx 0rpx 20rpx;
+    padding: 25rpx;
+    border-radius: 15rpx;
+    -webkit-filter: drop-shadow(0 0 8rpx var(--rgb40E));
+    filter: drop-shadow(0 0 8rpx var(--rgb40E));
+}
+
+/* 导航 */
+.main .two .two_1 {
+    display: flex;
+    text-align: center;
+    font-size: 32rpx;
+    margin-bottom: 8%;
+}
+
+.main .two .two_1 .left {
+    flex: 1;
+    font-weight: bold;
+}
+
+.main .two .two_1 .right {
+    flex: 1;
+    font-weight: bold;
+}
+
+.main .two .two_2 {
+    margin: 20rpx;
+}
+
+.main .two .two_2 .value {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-top: 40rpx;
+    padding-bottom: 20rpx;
+    border-bottom: 1rpx solid #f1f1f1;
+}
+
+
+
+.main .two .two_2 .value .input {
+    padding-left: 20rpx;
+    font-size: 30rpx;
+}
+
+.main .two .two_2 .value .picker {
+    font-size: 30rpx;
+    color: var(--rgb8b8);
+}
+
+.main .two .two_2 .value .picker .weui-select {
+    padding: 0 0 0 20rpx;
+}
+
+.main .two .two_2 .forget {
+    font-size: 26rpx;
+    color: var(--rgb40E);
+    margin-top: 20rpx;
+    text-align: right;
+}
+
+.main .two .button {
+    margin: 6% 30rpx 30rpx 30rpx;
+}
+
+.main .two .button .btn {
+    background-color: var(--rgb40E);
+    font-size: 30rpx;
+}
+
+/* 重影 */
+.shadow {
+    box-shadow: 0rpx 0rpx 10rpx 0rpx var(--rgb40E);
+    border-radius: 25rpx;
+    background-color: white;
+}
+
+.shadow-1 {
+    height: 40rpx;
+    margin: -20rpx 50rpx 0 50rpx;
+}
+
+.shadow-2 {
+    position: relative;
+    z-index: -888;
+    height: 50rpx;
+    margin: -30rpx 80rpx 0 80rpx;
+}
+
+/* 最底部 */
+.bottom-box {
+    position: fixed;
+    bottom: 10rpx;
+    width: 100%;
+    font-size: 24rpx;
+    color: gray;
+    display: flex;
+    justify-content: center;
+}
+
+.select {
+    font-weight: bold;
+    color: var(--rgb40E);
+}
+
+.select text {
+    padding-bottom: 5rpx;
+    border-bottom-left-radius: 10rpx;
+    border-bottom-right-radius: 10rpx;
+    border-bottom: 5rpx solid var(--rgb40E);
 }

+ 0 - 77
pagesCommon/register/index.js

@@ -1,77 +0,0 @@
-const app = getApp()
-Page({
-    data: {
-        info: {}
-    },
-    toPath(e) {
-        let data = e.detail;
-        let url = `/${data.route}`;
-        if (data.type == '0') wx.navigateTo({ url })
-        else if (data.type == '1') wx.redirectTo({ url })
-        else if (data.type == '2') wx.relaunch({ url })
-        else if (data.type == '3') wx.switchTab({ url })
-    },
-
-    /**
-     * 生命周期函数--监听页面加载
-     */
-    onLoad(options) {
-        const that = this;
-        wx.showLoading({ title: '加载中', mask: true })
-        that.search()
-        wx.hideLoading()
-    },
-    // 查询通知
-    async search() {
-        const that = this;
-    },
-
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
-    },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {
-
-    }
-})

+ 0 - 3
pagesCommon/register/index.json

@@ -1,3 +0,0 @@
-{
-    "navigationBarTitleText": "注册"
-}

+ 0 - 3
pagesCommon/register/index.wxml

@@ -1,3 +0,0 @@
-<view class="main">
-    注册
-</view>

+ 0 - 3
pagesCommon/register/index.wxss

@@ -1,3 +0,0 @@
-.main {
-    padding: 1vw;
-}