小程序 JM

// 本地
// 'https://ly.com/'
// 短信验证码参数:
let dataValue = { 'type': 1, mobile: '13615814562' };
dataValue = JSON.stringify(dataValue);
// console.log(RSA)
var rsa_public_key = APP.globalData.rsa_public_key
var encrypt_rsa = new RSA.RSAKey();
encrypt_rsa = RSA.KEYUTIL.getKey(rsa_public_key);
// console.log(encrypt_rsa)
let encStr = encrypt_rsa.encrypt(dataValue)
encStr = RSA.hex2b64(encStr);
// console.log(encStr)
var timestamp = Date.parse(new Date()) + '1';
// console.log(timestamp)
let params = [];
let randomKey;
params.push("data=" + encStr);
params.push("timestamp=" + timestamp);
let che = '';
for (let i = 0; i < params.length; i++) {
che += i < (params.length - 1) ? params[i] + '&' : params[i] + '&randomKey=';
}
let chedata = {
data: encStr,
sign: md5.hexMD5(che),
timestamp: timestamp
}
// console.log(chedata);
wx.request({
header: {
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
},
method: "POST",
url: 'https://cd.baiqiyilian.com/api/v1/user/sms',
data: chedata,
success: function (res) {
console.log(res.data.data)
if (res.data.data){
that.loginFn(res.data.data)
}
},
fail: function (res) {
console.log(res)
}
});
 
//---------------------------------------------------------------------------------------------------------------------------------------
loginFn:function(surecode){
// 登录参数:
let dataValue = { checkCode: surecode, userName: '13615814562', type: 2 };
dataValue = JSON.stringify(dataValue);
var rsa_public_key = APP.globalData.rsa_public_key
var encrypt_rsa = new RSA.RSAKey();
encrypt_rsa = RSA.KEYUTIL.getKey(rsa_public_key);
let encStr = encrypt_rsa.encrypt(dataValue)
encStr = RSA.hex2b64(encStr);
var timestamp = Date.parse(new Date()) + '1';
let params = [];
let randomKey;
params.push("data=" + encStr);
params.push("timestamp=" + timestamp);
let che='';
for (let i = 0; i < params.length;i++){
che += i < (params.length - 1) ? params[i] + '&' : params[i] +'&randomKey=';
}
// if(randomKey){
// che += randomKey;
// }
let chedata = {
data: encStr,
sign: md5.hexMD5(che),
timestamp: timestamp
}
wx.request({
header: {
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
},
method: "POST",
url: 'https://cd.baiqiyilian.com/api/v1/user/login',
data: chedata,
success: function (res) {
console.log(res.data.data)
},
fail:function(res){
console.log(res)
}
});
},
//----------------------------------------------------------------------------------------------------------------------
 
posted @ 2018-05-17 17:26  ThisCall  阅读(206)  评论(0编辑  收藏  举报