@@ -10,29 +10,57 @@ App({ | |||||
this.getUserInfo() | this.getUserInfo() | ||||
// 登录 | // 登录 | ||||
wx.login({ | wx.login({ | ||||
success: ({ code }) => { | |||||
Http.post({ | |||||
success: function(res) { | |||||
var code = res.code; | |||||
console.log(code); | |||||
wx.request({ | |||||
url: config.api.login, | url: config.api.login, | ||||
data: { | data: { | ||||
appId: config.weapp.AppId, | appId: config.weapp.AppId, | ||||
code: code, | code: code, | ||||
sceneAddress: this.globalData.sceneAddress, | |||||
} | |||||
}).then(res => { | |||||
// console.log("req",res); | |||||
this.globalData.token = res.token; | |||||
Http.setToken(res.token) | |||||
Http.get({ | |||||
url: config.api.checkUserStatus, | |||||
data: { } | |||||
}).then(statusres => { | |||||
if (statusres.code == 11004) { | |||||
// 用户昵称未授权 | |||||
wx.redirectTo({ | |||||
url: '../getuserinfo/index', | |||||
}) | |||||
screneAddress: options.scene | |||||
}, | |||||
method: "POST", | |||||
success: function (res) { | |||||
console.log(res); | |||||
that.globalData.token = res.data.token; | |||||
console.log(that.globalData.token) | |||||
that.globalData.openId = res.data.openId; | |||||
//由于这里是网络请求,可能会在 Page.onLoad 之后才返回 | |||||
// 所以此处加入 callback 以防止这种情况 | |||||
if (that.openIdCallback) { | |||||
console.log(res.data.openId); | |||||
that.openIdCallback(res.data.openId); | |||||
} | } | ||||
}) | |||||
wx.request({ | |||||
url: config.api.checkUserStatus, | |||||
header: { | |||||
"token": that.globalData.token | |||||
}, | |||||
success: function (res) { | |||||
console.log(res); | |||||
//如果是新用户未获取unionId | |||||
if (res.data.code == config.ErrorCode.NICK_NOT_AUTH) { | |||||
wx.redirectTo({ | |||||
url: '../getuserinfo/index', | |||||
}) | |||||
} | |||||
//如果是跳转到首页 | |||||
else if (res.data.code == 200) { | |||||
// 老用户跳转首页 | |||||
} else { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
}) | |||||
} | |||||
}, | |||||
fail: function(res) { | |||||
wx.showToast({ | |||||
title: res.data.message, | |||||
}) | |||||
} | |||||
}) | |||||
} | |||||
}) | }) | ||||
} | } | ||||
}) | }) | ||||
@@ -1,7 +1,6 @@ | |||||
// var url = 'https://ciformall.youlane.cn' | |||||
// //var url = 'http://a8b668aa.ngrok.io' | |||||
// //var url = 'http://localhost:8001' | |||||
// var apiPrefix = url + '/C'; | |||||
var url = 'https://ciformall.youlane.cn' | |||||
//var url = 'http://7479f9de.ngrok.io' | |||||
var apiPrefix = url + '/C'; | |||||
var config = { | var config = { | ||||
name: "富茂", | name: "富茂", | ||||
url: "https://ciformall.youlane.cn/C", | url: "https://ciformall.youlane.cn/C", | ||||
@@ -58,9 +57,14 @@ var config = { | |||||
weapp: { | weapp: { | ||||
AppId: 'wx8eb8275b78db4ede', | AppId: 'wx8eb8275b78db4ede', | ||||
} | |||||
}, | |||||
ErrorCode: { | |||||
NICK_NOT_AUTH: 11004, | |||||
PHONE_NOT_AUTH: 11005, | |||||
PHONE_IS_ENCRYPTED: 11006, | |||||
}, | |||||
}; | }; | ||||
// for (var key in config.api) { | |||||
// config.api[key] = apiPrefix + config.api[key]; | |||||
// } | |||||
for (var key in config.api) { | |||||
config.api[key] = apiPrefix + config.api[key]; | |||||
} | |||||
module.exports = config; | module.exports = config; |
@@ -0,0 +1,73 @@ | |||||
// pages/forgetpwd/forgetpwd.js | |||||
const Http = require('../../../utils/http.js') | |||||
const app = getApp() | |||||
Page({ | |||||
data: { | |||||
phone: '', | |||||
yzm: '', | |||||
flag: true, | |||||
retry: false, | |||||
time: 60 | |||||
}, | |||||
getYZM(e) { | |||||
this.setData({ | |||||
phone: e.detail.value.phone, | |||||
yzm: e.detail.value.yzm | |||||
}) | |||||
}, | |||||
next() { | |||||
console.log(this.data.yzm) | |||||
Http.getResquest('/wxMsgValidationcode/hasvalidationcode', '', '加载中', { | |||||
phone: this.data.phone, | |||||
code: this.data.yzm, | |||||
type: 1, | |||||
appid: app.globalData.appId | |||||
}, (res) => { | |||||
console.log(res) | |||||
if (res.code == 200) { | |||||
//wx.navigateTo({ | |||||
// url: `../setpwd/setpwd?phone=${this.data.phone}&code=${this.data.yzm}` | |||||
//}) | |||||
} else { | |||||
wx.showToast({ | |||||
title: res.res, | |||||
}) | |||||
} | |||||
}) | |||||
}, | |||||
send() { | |||||
var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/; | |||||
if (phoneReg.test(this.data.phone)) { | |||||
this.setData({ | |||||
flag: false, | |||||
retry: true | |||||
}) | |||||
Http.getResquest('/wxMsgValidationcode/sendvalidationcode', '', '加载中', { | |||||
phone: this.data.phone, | |||||
type: 1, | |||||
appid: app.globalData.appId | |||||
}, (res) => { | |||||
console.log(res) | |||||
var timer = setInterval(() => { | |||||
this.data.time-- | |||||
this.setData({ | |||||
time: this.data.time | |||||
}) | |||||
if (this.data.time == 0) { | |||||
clearInterval(timer) | |||||
this.setData({ | |||||
flag: true, | |||||
retry: false, | |||||
time:60 | |||||
}) | |||||
} | |||||
}, 1000) | |||||
}) | |||||
} else { | |||||
wx.showToast({ | |||||
title: '请输入有效手机号', | |||||
}) | |||||
} | |||||
} | |||||
}) |
@@ -0,0 +1,6 @@ | |||||
{ | |||||
"backgroundTextStyle": "light", | |||||
"navigationBarBackgroundColor": "#fff", | |||||
"navigationBarTitleText": "找回密码", | |||||
"navigationBarTextStyle": "black" | |||||
} |
@@ -0,0 +1,18 @@ | |||||
<!--pages/phoneinput/phoneinput.wxml--> | |||||
<view class='forgetpwd'> | |||||
<form bindsubmit='getYZM'> | |||||
<view class='retrievepwd'> | |||||
<view> | |||||
<text>+86</text> | |||||
<text class='line'></text> | |||||
<input type='text' name='phone'/> | |||||
<button form-type='submit' class='send' bindtap='send' wx:if='{{flag}}'>发送验证码</button> | |||||
<text class='try' wx:if='{{retry}}'>{{time}}秒后重试</text> | |||||
</view> | |||||
<view> | |||||
<input type='number' placeholder='请输入验证码' name='yzm' /> | |||||
</view> | |||||
</view> | |||||
<button form-type='submit' bindtap='next'>下一步</button> | |||||
</form> | |||||
</view> |
@@ -0,0 +1,79 @@ | |||||
/* pages/forgetpwd/forgetpwd.wxss */ | |||||
/**index.wxss**/ | |||||
.forgetpwd { | |||||
width: 100%; | |||||
display: flex; | |||||
flex-direction: column; | |||||
} | |||||
.retrievepwd { | |||||
width: 100%; | |||||
display: flex; | |||||
flex-direction: column; | |||||
position: relative; | |||||
} | |||||
.retrievepwd view { | |||||
width: 90%; | |||||
display: flex; | |||||
margin: 0 auto; | |||||
border-bottom: 1rpx solid #d7d7d7; | |||||
padding: 3.3% 0; | |||||
padding-left: 4%; | |||||
position: relative; | |||||
} | |||||
.line { | |||||
width: 2rpx; | |||||
height: 22rpx; | |||||
background: #d7d7d7; | |||||
position: absolute; | |||||
left: 20%; | |||||
top: 38rpx; | |||||
} | |||||
.retrievepwd view input { | |||||
font-size: 34rpx; | |||||
} | |||||
.retrievepwd view:nth-child(1) input { | |||||
width: 58%; | |||||
padding-left: 60rpx; | |||||
} | |||||
.retrievepwd view text:nth-child(4) { | |||||
color: #00c0ff; | |||||
font-size: 28rpx; | |||||
} | |||||
.forgetpwd button { | |||||
width: 92%; | |||||
height: 6.6%; | |||||
background: #00c0ff; | |||||
color: #fff; | |||||
margin-top: 10.3%; | |||||
font-size: 36rpx; | |||||
} | |||||
.send { | |||||
width: 218rpx !important; | |||||
height: 40rpx !important; | |||||
font-size: 28rpx !important; | |||||
line-height: 40rpx; | |||||
position: absolute; | |||||
right: 0; | |||||
top: -34rpx; | |||||
background: #fff!important; | |||||
color: #00c0ff!important; | |||||
} | |||||
button::after{ | |||||
border: none; | |||||
} | |||||
.try { | |||||
position: absolute; | |||||
top: 38rpx; | |||||
right: 0; | |||||
font-size: 28rpx; | |||||
} |
@@ -22,6 +22,24 @@ Page({ | |||||
*/ | */ | ||||
onReady: function () { | onReady: function () { | ||||
}, | |||||
onLoad: function (options) { | |||||
wx.showLoading({ | |||||
title: '加载中', | |||||
}) | |||||
var scene = decodeURIComponent(options.scene); | |||||
var that = this; | |||||
if (app.globalData.openId && app.globalData.openId != null) { | |||||
} else { | |||||
// 由于是网络请求,可能会在 Page.onLoad 之后才返回 | |||||
// 所以此处加入 callback 以防止这种情况 | |||||
app.openIdCallback = openId => { | |||||
console.log(openId); | |||||
} | |||||
setTimeout(function () { | |||||
wx.hideLoading() | |||||
}, 2200) | |||||
} | |||||
}, | }, | ||||
// 用户点击右上角分享 | // 用户点击右上角分享 | ||||
onShareAppMessage: function () { | onShareAppMessage: function () { | ||||