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,63 +88,70 @@ Page({ ...@@ -82,63 +88,70 @@ 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({ // 手机号登录
code, api
mobile .smsLogin({
}) code,
.then(result => { mobile
wx.$util.showLoading() })
if (result.code == 0) { .then(result => {
let { loginUserInfoList, sessionId } = result.data wx.$util.showLoading()
if (loginUserInfoList.length > 0) { if (result.code == 0) {
wx.$util.setSessionId(sessionId) let { loginUserInfoList, sessionId } = result.data
wx.$router.reLaunch('pages.accountItems') if (loginUserInfoList.length > 0) {
wx.$util.setSessionId(sessionId)
wx.$router.reLaunch('pages.accountItems')
} else {
wx.$router.reLaunch('pages.nothing')
}
} else { } else {
wx.$router.reLaunch('pages.nothing') wx.hideLoading()
wx.showModal({
title: '温馨提示',
content: result.message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#3582EE'
})
} }
} else { })
wx.hideLoading() } else if (loginType == 2) {
wx.showModal({ // 账号密码登录
title: '温馨提示',
content: result.message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#3582EE'
})
}
})
} else if (loginType == 2) { // 账号密码登录
console.log('账号密码登录成功') console.log('账号密码登录成功')
api.smsLogin({ api
mobile: accountNumber, .smsLogin({
code: password mobile: accountNumber,
}) code: password
.then(result => { })
wx.$util.showLoading() .then(result => {
if (result.code == 0) { wx.$util.showLoading()
let { loginUserInfoList, sessionId } = result.data if (result.code == 0) {
if (loginUserInfoList.length > 0) { let { loginUserInfoList, sessionId } = result.data
wx.$util.setSessionId(sessionId) if (loginUserInfoList.length > 0) {
wx.$router.reLaunch('pages.accountItems') wx.$util.setSessionId(sessionId)
wx.$router.reLaunch('pages.accountItems')
} else {
wx.$router.reLaunch('pages.nothing')
}
} else { } else {
wx.$router.reLaunch('pages.nothing') wx.hideLoading()
wx.showModal({
title: '温馨提示',
content: result.message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#3582EE'
})
} }
} else { })
wx.hideLoading()
wx.showModal({
title: '温馨提示',
content: result.message,
showCancel: false,
confirmText: '知道了',
confirmColor: '#3582EE'
})
}
})
} }
}, },
playCountDown() { playCountDown() {
...@@ -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": {}
}
\ No newline at end of file \ No newline at end of file
"usingComponents": {
"auth-setting": "/components/authSetting/authSetting"
}
}
...@@ -2,61 +2,122 @@ ...@@ -2,61 +2,122 @@
<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>
</block> </block>
<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 class='input'>
<input
placeholder="请输入密码"
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 class='input'>
<input placeholder="请输入密码" type="password" placeholder-style="color:#999;" style="width:calc(100% - 50rpx);" bindinput="input" data-name='password' value='{{password}}'></input>
<view class='clear y-center' hidden="{{!password}}" bindtap="clear" data-name='password'>
<image src="/images/clear.png"></image>
</view>
</view>
</view> </view>
</block> </block>
<view class='box'> <view class='box'>
<!-- <view class='box' style="top:{{loginType?'-264rpx':'0'}}"> --> <!-- <view class='box' style="top:{{loginType?'-264rpx':'0'}}"> -->
<view class="agree" bindtap="agree" wx:if="{{loginType == 2}}"> <view class="agree" bindtap="agree" wx:if="{{loginType == 2}}">
<view class="icon {{agree}}"> <view class="icon {{agree}}">
<image src="../../components/images/radio.png" /> <image src="../../components/images/radio.png" />
</view> </view>
<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'
<!-- <view class='tips' bindtap="changeLoginType" data-type="2" wx:if="{{loginType != 2}}">{{"账号密码登录"}}</view> --> bindtap="changeLoginType"
<view class='tips' bindtap="changeLoginType" data-type="3" wx:if="{{loginType != 3}}">{{"微信登录"}}</view> 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="3"
wx:if="{{loginType != 3}}">
{{"微信登录"}}
</view>
<auth-setting bind:choose="authChoose" />
</view> </view>
</view>
\ No newline at end of file \ No newline at end of file
</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!