From 7e83f2413f85f2632839cb3ca0a51478ef913708 Mon Sep 17 00:00:00 2001 From: lqq Date: Mon, 14 Oct 2019 17:08:32 +0800 Subject: [PATCH] =?UTF-8?q?Auth=20=E5=8A=9F=E8=83=BD=E3=80=81Empty?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.wxss | 1 + components/card/index.wxss | 1 + components/cell/index.wxss | 1 + components/empty/index.js | 13 +++- components/empty/index.wxml | 8 ++- components/empty/index.wxss | 51 +++++++++++++- components/focus/index.wxml | 2 +- components/swiper/index.wxml | 2 +- models/auth.js | 35 +++++++--- pages/article/index.js | 2 +- pages/article/index.wxss | 3 + pages/billboards/park/park-list/index.js | 4 ++ pages/billboards/park/park-list/index.wxss | 2 +- pages/home/index.js | 12 ++-- pages/home/index.json | 3 +- pages/home/index.wxml | 1 + pages/register/index.js | 77 ++++++++++++++++++++-- pages/register/index.wxml | 4 +- utils/http.js | 9 ++- 19 files changed, 200 insertions(+), 31 deletions(-) diff --git a/app.wxss b/app.wxss index 2876473..f986072 100644 --- a/app.wxss +++ b/app.wxss @@ -2,4 +2,5 @@ page{ font-family: PingFangSC-Regular; + /* background-color: #f7f7f7; */ } \ No newline at end of file diff --git a/components/card/index.wxss b/components/card/index.wxss index e32232d..315f94a 100644 --- a/components/card/index.wxss +++ b/components/card/index.wxss @@ -1,5 +1,6 @@ /* components/card/index.wxss */ .card { + background-color: white; border: 1px solid #e7e7e7; box-shadow: 1px 1px 1px #eee; } diff --git a/components/cell/index.wxss b/components/cell/index.wxss index 2f1585b..1e3e478 100644 --- a/components/cell/index.wxss +++ b/components/cell/index.wxss @@ -1,5 +1,6 @@ /* components/cell/index.wxss */ .cell { + background-color: white; border-bottom: 1px solid #E7E7E7; display: flex; flex-direction: column; diff --git a/components/empty/index.js b/components/empty/index.js index 64354b9..7519f39 100644 --- a/components/empty/index.js +++ b/components/empty/index.js @@ -4,7 +4,18 @@ Component({ * 组件的属性列表 */ properties: { - + loading: { + type: Boolean, + value: true, + }, + empty: { + type: Boolean, + value: false, + }, + message: { + type: Boolean, + value: '页面迷路了!' + } }, /** diff --git a/components/empty/index.wxml b/components/empty/index.wxml index 749e0ae..ffef962 100644 --- a/components/empty/index.wxml +++ b/components/empty/index.wxml @@ -1,4 +1,10 @@ - + + 加载中 + + + + + diff --git a/components/empty/index.wxss b/components/empty/index.wxss index 615e47f..8f3e25c 100644 --- a/components/empty/index.wxss +++ b/components/empty/index.wxss @@ -1 +1,50 @@ -/* components/empty/index.wxss */ \ No newline at end of file +/* components/empty/index.wxss */ + +.empty { + position: relative; + width: 100%; +} + +.empty-loading { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; +} +.empty-bd { + padding: 10px 0; + text-align: center; + font-size: 17px; + color: #888; +} + +.load-indicator { + font-size: 16px; + color: #888; + text-align: center; +} +dot { + display: inline-block; + overflow: hidden; + height: 1em; + line-height: 1; + vertical-align: -.25em; +} + +dot::after { + display: block; + white-space: pre-wrap; + content: "...\A..\A."; + animation: loading 3s infinite step-start both; +} + +@keyframes loading { + 33% { + transform: translate3d(0, -2em, 0); + } + + 66% { + transform: translate3d(0, -1em, 0); + } +} diff --git a/components/focus/index.wxml b/components/focus/index.wxml index 438d78c..6049dd0 100644 --- a/components/focus/index.wxml +++ b/components/focus/index.wxml @@ -1,5 +1,5 @@ - + diff --git a/components/swiper/index.wxml b/components/swiper/index.wxml index 0c1dbfe..ea851fb 100644 --- a/components/swiper/index.wxml +++ b/components/swiper/index.wxml @@ -1,5 +1,5 @@ - + { wx.showToast({ title: '短信验证码已发送!', icon: 'none' }) + success(data) } } this.request(params) } - // 验证和注册 + checkRegister (success) { + let params = { + url: AuthConst.check_register_url, + method: Method.POST, + success: success, + } + this.request(params) + } + // 提交验证和注册 register (phone, name, vscode, success) { let params = { - url: '', + url: AuthConst.verify_update_phone_url, method: Method.POST, data: { - + phone: phone, + realName: name, + verificationCode: vscode, }, success: (data) => { if (data) { @@ -51,7 +66,7 @@ class AuthModel extends HTTP { this._fetchWXCode().then(res => { if (!res) return let params = { - url: token_url, + url: AuthConst.token_url, method: Method.GET, data: { code: res diff --git a/pages/article/index.js b/pages/article/index.js index 1e449ca..749eb23 100644 --- a/pages/article/index.js +++ b/pages/article/index.js @@ -11,7 +11,7 @@ Page({ data: { nodes: '', isStar: true, // 是否 - showBtn: true, + showBtn: false, aId: '', title: '', date: '', diff --git a/pages/article/index.wxss b/pages/article/index.wxss index 8b6383e..499b497 100644 --- a/pages/article/index.wxss +++ b/pages/article/index.wxss @@ -1,4 +1,7 @@ /* pages/article/index.wxss */ +.contianer { + overflow: hidden; +} .page_hd { padding: 0 15px; display: flex; diff --git a/pages/billboards/park/park-list/index.js b/pages/billboards/park/park-list/index.js index 3ced5b5..afacbf6 100644 --- a/pages/billboards/park/park-list/index.js +++ b/pages/billboards/park/park-list/index.js @@ -7,6 +7,7 @@ Page({ * 页面的初始数据 */ data: { + loading: true, list: [], curCode: '', curPage:1, @@ -34,6 +35,9 @@ Page({ const {curCode} = this.data const page = this.data.curPage billboard.fetchBailList(curCode, page, res => { + this.setData({ + loading:false, + }) console.log(res) const list = res.list if (page == 1) { diff --git a/pages/billboards/park/park-list/index.wxss b/pages/billboards/park/park-list/index.wxss index 548a507..425ba09 100644 --- a/pages/billboards/park/park-list/index.wxss +++ b/pages/billboards/park/park-list/index.wxss @@ -13,7 +13,7 @@ .page_empty { width: 100%; height: 100px; - margin-top: 100px; + margin-top: 20px; font-size: 14px; color: #aaa; text-align: center; diff --git a/pages/home/index.js b/pages/home/index.js index 24902df..4e10cea 100644 --- a/pages/home/index.js +++ b/pages/home/index.js @@ -6,6 +6,7 @@ import { HomeModel } from '../../models/home.js' let homeModel = new HomeModel() Page({ data: { + loading: true, currPage: 1, banners: [], hots: [], @@ -47,6 +48,9 @@ Page({ fetchHomeList() { let page = this.data.currPage homeModel.getHomeList(page, res => { + this.setData({ + loading: false + }) console.log('啦啦啦') const datas = res.list let tempDatas = [] @@ -130,10 +134,10 @@ Page({ }, clickListItem(e) { console.log(e.detail) - this.gotoArticePage(e.detail.id) - // wx.redirectTo({ - // url: '/pages/register/index', - // }) + // this.gotoArticePage(e.detail.id) + wx.redirectTo({ + url: '/pages/register/index', + }) }, gotoArticePage(id) { wx.navigateTo({ diff --git a/pages/home/index.json b/pages/home/index.json index 8b85794..c97011e 100644 --- a/pages/home/index.json +++ b/pages/home/index.json @@ -5,6 +5,7 @@ "usingComponents": { "e-swiper": "/components/swiper/index", "e-focus": "/components/focus/index", - "e-cell": "/components/cell/index" + "e-cell": "/components/cell/index", + "e-empty": "/components/empty/index" } } \ No newline at end of file diff --git a/pages/home/index.wxml b/pages/home/index.wxml index 07e9f53..4a88be0 100644 --- a/pages/home/index.wxml +++ b/pages/home/index.wxml @@ -11,4 +11,5 @@ showTop="{{item.showTop}}" bind:clickListItem="clickListItem"/> + diff --git a/pages/register/index.js b/pages/register/index.js index c92bd4d..d34db78 100644 --- a/pages/register/index.js +++ b/pages/register/index.js @@ -1,4 +1,7 @@ // pages/register/index.js +import {AuthModel} from '../..//models/auth.js' +let auth = new AuthModel() + Page({ /** @@ -18,9 +21,11 @@ Page({ rules: { required: true, message: '验证码必填' }, }, ], - formData: { - - } + formData: {}, + time: 60, + fetchCode: true, + interval: null, + btnTitle: '获取验证码' }, /** @@ -28,6 +33,67 @@ Page({ */ onLoad: function (options) { + }, + onHide () { + clearInterval(this.data.interval) + }, + // 重新获取Code + refetchCodeDownTime () { + + this.data.interval = setInterval(() => { + const time = this.data.time - 1 + const title = `${time}s 重新发送` + this.setData({ + fetchCode: false, + time: time, + btnTitle: title + }) + if (time == 0) { + this.setData({ + fetchCode: true, + time: 60, + btnTitle: '重新发送' + }) + clearInterval(this.data.interval) + } + }, 1000) + }, + // 调用获取 Code 接口 + onGetMsgCode () { + this.selectComponent('#form').validate((valid, errors) => { + if (!valid) { + let emptyPhone = false + errors.forEach(item => { + if (item.name === 'mobile') { + emptyPhone = true + wx.showToast({ + title: item.message, + icon: 'none' + }) + } + }) + if (!emptyPhone) { + + // console.log(this.data.formData) + this.fetchMsgCodeApi() + } + } + }) + }, + fetchMsgCodeApi () { + auth.getMsgCode(this.data.formData.mobile, res => { + console.log(res) + this.refetchCodeDownTime() + }) + }, + registerApi () { + const {mobile, name, vcode} = this.data.formData + auth.register(modile, name, vcode, res => { + console.log(res) + wx.reLaunch({ + url: '/pages/home/index', + }) + }) }, formInputChange (e) { const { field } = e.currentTarget.dataset @@ -40,6 +106,7 @@ Page({ console.log('valid', valid, errors) if (!valid) { const firstError = Object.keys(errors) + console.log(firstError) if (firstError.length) { const error = errors[firstError[0]].message wx.showToast({ @@ -48,9 +115,7 @@ Page({ }) } } else { - wx.showToast({ - title: '校验通过' - }) + this.registerApi() } }) } diff --git a/pages/register/index.wxml b/pages/register/index.wxml index a537af9..0d97d7b 100644 --- a/pages/register/index.wxml +++ b/pages/register/index.wxml @@ -13,9 +13,9 @@ - + - 获取验证码 + {{btnTitle}} diff --git a/utils/http.js b/utils/http.js index e00b0b1..0cb4a63 100644 --- a/utils/http.js +++ b/utils/http.js @@ -47,11 +47,18 @@ class HTTP { } } else { console.log('请求错误') + wx.showToast({ + title: '服务器错误!', + icon: 'none' + }) params.error && params.error(res) } }, fail: function (res) { - console.log('服务器错误') + wx.showToast({ + title: '网络连接错误,请求失败!', + icon: 'none' + }) params.fail && params.fail(res) }, })