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)
    }
    });
    },
    //----------------------------------------------------------------------------------------------------------------------
     
  • 相关阅读:
    熟悉常用的HDFS操作
    爬虫大作业-爬取B站弹幕
    数据结构化与保存
    使用正则表达式,取得点击次数,函数抽离
    爬取校园新闻首页的新闻
    网络爬虫基础练习
    综合练习:词频统计
    理解MapReduce
    熟悉常用的HBase操作
    熟悉常用的HDFS操作
  • 原文地址:https://www.cnblogs.com/dianzan/p/9052188.html
Copyright © 2011-2022 走看看