zoukankan      html  css  js  c++  java
  • 小程序 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)
    }
    });
    },
    //----------------------------------------------------------------------------------------------------------------------
     
  • 相关阅读:
    2017(秋)软工作业: (2)硬币游戏—— 代码分析与改进
    软工作业(1)课程学习热身
    用户体验分析:以 “师路南通网站” 为例
    用户体验分析: 以 “南通大学教务管理系统微信公众号” 为例
    软件工程第二次作业:硬币游戏—— 代码分析与改进
    自我介绍
    用户体验分析---以师路南通为例
    用户体验分析---七八点照相馆
    硬币游戏—— 代码分析与改进
    About me
  • 原文地址:https://www.cnblogs.com/dianzan/p/9052188.html
Copyright © 2011-2022 走看看