/// +---------------------------------------------------------------------- // | HTTP 全局监听口[监听远程执行之前] // +---------------------------------------------------------------------- // | Copyright (c) 2016-2017 ,Lioc All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: Mr Table // +---------------------------------------------------------------------- import store from "../../store"; import md5 from "../vendor/md5.js"; import global from "../../config/global.js"; import { v4 as uuidv4 } from "uuid"; class Before { app = null; http = null; constructor(http) { this.app = getApp(); } /** * [监听]和[拦截] */ create() { var salt = global.putoken; var app = getApp(); var post = {}; post['token'] = store.state.user != null ? store.state.user.token : ""; //设备号 post['deviceId'] = store.state.uuid; //设备类型 post["deviceType"] = app.$device.platform == 'ios' ? 2 : 1; //#ifdef APP-PLUS post["fromApp"] = "app"; //#endif //#ifndef APP-PLUS post["fromApp"] = "h5"; //#endif post["mobileType"] = app.$device.model + "(" + app.$device.system + ")"; //版本号 post["version"] = global.version; //内部版本号 post['appCode'] = global.app_code; //校验标码 post['noction'] = uuidv4(); //访问时间戳 post["timestamp"] = Date.parse(new Date()); var signAr = []; for(var i in post) { signAr.push(i + "=" + post[i]); } var signStr = md5(salt + signAr.join(',')); post['sign'] = signStr; for(var i in post) { this.setHeader(i,post[i]); } } } export default Before;