Commit 7d77d9f9 by 施宇

Merge branch 'master' of http://119.23.72.7/shiyu/icsalesProgram

parents f6fe75d1 27460c84
......@@ -79,7 +79,6 @@ App({
// 查看是否授权
wx.getSetting({
success(res) {
console.log(res)
if (res.authSetting['scope.userInfo']) {
// 已经授权
wx.switchTab({
......
{
"pages": [
"pages/person/auth/index",
"pages/person/forget/index",
"pages/person/register/index",
"pages/person/verifycode/index",
"pages/person/login/index",
"pages/person/getphone/index",
"pages/person/agreement/index",
"pages/person/successfully/index",
"pages/person/register/index",
"pages/tab/home/home",
"pages/form/good/index",
"pages/tab/good/good",
......
{
"usingComponents": {},
"navigationBarTitleText": "IC业务助手用户协议",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "IC业务助手用户协议"
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ Page({
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
......@@ -84,7 +84,7 @@ Page({
});
//获取openId
http.getData(apis.getOpenId, {
http.getData(apis.getOpenId, 'GET',{
code: res.code,
'userinfo[avatarUrl]': self.data.userinfo.avatarUrl,
'userinfo[nickName]': self.data.userinfo.nickName
......@@ -110,16 +110,11 @@ Page({
}
}, true);
} else {
console.log('登录失败!' + res.errMsg);
}
},
fail(res) {
wx.showLoading({
title: '网络不通,请重试'
})
}
})
}else{
......
{
"usingComponents": {
},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"usingComponents": {},
"navigationBarTitleText": ""
}
\ No newline at end of file
const http = require('../../../utils/util.js');
import {
apis
} from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
type: 1,
btnText: '下一步',
error: false,
errorText: '',
visiblePwd: false,
passwordType: true,
mobileFlag: false,
passwordFlag: false,
codeFlag: false,
disabled: false,
disabledBtn: false,
loading: false,
currentTime: 61,
vcode: false,
vcodeFlag: false,
timeText: '发送验证码',
captchaUrl: '',
captchaUuid: '',
captcha: '',
formData: {
mobile: '',
password: '',
code: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 获取验证码
*/
getCode: function() {
let self = this;
let currentTime = this.data.currentTime;
let interval = setInterval(function() {
currentTime--;
self.setData({
timeText: currentTime + 's'
});
if (currentTime <= 0) {
clearInterval(interval);
self.setData({
timeText: '重新发送',
currentTime: 61,
disabled: false
});
}
}, 1000)
},
/**
* 发送验证码
*/
getVerificationCode: function(e) {
//验证必填手机号
if (this.data.formData.mobile) {
//验证是否发送了验证码
if (this.data.captchaUuid) {
//是否填写了验证码
if (this.data.captcha) {
http.getData(apis.getRegistCode, 'GET', {
captchaUuid: this.data.captchaUuid,
captcha: this.data.captcha,
mobile: this.data.formData.mobile,
code_type: 3
}, (res) => {
if (res.err_code === 0) {
this.getCode();
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
}, true);
} else {
this.setData({
error: true,
errorText: '图形验证码不能为空',
vcodeFlag: true
});
}
} else {
this.refreshVerification();
}
} else {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
}
},
/**
* 刷新图形验证码
*/
refreshVerification: function() {
this.setData({
vcode: true
});
http.getData(apis.captchaInfo, 'GET', null, (res) => {
this.setData({
captchaUrl: res.captchaUrl,
captchaUuid: res.captchaUuid
});
});
},
/**
* 校验字段
*/
bindinputFn: function(e) {
let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (e.currentTarget.dataset.type == 1) {
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
this.setData({
'formData.mobile': value,
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else if (e.currentTarget.dataset.type == 2) {
if (value) {
this.setData({
'formData.code': value,
error: false,
errorText: '',
codeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 3) {
if (value) {
this.setData({
captcha: value
});
this.setData({
error: false,
errorText: '',
vcodeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 4) {
if (value) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
passwordFlag: true
});
if (reg_pwd.test(value)) {
this.setData({
'formData.password': value,
error: false,
errorText: '',
passwordFlag: false
});
}
}
}
},
/**
* 校验字段
*/
calcForm: function(val, type) {
let mobile = val.mobile;
let code = val.code;
let password = val.password;
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (!mobile && type == 1) {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile) && type == 1) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
if (!code && type == 1) {
this.setData({
error: true,
errorText: '验证码不能为空',
codeFlag: true
});
return false;
}
if (!password && type == 2) {
this.setData({
error: true,
errorText: '密码不能为空',
mobileFlag: false,
passwordFlag: true
});
return false;
}
if (!reg_pwd.test(password) && type == 2) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
mobileFlag: false,
passwordFlag: true
});
return false;
}
this.setData({
error: false,
errorText: '',
codeFlag: false,
mobileFlag: false
});
return true;
},
/**
*忘记密码
*/
formSubmit: function(e) {
if (this.data.type == 1) {
//第一步
if (this.calcForm(e.detail.value, 1)) {
this.setData({
type: 2,
btnText: '设置密码'
});
}
} else if (this.data.type == 2) {
//第二步
if (this.calcForm(e.detail.value, 2)) {
let params = {
mobile: this.data.formData.mobile,
code: this.data.formData.code,
password: this.data.formData.password
}
http.getData(apis.resetPassword, 'POST', params, (res) => {
if (res.err_code === 0) {
this.setData({
type: 3
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
this.refreshVerification();
this.setData({
type: 1,
btnText: '下一步'
});
}
});
}
}
},
/**
* 密码是否可见
*/
toggleFn: function(e) {
if (this.data['visiblePwd']) {
this.setData({
visiblePwd: false,
passwordType: true
});
} else {
this.setData({
visiblePwd: true,
passwordType: false
});
}
}
})
{
"usingComponents": {},
"navigationBarTitleText": "忘记密码"
}
\ No newline at end of file
.person {
margin: 0 55rpx;
padding-top: 32rpx;
.tit {
margin-bottom: 50rpx;
.t1 {
font-size: 48rpx;
color: #2e3033;
font-weight: 600;
line-height: 67rpx;
}
.t2 {
font-size: 26rpx;
font-weight: 400;
line-height: 40px;
color: #8a9299;
}
}
.inp-wrap {
height: 98rpx;
border-bottom: 1px solid #d8dfe6;
padding-left: 10rpx;
input {
padding-left: 35rpx;
width: 340rpx;
}
.icon {
color: #adb6bf;
}
.pwd-ico {
padding-left: 160rpx;
}
.vcode {
font-size: 32rpx;
color: #61a0f2;
background: none;
font-weight: 400;
border: 0 !important;
&::after {
border: 0 !important;
}
}
.areacode {
border-left: 1px solid #d8dfe6;
.tel-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.icon {
color: #d8dfe6;
font-size: 26rpx;
}
}
}
.register-button {
height: 98rpx;
line-height: 98rpx;
background: rgba(13, 132, 209, 1) !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
text-align: center;
}
.error-wrap {
margin-top: 24rpx;
.error {
.iconfont {
color: #ea1717;
}
.txt {
font-size: 24rpx;
color: #ea1717;
margin-left: 15rpx;
}
}
.forget {
font-size: 28rpx;
color: #61a0f2;
}
}
.placeholderClass {
color: #adb6bf;
font-size: 32rpx;
}
.inp-error {
border-bottom: 1px solid #ea1717;
.icon {
color: #ea1717;
}
input {
color: #ea1717;
}
}
}
.success {
width: 100%;
padding-top: 50rpx;
.img {
width: 480rpx;
height: 346rpx;
}
.t1 {
padding-top: 40rpx;
margin-bottom: 14rpx;
font-size: 48rpx;
color: #2e3033;
line-height: 67rpx;
font-weight: 600;
display: block;
}
.t2 {
font-size: 26rpx;
font-weight: 400;
color: #8a9299;
margin-bottom: 66rpx;
}
}
<!-- 注册 -->
<view class="person">
<view class="column tit" wx:if="{{type === 1 || type === 2}}">
<text class="t1">验证手机号</text>
<text class="t2">知道吗! 还可以用验证登录呢</text>
</view>
<form bindsubmit="formSubmit">
<block wx:if="{{type === 1}}">
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1"
bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{vcodeFlag ? 'inp-error':''}}" wx:if="{{vcode}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
</block>
<block wx:elif="{{type === 2}}">
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入新密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4"
password='{{passwordType}}' bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
<block wx:else>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text>
</block>
</view>
</view>
</block>
<block wx:elif="{{type === 3}}">
<view class="success column rowCenter verCenter">
<cover-image src="/res/images/imgs/scu.png" class="img"></cover-image>
<text class="t1">恭喜您,密码找回成功</text>
<text class="t2">请保管好您的账户信息。</text>
</view>
<navigator url="/pages/tab/home/home" class="register-button" open-type="switchTab">返回首页</navigator>
</block>
<view class="error-wrap row bothSide verCenter" wx:if="{{type === 1 || type === 2}}">
<view class="error">
<block wx:if="{{error}}">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">{{errorText}}</text>
</block>
</view>
</view>
<button wx:if="{{type === 1 || type === 2}}" class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">{{btnText}}</button>
</form>
</view>
.person {
margin: 0 55rpx;
padding-top: 32rpx;
}
.person .tit {
margin-bottom: 50rpx;
}
.person .tit .t1 {
font-size: 48rpx;
color: #2e3033;
font-weight: 600;
line-height: 67rpx;
}
.person .tit .t2 {
font-size: 26rpx;
font-weight: 400;
line-height: 40px;
color: #8a9299;
}
.person .inp-wrap {
height: 98rpx;
border-bottom: 1px solid #d8dfe6;
padding-left: 10rpx;
}
.person .inp-wrap input {
padding-left: 35rpx;
width: 340rpx;
}
.person .inp-wrap .icon {
color: #adb6bf;
}
.person .inp-wrap .pwd-ico {
padding-left: 160rpx;
}
.person .inp-wrap .vcode {
font-size: 32rpx;
color: #61a0f2;
background: none;
font-weight: 400;
border: 0 !important;
}
.person .inp-wrap .vcode::after {
border: 0 !important;
}
.person .inp-wrap .areacode {
border-left: 1px solid #d8dfe6;
}
.person .inp-wrap .areacode .tel-value {
font-size: 32rpx;
color: #515559;
padding: 7rpx 11rpx 7rpx 16rpx;
}
.person .inp-wrap .areacode .icon {
color: #d8dfe6;
font-size: 26rpx;
}
.person .register-button {
height: 98rpx;
line-height: 98rpx;
background: #0d84d1 !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
text-align: center;
}
.person .error-wrap {
margin-top: 24rpx;
}
.person .error-wrap .error .iconfont {
color: #ea1717;
}
.person .error-wrap .error .txt {
font-size: 24rpx;
color: #ea1717;
margin-left: 15rpx;
}
.person .error-wrap .forget {
font-size: 28rpx;
color: #61a0f2;
}
.person .placeholderClass {
color: #adb6bf;
font-size: 32rpx;
}
.person .inp-error {
border-bottom: 1px solid #ea1717;
}
.person .inp-error .icon {
color: #ea1717;
}
.person .inp-error input {
color: #ea1717;
}
.success {
width: 100%;
padding-top: 50rpx;
}
.success .img {
width: 480rpx;
height: 346rpx;
}
.success .t1 {
padding-top: 40rpx;
margin-bottom: 14rpx;
font-size: 48rpx;
color: #2e3033;
line-height: 67rpx;
font-weight: 600;
display: block;
}
.success .t2 {
font-size: 26rpx;
font-weight: 400;
color: #8a9299;
margin-bottom: 66rpx;
}
const http = require('../../../utils/util.js');
import { apis } from '../../../utils/api.js';
import {
apis
} from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 一键获取手机号
*/
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok'){
http.getData(apis.getwxUserInfo, {
openid: wx.getStorageSync('openid'),
session_key: wx.getStorageSync('session_key'),
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}, function (res) {
if (res.err_code === 0) {
//注入token
wx.setStorage({
key: "access_token",
data: res.data.access_token
});
wx.switchTab({
url: '/pages/tab/home/home'
});
}
},true);
}else{
//用户拒绝获取手机
wx.navigateTo({
url: '/pages/person/login/index'
});
}
}
})
\ No newline at end of file
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 一键获取手机号
*/
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
http.getData(apis.getwxUserInfo, 'GET', {
openid: wx.getStorageSync('openid'),
session_key: wx.getStorageSync('session_key'),
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}, (res) => {
if (res.err_code === 0) {
//注入token
wx.setStorage({
key: "access_token",
data: res.data.access_token
});
wx.switchTab({
url: '/pages/tab/home/home'
});
}
}, true);
} else {
//用户拒绝获取手机
wx.navigateTo({
url: '/pages/person/login/index'
});
}
}
})
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -99,7 +99,6 @@ Page({
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile)) {
......@@ -109,9 +108,7 @@ Page({
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
......@@ -123,7 +120,6 @@ Page({
mobileFlag: false,
passwordFlag: true
});
return false;
}
......@@ -135,9 +131,7 @@ Page({
mobileFlag: false,
passwordFlag: true
});
return false;
}
this.setData({
......@@ -168,7 +162,7 @@ Page({
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
error: false,
errorText: '',
......@@ -216,7 +210,7 @@ Page({
loading: true
});
http.postData(apis.authlogin, e.detail.value, function (res) {
http.getData(apis.authlogin,'POST', e.detail.value, function (res) {
if (res.err_code === 0) {
......
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn' bindblur='bindblurFn'></input>
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
......@@ -22,7 +22,7 @@
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="2" password='{{passwordType}}' bindinput='bindinputFn' bindblur='bindblurFn'></input>
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="2" password='{{passwordType}}' bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
......@@ -41,7 +41,7 @@
</block>
</view>
<navigator class="forget" url="pages/person/verifycode/index">忘记密码?</navigator>
<navigator class="forget" url="/pages/person/forget/index">忘记密码?</navigator>
</view>
......@@ -50,7 +50,7 @@
<view class="bottom row bothSide">
<navigator class="txt" url="/pages/person/verifycode/index">验证码登录</navigator>
<navigator class="txt" url="/pages/person/verifycode/index">注册账户</navigator>
<navigator class="txt" url="/pages/person/register/index">注册账户</navigator>
</view>
</view>
\ No newline at end of file
// pages/person/register/index.js
const http = require('../../../utils/util.js');
import {
apis
} from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
/**
* 页面的初始数据
*/
data: {
error: false,
errorText: '',
visiblePwd: false,
passwordType: true,
mobileFlag: false,
passwordFlag: false,
codeFlag: false,
disabled: false,
disabledBtn: false,
loading: false,
currentTime: 61,
vcode: false,
vcodeFlag: false,
timeText: '发送验证码',
captchaUrl: '',
captchaUuid: '',
captcha: '',
formData: {
mobile: '',
code: ''
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
},
/**
* 获取验证码
*/
getCode: function() {
let self = this;
let currentTime = this.data.currentTime;
let interval = setInterval(function() {
currentTime--;
self.setData({
timeText: currentTime + 's'
});
if (currentTime <= 0) {
clearInterval(interval);
self.setData({
timeText: '重新发送',
currentTime: 61,
disabled: false
});
}
}, 1000)
},
/**
* 发送验证码
*/
getVerificationCode: function(e) {
//验证必填手机号
if (this.data.formData.mobile) {
//验证是否发送了验证码
if (this.data.captchaUuid) {
//是否填写了验证码
if (this.data.captcha) {
http.getData(apis.getRegistCode,'GET',{
captchaUuid: this.data.captchaUuid,
captcha: this.data.captcha,
mobile: this.data.formData.mobile,
code_type: 1
}, (res) => {
if (res.err_code === 0) {
this.getCode();
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
}, true);
} else {
this.setData({
error: true,
errorText: '图形验证码不能为空',
vcodeFlag: true
});
}
} else {
this.refreshVerification();
}
} else {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
}
},
/**
* 刷新图形验证码
*/
refreshVerification: function() {
this.setData({
vcode: true
});
http.getData(apis.captchaInfo,'GET',null, (res) => {
this.setData({
captchaUrl: res.captchaUrl,
captchaUuid: res.captchaUuid
});
});
},
/**
* 校验字段
*/
bindinputFn: function(e) {
let value = e.detail.value
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (e.currentTarget.dataset.type == 1) {
this.setData({
'formData.mobile': value
});
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
error: false,
errorText: '',
mobileFlag: false
});
}
}
} else if (e.currentTarget.dataset.type == 2) {
if (value) {
this.setData({
error: false,
errorText: '',
codeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 3) {
if (value) {
this.setData({
captcha: value
});
this.setData({
error: false,
errorText: '',
vcodeFlag: false
});
}
} else if (e.currentTarget.dataset.type == 4) {
if (value) {
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
passwordFlag: true
});
if (reg_pwd.test(value)) {
this.setData({
error: false,
errorText: '',
passwordFlag: false
});
}
}
}
},
/**
* 校验字段
*/
calcForm: function(val, type) {
let mobile = val.mobile;
let code = val.code;
let password = val.password;
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
let reg_pwd = /^[0-9A-Za-z]{6,}$/;
if (!mobile) {
this.setData({
error: true,
errorText: '手机号不能为空',
mobileFlag: true
});
return false;
}
if (!reg_mobile.test(mobile)) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
return false;
}
if (!password) {
this.setData({
error: true,
errorText: '密码不能为空',
mobileFlag: false,
passwordFlag: true
});
return false;
}
if (!reg_pwd.test(password)) {
},
this.setData({
error: true,
errorText: '密码由字母和数字组成,且不能少于6位',
mobileFlag: false,
passwordFlag: true
});
return false;
}
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (!code) {
},
this.setData({
error: true,
errorText: '验证码不能为空',
codeFlag: true
});
return false;
}
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
this.setData({
error: false,
errorText: '',
codeFlag: false,
mobileFlag: false
});
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
return true;
},
/**
*注册
*/
formSubmit: function(e) {
},
if (this.calcForm(e.detail.value)) {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
this.setData({
disabledBtn: true,
loading: true
});
},
http.getData(apis.authRegister,'POST', e.detail.value, (res) => {
if (res.err_code === 0) {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
//注入token
wx.setStorage({
key: "access_token",
data: res.data.access_token
});
},
wx.navigateTo({
url: '/pages/person/successfully/index'
});
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
}else if(res.err_code === 500){
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
}
this.setData({
disabledBtn: false,
loading: false
});
});
}
},
/**
* 密码是否可见
*/
toggleFn: function(e) {
},
if (this.data['visiblePwd']) {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
visiblePwd: false,
passwordType: true
});
},
} else {
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
this.setData({
visiblePwd: true,
passwordType: false
});
}
})
\ No newline at end of file
}
}
})
{
"usingComponents": {},
"navigationBarTitleText": "免费注册",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "免费注册"
}
\ No newline at end of file
.person {
.person {
margin: 0 55rpx;
padding-top: 32rpx;
.tit {
......@@ -50,10 +50,10 @@
.register-button {
height: 98rpx;
line-height: 98rpx;
background: rgba(13, 132, 209, 1);
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3);
background: rgba(13, 132, 209, 1) !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
}
......@@ -90,4 +90,13 @@
color: #adb6bf;
font-size: 32rpx;
}
.inp-error {
border-bottom: 1px solid #ea1717;
.icon {
color: #ea1717;
}
input {
color: #ea1717;
}
}
}
<!-- 注册 -->
<view class="person">
<view class="column tit">
<text class="t1">Hi,上午好</text>
<text class="t1">欢迎注册账户!</text>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass"></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请设置密码" placeholder-class="placeholderClass" class="pwd"></input>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico"></text>
</view>
</view>
<view class="inp-wrap row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass"></input>
<button class="vcode">发送验证码</button>
</view>
</view>
<view class="error-wrap row bothSide verCenter">
<view class="error">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">密码错误,请重新输入</text>
</view>
</view>
<button class="register-button">注册</button>
<view class="agreement">
<text class="t1">点击注册即默认同意</text>
<navigator url="/pages/person/agreement/index" class="t2">《IC业务助手用户协议》</navigator>
</view>
</view>
\ No newline at end of file
<view class="column tit">
<text class="t1">Hi,上午好</text>
<text class="t1">欢迎注册账户!</text>
</view>
<form bindsubmit="formSubmit">
<view class="inp-wrap row verCenter {{mobileFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji21"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机号" placeholder-class="placeholderClass" name="mobile" type="number" data-type="1" bindinput='bindinputFn'></input>
<view class="areacode" bindtap="switchPrice">
<text class="tel-value">中国 + 86</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{passwordFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji2"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入密码" placeholder-class="placeholderClass" class="pwd" name="password" data-type="4" password='{{passwordType}}'
bindinput='bindinputFn'></input>
<block wx:if="{{visiblePwd}}">
<text class="icon iconfont iconiconxiantiaoshouji3 pwd-ico" bindtap="toggleFn"></text>
</block>
<block wx:else>
<text class="icon iconfont iconiconxiantiaoshouji4 pwd-ico" bindtap="toggleFn"></text>
</block>
</view>
</view>
<view class="inp-wrap row verCenter {{vcodeFlag ? 'inp-error':''}}" wx:if="{{vcode}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入图形验证码" placeholder-class="placeholderClass" name='captcha' data-type="3" bindinput='bindinputFn'></input>
<view class='code-img'>
<cover-image src="{{captchaUrl}}" class="img" bindtap='refreshVerification'></cover-image>
</view>
</view>
</view>
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
<view class="error-wrap row bothSide verCenter">
<view class="error">
<block wx:if="{{error}}">
<text class="icon iconfont iconiconxiantiaoshouji1"></text>
<text class="txt">{{errorText}}</text>
</block>
</view>
</view>
<button class="register-button" form-type="submit" disabled="{{disabledBtn}}" loading="{{loading}}">注册</button>
</form>
<view class="agreement">
<text class="t1">点击注册即默认同意</text>
<navigator url="/pages/person/agreement/index" class="t2">《IC业务助手用户协议》</navigator>
</view>
</view>
......@@ -51,10 +51,10 @@
.person .register-button {
height: 98rpx;
line-height: 98rpx;
background: #0d84d1;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3);
background: #0d84d1 !important;
box-shadow: 0px 6rpx 10rpx 0rpx rgba(97, 160, 242, 0.3) !important;
border-radius: 8rpx;
color: #fff;
color: #fff !important;
font-size: 32rpx;
margin-top: 40rpx;
}
......@@ -89,3 +89,12 @@
color: #adb6bf;
font-size: 32rpx;
}
.person .inp-error {
border-bottom: 1px solid #ea1717;
}
.person .inp-error .icon {
color: #ea1717;
}
.person .inp-error input {
color: #ea1717;
}
......@@ -62,5 +62,13 @@ Page({
*/
onShareAppMessage: function () {
},
/**
* 暂不认证
*/
toUrl: function() {
wx.switchTab({
url: '/pages/tab/home/home'
})
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "注册成功",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": "注册成功"
}
\ No newline at end of file
......@@ -7,5 +7,5 @@
<text class="t2">资质认证</text>
<text class="t1">” 否则将影响您的询价和报价业务</text>
</view>
<text class="skip-text">暂不认证,跳过</text>
<text class="skip-text" bindtap="toUrl">暂不认证,跳过</text>
</view>
......@@ -126,7 +126,7 @@ Page({
//是否填写了验证码
if (this.data.captcha) {
http.getData(apis.getRegistCode, {
http.getData(apis.getRegistCode, 'GET', {
captchaUuid: this.data.captchaUuid,
captcha: this.data.captcha,
mobile: this.data.formData.mobile,
......@@ -137,6 +137,14 @@ Page({
this.setData({
disabled: true
});
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
......@@ -174,7 +182,7 @@ Page({
vcode: true
});
http.getData(apis.captchaInfo, null, (res) => {
http.getData(apis.captchaInfo, 'GET', null, (res) => {
this.setData({
captchaUrl: res.captchaUrl,
captchaUuid: res.captchaUuid
......@@ -189,21 +197,19 @@ Page({
let reg_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
if (e.currentTarget.dataset.type == 1) {
this.setData({
'formData.mobile': value
});
if (value) {
this.setData({
error: true,
errorText: '请填写正确的手机号',
mobileFlag: true
});
if (reg_mobile.test(value)) {
wx.hideKeyboard();
this.setData({
'formData.mobile': value,
error: false,
errorText: '',
mobileFlag: false
......@@ -289,16 +295,14 @@ Page({
*/
formSubmit: function(e) {
var self = this;
if (this.calcForm(e.detail.value)) {
self.setData({
this.setData({
disabledBtn: true,
loading: true
});
http.postData(apis.authMobilelogin, e.detail.value, (res) => {
http.getData(apis.authMobilelogin, 'POST', e.detail.value, (res) => {
if (res.err_code === 0) {
//注入token
......@@ -311,6 +315,14 @@ Page({
url: '/pages/tab/home/home'
})
} else if (res.err_code === 500) {
//图形验证码不正确的时候
this.refreshVerification();
wx.showToast({
title: res.err_msg,
icon: 'none',
duration: 2000
});
} else {
wx.showToast({
title: res.err_msg,
......@@ -318,7 +330,7 @@ Page({
duration: 2000
});
}
self.setData({
this.setData({
disabledBtn: false,
loading: false
});
......
{
"usingComponents": {},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "white",
"navigationBarTextStyle": "black",
"backgroundColor": "white"
"navigationBarTitleText": ""
}
\ No newline at end of file
......@@ -30,7 +30,7 @@
<view class="inp-wrap row verCenter {{codeFlag ? 'inp-error':''}}">
<text class="icon iconfont iconiconxiantiaoshouji"></text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入手机验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<input placeholder="请输入验证码" placeholder-class="placeholderClass" name='code' data-type="2" bindinput='bindinputFn'></input>
<button class="vcode {{disabled ? 'vcode-color':''}}" disabled="{{disabled}}" bindtap="getVerificationCode">{{timeText}}</button>
</view>
</view>
......
......@@ -11,6 +11,10 @@ const apis = {
* 授权接口
*/
getOpenId: auth_url + '/v1/getOpenId',
/**
* 刷新token
*/
authRefresh: auth_url + '/auth/refresh',
/**
* 获取微信用户信息
*/
......@@ -34,7 +38,7 @@ const apis = {
/**
* 获取图形验证码接口
*/
captchaInfo: auth_url + '/captchaInfo',
captchaInfo: auth_url + '/captchaInfo/wx',
/**
* 注册获取短信验证码接口
*/
......
//数据请求(get)
const getData = (url, param, callBack,loading) => {
wx.showNavigationBarLoading();
var params = Object.assign({}, param, { pf: 1 });
if(loading){
wx.showLoading();
}
wx.request({
url: url,
data: params,
header: {
"Content-Type": "applciation/json"
},
success: (res) => {
typeof callBack == "function" && callBack(res.data, "");
wx.hideNavigationBarLoading();
wx.hideLoading();
},
fail: (err) => {
typeof callBack == "function" && callBack(null, err.errMsg);
console.log(err);
wx.hideNavigationBarLoading();
wx.hideLoading();
}
})
};
//数据请求(post)
const postData = (url, param, callBack, loading) => {
wx.showNavigationBarLoading();
var params = Object.assign({}, param, { pf: 1 });
if (loading) {
wx.showLoading();
}
wx.request({
url: url,
data: params,
header: {
"Content-Type": "applciation/json"
},
method: "POST",
success: (res) => {
typeof callBack == "function" && callBack(res.data, "");
wx.hideNavigationBarLoading();
wx.hideLoading();
},
fail: (err) => {
typeof callBack == "function" && callBack(null, err.errMsg);
console.log(err);
wx.hideNavigationBarLoading();
wx.hideLoading();
}
})
import {
apis
} from './api.js';
//数据请求(get,post)
const getData = (url, type, param, callBack, loading, isheader) => {
wx.showNavigationBarLoading();
//获取token
var token, header;
wx.getStorage({
key: 'access_token',
success(res) {
if (res.data) {
token = res.data;
}
}
});
//参数字段追加来源字段
var params = Object.assign({}, param, {
source: 1
});
//是否启用loading加载效果
if (loading) {
wx.showLoading();
}
//是否启用请求头token
if (isheader) {
header = {
"Content-Type": "applciation/json",
"Authorization": 'Bearer ' + token
}
} else {
header = {
"Content-Type": "applciation/json"
}
}
wx.request({
url: url,
data: params,
header: header,
method: type,
success: (res) => {
//处理token失效的情况
if (res.data.hasOwnProperty('data')) {
if (res.data.data.err_code === 501 || res.data.data.errcode === 501) {
wx.navigateTo({
url: '/pages/person/login/index'
});
} else {
typeof callBack == "function" && callBack(res.data, "");
}
} else {
typeof callBack == "function" && callBack(res.data, "");
}
wx.hideNavigationBarLoading();
wx.hideLoading();
},
fail: (err) => {
typeof callBack == "function" && callBack(null, err.errMsg);
console.log(err);
wx.hideNavigationBarLoading();
wx.hideLoading();
}
})
};
//上传文件
const uploadFile = (paths, callBack) => {
let gUrl = getApp().globalUrl;
showLoading('正在上传', true)
for (var i = 0; i < paths.length; i++) {
wx.uploadFile({
url: gUrl.baseUrl + gUrl.uploadImg,
filePath: paths[i],
name: 'file',
success: (res) => {
var data = JSON.parse(res.data);
if (data.suc == 'y') {
callBack({
imgSrc: data.data.file.url,
image_id: data.data.file.image_id
})
} else {
showModal(data.msg);
}
},
fail: () => {
showModal("上传图片失败!");
},
complete: () => {
wx.hideLoading();
}
})
}
let gUrl = getApp().globalUrl;
showLoading('正在上传', true)
for (var i = 0; i < paths.length; i++) {
wx.uploadFile({
url: gUrl.baseUrl + gUrl.uploadImg,
filePath: paths[i],
name: 'file',
success: (res) => {
var data = JSON.parse(res.data);
if (data.suc == 'y') {
callBack({
imgSrc: data.data.file.url,
image_id: data.data.file.image_id
})
} else {
showModal(data.msg);
}
},
fail: () => {
showModal("上传图片失败!");
},
complete: () => {
wx.hideLoading();
}
})
}
};
const chooseImg = (num, callback) => {
wx.chooseImage({
count: num,
success: (res) => {
var arr = [];
uploadFile(res.tempFilePaths, (rtn) => {
arr.push(rtn)
if (arr.length === res.tempFilePaths.length) {
callback(arr)
}
})
}
})
wx.chooseImage({
count: num,
success: (res) => {
var arr = [];
uploadFile(res.tempFilePaths, (rtn) => {
arr.push(rtn)
if (arr.length === res.tempFilePaths.length) {
callback(arr)
}
})
}
})
};
module.exports = {
getData: getData,
postData: postData,
chooseImg: chooseImg
}
\ No newline at end of file
getData: getData,
chooseImg: chooseImg
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment