1234567891011121314151617181920212223242526272829303132 |
- import request from '@/utils/request'
- import md5 from 'js-md5'
- import {
- getUser
- } from '@/utils/auth'
- const version = '1.0'
- const secret = '017c0743819088468e590246464cc75f';
- export function postData(method, data) {
- let user = getUser();
- let uid = user.uid
- let token = user.token
- let role = user.roles&&user.roles[0]||''
- // 未登入
- if (method.split(".")[0] == 'Auth') {
- uid = '0'
- token = ''
- role = ''
- }else if( token == ''){
- return
- }
- let body = JSON.stringify(data);
- let mtime = parseInt(Date.now() / 1000);
- let sigureStr = "rental_" + version + token + body + method + mtime + secret
- let sign = md5(sigureStr)
- let url = `/rental/${method}?t=${mtime}&u=${uid}&v=${version}&s=${sign}`
- return request({
- url: url,
- method: 'post',
- data: body
- })
- }
|