Commit 3836b3ac by 张立顺

协议功能开发

1 parent 1d4398d4
// components/authSetting/authSetting.js
// const restapi = require('../../utils/restapi.js')
// var appInstance = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
// auth: {
// type: Boolean,
// value: true,
// observer: function (newVal, oldVal) {
// this.getHeadImage()
// }
// },
// type: {
// type: Boolean,
// value: true
// },
// special: {
// type: Boolean,
// value: false
// },
// index: {
// type: Boolean,
// value: false
// }
},
/**
* 组件的初始数据
*/
data: {
agree: false
// auth: true,
// type: true,
// appLogo: '',
// appName: '',
// merchantName: '',
// gender: 1
},
ready() {
// this.getHeadImage()
},
/**
* 组件的方法列表
*/
methods: {
choose() {
this.setData({
agree: !this.data.agree
})
this.triggerEvent('choose', this.data.agree)
},
jump(e) {
console.log(e)
let { url } = e.currentTarget.dataset
const baseUrl = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/'
const path = `${baseUrl}${url}.html`
// private user
wx.navigateTo({
url: `/pages/webView/webView?path=${encodeURIComponent(path)}`
})
// var globalData = appInstance.globalData.extConfig
// restapi.getMerchantBussiness(globalData.merchantId, function (res) {
// console.log(res);
// if (res.returnCode == '0') {
// let path = `https://dj.glsx.com.cn/agreement/djUserPolicy.html?merchantName=${globalData.merchantName}&phone=${res.data.phone}`
// wx.navigateTo({
// url: `/pages/webpage/webpage?path=${encodeURIComponent(path)}`
// })
// }
// }, function (res) {
// console.log(res);
// })
},
noScroll() {}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class='tips'>
<view class='choose-box' bindtap="choose">
<view class='icon'>
<image src="{{agree?'./images/ok.png':'./images/box.png'}}" class='check-img' />
</view>
</view>
阅读并同意以下协议
<!-- <text catchtap="jump" data-url="agree">《服务协议》</text> -->
<text catchtap="jump" data-url="privacy">《隐私协议》</text>
<text catchtap="jump" data-url="agreement">《用户协议》</text>
</view>
/* components/authSetting/authSetting.wxss */
.tips {
position: fixed;
width: 100%;
left: 0;
bottom: 60rpx;
font-size: 24rpx;
color: #999;
letter-spacing: 2rpx;
padding-left: 28rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
}
.tips text {
color: #ff600f;
}
.tips .icon {
position: absolute;
top: 50%;
left: 50%;
width: 24rpx;
height: 24rpx;
border-radius: 2rpx;
box-sizing: border-box;
transform: translate(-50%, -50%);
}
.tips .icon .check-img {
vertical-align: top;
width: 100%;
height: 100%;
}
.tips .choose-box {
width: 80rpx;
height: 80rpx;
position: relative;
}
\ No newline at end of file \ No newline at end of file
...@@ -17,6 +17,12 @@ Page({ ...@@ -17,6 +17,12 @@ Page({
loginToken loginToken
}) })
}, },
authChoose(e) {
let { detail: agree } = e
this.setData({
agree
})
},
changeLoginType(e) { changeLoginType(e) {
let { type } = e.currentTarget.dataset let { type } = e.currentTarget.dataset
this.setData({ this.setData({
...@@ -40,7 +46,7 @@ Page({ ...@@ -40,7 +46,7 @@ Page({
}) })
}, },
agree() { agree() {
let {agree} = this.data let { agree } = this.data
this.setData({ this.setData({
agree: !agree agree: !agree
}) })
...@@ -82,12 +88,17 @@ Page({ ...@@ -82,12 +88,17 @@ Page({
}) })
}, },
smsLogin() { smsLogin() {
const checkAgree = this.checkAgree()
if (checkAgree) return false
let { flag, code, mobile, loginType, accountNumber, password } = this.data let { flag, code, mobile, loginType, accountNumber, password } = this.data
console.log(flag) console.log(flag)
if (!flag) return if (!flag) return
wx.$util.showLoading() wx.$util.showLoading()
if (loginType == 1) { // 手机号登录 if (loginType == 1) {
api.smsLogin({ // 手机号登录
api
.smsLogin({
code, code,
mobile mobile
}) })
...@@ -112,9 +123,11 @@ Page({ ...@@ -112,9 +123,11 @@ Page({
}) })
} }
}) })
} else if (loginType == 2) { // 账号密码登录 } else if (loginType == 2) {
// 账号密码登录
console.log('账号密码登录成功') console.log('账号密码登录成功')
api.smsLogin({ api
.smsLogin({
mobile: accountNumber, mobile: accountNumber,
code: password code: password
}) })
...@@ -159,6 +172,15 @@ Page({ ...@@ -159,6 +172,15 @@ Page({
}) })
}, 1 * 1000) }, 1 * 1000)
}, },
checkAgree() {
let { agree } = this.data
console.log('agree', agree)
if (!agree) {
wx.$util.showToast('请同意用户协议')
return true
}
return false
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -168,6 +190,9 @@ Page({ ...@@ -168,6 +190,9 @@ Page({
*/ */
getPhoneNumber(e) { getPhoneNumber(e) {
console.log(e) console.log(e)
const checkAgree = this.checkAgree()
if (checkAgree) return false
let { loginToken } = this.data let { loginToken } = this.data
let { encryptedData, iv } = e.detail let { encryptedData, iv } = e.detail
if (!encryptedData) return if (!encryptedData) return
......
{ {
"usingComponents": {} "usingComponents": {
"auth-setting": "/components/authSetting/authSetting"
}
} }
...@@ -2,25 +2,46 @@ ...@@ -2,25 +2,46 @@
<block wx:if="{{loginType == 1}}"> <block wx:if="{{loginType == 1}}">
<view class='login-form'> <view class='login-form'>
<view class='input'> <view class='input'>
<input placeholder="请输入手机号" type="number" placeholder-style="color:#999;" style="width:calc(100% - 50rpx);" bindinput="input" data-name='mobile' value="{{mobile}}" maxlength="11"></input> <input
<view class='clear y-center' hidden="{{!mobile}}" bindtap="clear" data-name='mobile'> placeholder="请输入手机号"
<image src="/images/clear.png"></image> type="number"
placeholder-style="color:#999;"
style="width:calc(100% - 50rpx);"
bindinput="input"
data-name='mobile'
value="{{mobile}}"
maxlength="11" />
<view
class='clear y-center'
hidden="{{!mobile}}"
bindtap="clear"
data-name='mobile'>
<image src="/images/clear.png" />
</view> </view>
</view> </view>
<view class="sms-box"> <view class="sms-box">
<view class='input'> <view class='input'>
<input placeholder="请输入验证码" type="number" placeholder-style="color:#999;" style="width:calc(100% - 100rpx);" bindinput="input" data-name='code' value='{{code}}' maxlength="4"></input> <input
<view class='clear y-center' style="right:50rpx;" hidden="{{!code}}" bindtap="clear" data-name='code'> placeholder="请输入验证码"
<image src="/images/clear.png"></image> type="number"
placeholder-style="color:#999;"
style="width:calc(100% - 100rpx);"
bindinput="input"
data-name='code'
value='{{code}}'
maxlength="4" />
<view
class='clear y-center'
style="right:50rpx;"
hidden="{{!code}}"
bindtap="clear"
data-name='code'>
<image src="/images/clear.png" />
</view> </view>
</view> </view>
<view class="sms {{countDown?'code-disabled':''}}" bindtap="getSms"> <view class="sms {{countDown?'code-disabled':''}}" bindtap="getSms">
<block wx:if="{{countDown}}"> <block wx:if="{{countDown}}">{{count}}秒后获取</block>
{{count}}秒后获取 <block wx:else>获取验证码</block>
</block>
<block wx:else>
获取验证码
</block>
</view> </view>
</view> </view>
</view> </view>
...@@ -28,15 +49,37 @@ ...@@ -28,15 +49,37 @@
<block wx:if="{{loginType == 2}}"> <block wx:if="{{loginType == 2}}">
<view class='login-form'> <view class='login-form'>
<view class='input'> <view class='input'>
<input placeholder="请输入账号" type="number" placeholder-style="color:#999;" style="width:calc(100% - 50rpx);" bindinput="input" data-name='accountNumber' value="{{accountNumber}}"></input> <input
<view class='clear y-center' hidden="{{!accountNumber}}" bindtap="clear" data-name='accountNumber'> placeholder="请输入账号"
<image src="/images/clear.png"></image> type="number"
placeholder-style="color:#999;"
style="width:calc(100% - 50rpx);"
bindinput="input"
data-name='accountNumber'
value="{{accountNumber}}" />
<view
class='clear y-center'
hidden="{{!accountNumber}}"
bindtap="clear"
data-name='accountNumber'>
<image src="/images/clear.png" />
</view> </view>
</view> </view>
<view class='input'> <view class='input'>
<input placeholder="请输入密码" type="password" placeholder-style="color:#999;" style="width:calc(100% - 50rpx);" bindinput="input" data-name='password' value='{{password}}'></input> <input
<view class='clear y-center' hidden="{{!password}}" bindtap="clear" data-name='password'> placeholder="请输入密码"
<image src="/images/clear.png"></image> type="password"
placeholder-style="color:#999;"
style="width:calc(100% - 50rpx);"
bindinput="input"
data-name='password'
value='{{password}}' />
<view
class='clear y-center'
hidden="{{!password}}"
bindtap="clear"
data-name='password'>
<image src="/images/clear.png" />
</view> </view>
</view> </view>
</view> </view>
...@@ -50,13 +93,31 @@ ...@@ -50,13 +93,31 @@
<block>30天免登录</block> <block>30天免登录</block>
</view> </view>
<view class="login-btn {{loginType == 3?'mini':''}}"> <view class="login-btn {{loginType == 3?'mini':''}}">
<button size="default" hidden="{{loginType != 3}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button> <button
<view hidden="{{loginType !=3 }}">微信登录</view> size="default"
hidden="{{loginType != 3 || !agree}}"
open-type="getPhoneNumber"
bindgetphonenumber="getPhoneNumber" />
<view hidden="{{loginType !=3 }}" bindtap="checkAgree">微信登录</view>
<view hidden="{{loginType == 3}}" bindtap="smsLogin">登录</view> <view hidden="{{loginType == 3}}" bindtap="smsLogin">登录</view>
</view> </view>
<view class='tips' bindtap="changeLoginType" data-type="1" wx:if="{{loginType != 1}}">{{"手机号登录"}}</view> <view
class='tips'
bindtap="changeLoginType"
data-type="1"
wx:if="{{loginType != 1}}">
{{"手机号登录"}}
</view>
<!-- 暂时不做密码登录 --> <!-- 暂时不做密码登录 -->
<!-- <view class='tips' bindtap="changeLoginType" data-type="2" wx:if="{{loginType != 2}}">{{"账号密码登录"}}</view> --> <!-- <view class='tips' bindtap="changeLoginType" data-type="2" wx:if="{{loginType != 2}}">{{"账号密码登录"}}</view> -->
<view class='tips' bindtap="changeLoginType" data-type="3" wx:if="{{loginType != 3}}">{{"微信登录"}}</view> <view
class='tips'
bindtap="changeLoginType"
data-type="3"
wx:if="{{loginType != 3}}">
{{"微信登录"}}
</view>
<auth-setting bind:choose="authChoose" />
</view> </view>
</view> </view>
...@@ -193,6 +193,13 @@ ...@@ -193,6 +193,13 @@
"query": "", "query": "",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "登录页面",
"pathName": "pages/wxLogin/wxLogin",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!