time和sign参数传递后台

time和sign参数

const server = '/dev/api'; //运行环境
import md5 from 'js-md5';
import $ from '../../../static/js/jquery.min';

const time = (Date.parse(new Date())) / 1000;
const key = "xxxxxxxxx_xxxxxx";
const SiginTime = time + key
//封装好的ajax
export function postAjax(token, Url, data, fn) {
    $.ajax({
        headers: {
            "Authorization": `Bearer ` + token,
            sign: md5(SiginTime.toLocaleLowerCase()),
            time: time
        },
        type: 'post',
        url: server + Url,
        data: data,
        xhrFields: {
            withCredentials: true // 这里设置了withCredentials
        },
        traditional: true,
        success: function(data) {
            return fn(data);
        },
        error: function(xhr, status, error) {}
    });
}

你可能感兴趣的:(time,sign,ajax,vue)