Browse Source

no message

feature/v1.0
xpz2018 5 years ago
parent
commit
6cfbb5f4ff
3 changed files with 29 additions and 22 deletions
  1. 4
      api/request.js
  2. 19
      pages/login/index.js
  3. 28
      pages/login/index.wxml

4
api/request.js

@ -67,13 +67,13 @@ function handleResponse({ data, status }) {
return handleResult(data) return handleResult(data)
}, },
"400"() { "400"() {
return Promise.reject('请求错误')
return Promise.reject(data)
}, },
"401"() { "401"() {
return Promise.reject('请求未授权') return Promise.reject('请求未授权')
}, },
"403"() { "403"() {
return Promise.reject('拒绝请求')
return Promise.reject(data)
}, },
"404"() { "404"() {
return Promise.reject('URL错误') return Promise.reject('URL错误')

19
pages/login/index.js

@ -9,6 +9,7 @@ const app = getApp()
Page({ Page({
data: { data: {
type: 1, type: 1,
pwdType: 'password',
mobileEnable: false, mobileEnable: false,
codeEnable: true, codeEnable: true,
loginEnable: true, loginEnable: true,
@ -101,11 +102,17 @@ Page({
wx.redirectTo({ url: '/pages/index/index' }) wx.redirectTo({ url: '/pages/index/index' })
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
util.showToast(err)
if(err.code == 400){
util.showToast('获取用户信息失败,请注册登录')
this.setData({ loging: false, regist: true})
} else {
util.showToast('请求错误')
this.setData({ loging: false})
}
app.globalData.token = null app.globalData.token = null
storage.remove('Authorization') storage.remove('Authorization')
config.header = null config.header = null
this.setData({ loging: false})
}) })
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
@ -243,7 +250,13 @@ Page({
this.setData({ type: 1, ['form.password']: null, loginEnable: true }) this.setData({ type: 1, ['form.password']: null, loginEnable: true })
} }
}, },
changePwd: function () {
if (this.data.pwdType === 'password') {
this.setData({ pwdType: 'text' })
} else {
this.setData({ pwdType: 'password' })
}
},
/************************************** 二维码流程 ********************************************/ /************************************** 二维码流程 ********************************************/
fetchQrCode: function(code){ fetchQrCode: function(code){
wx.showLoading({ title: '处理中', mask: true }) wx.showLoading({ title: '处理中', mask: true })

28
pages/login/index.wxml

@ -3,44 +3,38 @@
<image style="width:192rpx;height:192rpx" src="/assets/image/icon_logo.png"></image> <image style="width:192rpx;height:192rpx" src="/assets/image/icon_logo.png"></image>
</view> </view>
<view style="padding: 30rpx 80rpx" wx:if="{{ regist }}">
<view style="padding: 30rpx 80rpx;height:480rpx" wx:if="{{ regist }}">
<view class="flex"> <view class="flex">
<image style="width:40rpx;height:40rpx" src="/assets/image/icon_phone.png"></image> <image style="width:40rpx;height:40rpx" src="/assets/image/icon_phone.png"></image>
<text class="label" style="margin-left:24rpx">手机号码</text> <text class="label" style="margin-left:24rpx">手机号码</text>
</view> </view>
<view class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx"> <view class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="account" type="number" placeholder-style="color:#aaa" maxlength="11" placeholder="请输入手机号"
value="{{form.account}}" bindinput="bindInput" />
<input id="account" type="number" placeholder-style="color:#aaa" maxlength="11" placeholder="请输入手机号" value="{{form.account}}" bindinput="bindInput" />
</view> </view>
<view class="flex" style="margin-top: 40rpx"> <view class="flex" style="margin-top: 40rpx">
<image style="width:40rpx;height:40rpx" src="{{type == 1 ? '/assets/image/icon_code.png' : '/assets/image/icon_pwd.png'}}"></image> <image style="width:40rpx;height:40rpx" src="{{type == 1 ? '/assets/image/icon_code.png' : '/assets/image/icon_pwd.png'}}"></image>
<text class="label" style="margin-left:12rpx">{{type == 1 ? '验证码' : '密码'}}</text> <text class="label" style="margin-left:12rpx">{{type == 1 ? '验证码' : '密码'}}</text>
</view> </view>
<view wx:if="{{type == 1}}" class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx;border-top:0rpx solid #eee;"> <view wx:if="{{type == 1}}" class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx;border-top:0rpx solid #eee;">
<input id="captcha" type="number" placeholder-style="color:#aaa" maxlength="6"
placeholder="请输入{{type == 1 ? '验证码' : '密码'}}" bindinput="bindInput" />
<van-button size="small" plain type="info" custom-style="width:220rpx" disabled="{{!mobileEnable || !codeEnable}}"
bind:click="fetchCaptcha">
<van-count-down class="count-down" time="{{ 60000 }}" use-slot auto-start="{{false}}" bind:change="onCountChange"
bind:finish="onFinished">
<input id="captcha" type="number" placeholder-style="color:#aaa" maxlength="6" placeholder="请输入验证码" bindinput="bindInput" />
<van-button size="small" plain type="info" custom-style="width:220rpx" disabled="{{!mobileEnable || !codeEnable}}" bind:click="fetchCaptcha">
<van-count-down class="count-down" time="{{ 60000 }}" use-slot auto-start="{{false}}" bind:change="onCountChange" bind:finish="onFinished">
<text class="text-sm">{{second}}</text> <text class="text-sm">{{second}}</text>
</van-count-down> </van-count-down>
</van-button> </van-button>
</view> </view>
<view wx:else class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx"> <view wx:else class="cu-form-group" style="min-height:120rpx;border-bottom:1rpx solid #eee;padding:0rpx">
<input id="password" placeholder-style="color:#aaa" type="{{pwdType}}" maxlength="20" placeholder="请输入验密码"
bindinput="bindInput" bindfocus="inputFocus" />
<input id="password" placeholder-style="color:#aaa" type="{{pwdType}}" maxlength="20" placeholder="请输入验密码" bindinput="bindInput" bindfocus="inputFocus" />
<text class="cuIcon-{{pwdType == 'password' ? 'attention': 'attentionforbid'}}" bindtap="changePwd" style="font-size:22px"></text>
</view> </view>
<view style="margin-top:24rpx;text-align:end;"> <view style="margin-top:24rpx;text-align:end;">
<text class="label" style="font-size:30rpx;padding: 12rpx 0rpx 12rpx 24rpx"
bindtap="changeType">{{type == 1 ? '密码登录' : '验证码登录'}}</text>
<text class="label" style="font-size:30rpx;padding: 12rpx 0rpx 12rpx 24rpx" bindtap="changeType">{{type == 1 ? '密码登录' : '验证码登录'}}</text>
</view> </view>
</view> </view>
<view wx:else style="margin-top:16rpx;padding:30rpx">
<view wx:else style="padding:30rpx 80rpx;height:480rpx">
<view style="text-align: center" class="text-xl">服务协议和隐私政策</view> <view style="text-align: center" class="text-xl">服务协议和隐私政策</view>
<view class="text-df" style="padding:40rpx 30rpx">
<text class="text-df">请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提工厂经营管理、订单结算以及其他业务的相关服务,我们需要获你的个人微信信息,然后验证是你本人在操作。
你可阅读</text><text class="text-blue" bindtap="readAgreement">《纸通宝SAAS服务协议》</text>了解详细信息,如你同意,请点击“同意”开始接受我们的服务。
<view class="text-df" style="padding:40rpx 0rpx">
<text class="text-df">请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提工厂经营管理、订单结算以及其他业务的相关服务,我们需要获你的个人微信信息,然后验证是你本人在操作。你可阅读</text><text class="text-blue" bindtap="readAgreement">《纸通宝SAAS服务协议》</text>了解详细信息,如你同意,请点击“同意”开始接受我们的服务。
</view> </view>
</view> </view>
<!-- <view style="margin-top:20rpx;padding:40rpx 80rpx"> <!-- <view style="margin-top:20rpx;padding:40rpx 80rpx">

Loading…
Cancel
Save