提交 e050f892 编写于 作者: huangwensu's avatar huangwensu

修改

上级 402a3136
import PicaH5Login from './src/agreement.vue';
import PicaH5Agreement from './src/agreement.vue';
PicaH5Login.install = function(Vue) {
Vue.component(PicaH5Login.name, PicaH5Login);
PicaH5Agreement.install = function(Vue) {
Vue.component(PicaH5Agreement.name, PicaH5Agreement);
};
export default PicaH5Login;
\ No newline at end of file
export default PicaH5Agreement;
\ No newline at end of file
{
"_args": [
[
"pica-h5-agreement@1.0.2",
"D:\\wsp\\积木-ssr\\pica-toy-brick"
]
"name": "pica-h5-agreement",
"version": "1.0.2",
"description": "vue call app component",
"author": "souse",
"private": false,
"main": "lib/index.js",
"files": [
"lib",
"src"
],
"_from": "pica-h5-agreement@1.0.2",
"_id": "pica-h5-agreement@1.0.2",
"_inBundle": false,
"_integrity": "sha512-IlXHRdJZ3bfQ41Ofw8rQiaZIdDJ+9czOs59mqmHSdZwLf41sxcAUnGrKSgNxUQCyZl3OAoPCnGlZlN5+l5SgJQ==",
"_location": "/pica-h5-agreement",
"_phantomChildren": {
"@babel/runtime": "7.5.5",
"@vant/icons": "1.1.7",
"@vue/babel-helper-vue-jsx-merge-props": "1.0.0"
"scripts": {
"prod": "rollup -c"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "pica-h5-agreement@1.0.2",
"name": "pica-h5-agreement",
"escapedName": "pica-h5-agreement",
"rawSpec": "1.0.2",
"saveSpec": null,
"fetchSpec": "1.0.2"
"repository": {
"type": "git",
"url": "git@192.168.110.53:com.pica.cloud.foundation.frontend/pica-h5-agreement.git"
},
"_requiredBy": [
"/"
"keywords": [
"rollup",
"components"
],
"_resolved": "http://192.168.110.93:4873/pica-h5-agreement/-/pica-h5-agreement-1.0.2.tgz",
"_spec": "1.0.2",
"_where": "D:\\wsp\\积木-ssr\\pica-toy-brick",
"author": {
"name": "pica"
},
"bundleDependencies": false,
"license": "MIT",
"bugs": {},
"dependencies": {
"axios": "^0.18.0",
"jsencrypt": "^3.0.0-rc.1",
"vant": "^1.4.2"
"rollup-plugin-url": "^3.0.0"
},
"peerDependencies": {
"vue": "^2.5.17"
},
"deprecated": false,
"description": "h5 login agreement component",
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
......@@ -52,12 +38,9 @@
"rollup": "^1.0.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-image": "^1.0.2",
"rollup-plugin-imagemin": "^0.4.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-terser": "^4.0.1",
"rollup-plugin-url": "^2.2.1",
"rollup-plugin-vue": "^5.0.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
......@@ -65,29 +48,5 @@
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"files": [
"lib",
"src",
"index.js"
],
"keywords": [
"rollup",
"components"
],
"license": "MIT",
"main": "lib/index.js",
"name": "pica-h5-agreement",
"peerDependencies": {
"vue": "^2.5.17"
},
"private": false,
"repository": {
"type": "git",
"url": "http://192.168.110.53/com.pica.cloud.foundation.frontend/pica-h5-agreement.git"
},
"scripts": {
"prod": "rollup -c"
},
"version": "1.0.2"
}
}
<template>
<div>协议</div>
<div>
<h1>title</h1>
</div>
</template>
<script>
export default {
data() {
},
created() {
},
methods: {
}
name: 'pica-h5-agreement'
}
</script>
\ No newline at end of file
</script>
import { isObj } from './util';
const defaultOptions = {
message: '',
duration: 1500
};
const parseOptions = message => (isObj(message) ? message : { message });
/**
* [Toast description]
* @param {Object} options [description]
*/
export function Toast(options = {}) {
const opts = Object.assign(defaultOptions, parseOptions(options));
const toast = ToastFn.createInstance(opts);
}
function ToastFn(options) {}
ToastFn.prototype.createInstance = function(options) {}
ToastFn.prototype.clear = function() {}
/* eslint-disable */
/**
* [isDef description]
* @param {[type]} value [description]
* @return {Boolean} [description]
*/
export function isDef(value) {
return value !== undefined && value !== null;
}
/**
* [preventDefault description]
* @param {[type]} event [description]
* @return {[type]} [description]
*/
export function preventDefault(event) {
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
event.preventDefault();
}
// event.stopPropagation();
}
/**
* [isObj description]
* @param {[type]} x [description]
* @return {Boolean} [description]
*/
export function isObj(x) {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
/**
* [isAndroid description]
* @return {Boolean} [description]
*/
export function isAndroid() {
return /android/.test(navigator.userAgent.toLowerCase());
}
/**
* [isIOS description]
* @return {Boolean} [description]
*/
export function isIOS() {
return /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
}
/**
* [getRootScrollTop description]
* @return {[type]} [description]
*/
export function getRootScrollTop() {
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
}
\ No newline at end of file
此差异已折叠。
import axios from 'axios';
import { Toast } from 'vant';
import { CryptoJS } from './aes'
import 'jsencrypt'
let pubKey = "";
// generate key
function getAesKey(len) {
len = len || 16;
var aesKey = "";
var strList = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var strLen = strList.length;
for(var i=0; i<len; i++){
aesKey += strList.charAt( Math.floor( Math.random()*strLen ) );
};
return aesKey;
}
// 加密传参,发送请求
function sendEncryptRequest(content, cb, config){
content = JSON.stringify(content); // 后端要求转 string
// debugger;
if(pubKey){ // pubKey获取过就不用再获取了
let params = formatContent(content, pubKey);
cb && cb(params);
}else{
handleGetPubKey(content, cb, config);
}
}
// 获取 RSA public key
function getPubKey(config) {
return axios({ ...config, url: '/account/cipher/key' });
};
// get public key
function handleGetPubKey(content, cb, config){
// debugger;
getPubKey(config).then(res => {
// console.log('>>>>>>>>>>>>>>>>>>>> publicKey: ', res);
if(res.status && res.status === 200) {
res = res.data;
}
// debugger;
if(res.code == '000000'){
pubKey = res.data;
if(cb){
let params = formatContent(content, pubKey);
cb && cb(params);
}
}else{
Toast({
message: (res && res.message) || '接口出错',
duration: 1500
});
}
})
}
// format account params
function formatContent(content, pubKey) { // obj为具体的json传参
let aesKey = getAesKey(16);
let params = {
key: '',
content: ''
};
// 开发阶段后端接口还没处理加密,先传 原始json数据 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 后端加密OK后 再用下面的注释代码
// params.content = content;
params.content = AesEncrypt(content, aesKey);
params.key = RsaEncrypt(aesKey, pubKey);
return params;
}
// AES encrypt
function AesEncrypt(content, aesKey) {
let sKey = CryptoJS.enc.Utf8.parse(aesKey);
let sContent = CryptoJS.enc.Utf8.parse(content);
let encrypted = CryptoJS.AES.encrypt(sContent, sKey, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
return encrypted.toString();
}
// RSA encrypt
function RsaEncrypt(aesKey, pubKey){
let _encrypt = new JSEncrypt();
let boss_public_key = pubKey;
_encrypt.setPublicKey(boss_public_key);
let encrypted = _encrypt.encrypt(aesKey);
return encrypted;
}
export {
getAesKey,
sendEncryptRequest,
handleGetPubKey,
formatContent,
AesEncrypt,
RsaEncrypt,
}
\ No newline at end of file
// 获取用户终端信息
function getTerminalType() {
let brow = "unknown";
// alert(navigator.userAgent);
if (navigator.userAgent.indexOf('iPad') > -1) {
// alert("iPad");
return brow = "iPad";
}
if (navigator.userAgent.indexOf('Android') > -1
|| navigator.userAgent.indexOf('Linux') > -1) {
// alert("Android");
return brow = "android";
}
if (navigator.userAgent.indexOf('iPhone') > -1
// || navigator.userAgent.indexOf('Mac') > -1
) {
// alert("iPhone");
return brow = "iPhone";
}
if (navigator.userAgent.indexOf('Trident') > -1) {
// alert("Trident");
return brow = "PC";
}
if (navigator.userAgent.indexOf('Presto') > -1) {
// alert("Presto");
return brow = "PC";
}
if (navigator.userAgent.indexOf('Chrome') > -1) {
// alert("Chrome");
return brow = "PC";
}
if (navigator.userAgent.indexOf('AppleWebKit') > -1) {
// alert("AppleWebKit");
return brow = "iPad";
}
if (navigator.userAgent.indexOf('Gecko') > -1
&& navigator.userAgent.indexOf('KHTML') == -1) {
// alert("Gecko");
return brow = "PC";
}
if (navigator.userAgent.indexOf("Mac OS X") > -1) {
// alert("ios");
return brow = "ios";
}
if (navigator.userAgent.indexOf('Safari') == -1) {
// alert("Safari");
return brow = "PC";
}
return brow;
};
// 获取用户系统信息start
function detectOS() {
let sUserAgent = navigator.userAgent;
let isWin = (navigator.platform == "Win32")
|| (navigator.platform == "Windows");
let isMac = (navigator.platform == "Mac68K")
|| (navigator.platform == "MacPPC")
|| (navigator.platform == "Macintosh")
|| (navigator.platform == "MacIntel");
if (isMac)
return "Mac";
let isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if (isUnix)
return "Unix";
let isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if (isLinux)
return "Linux";
let isIos = (sUserAgent.indexOf("Mac OS X") > -1);
if (isIos)
return "Mac";
if (isWin) {
let isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1
|| sUserAgent.indexOf("Windows XP") > -1;
if (isWinXP)
return "WinXP";
let isWinVista = sUserAgent.indexOf("Windows NT 6.0") > -1
|| sUserAgent.indexOf("Windows Vista") > -1;
if (isWinVista)
return "WinVista";
let isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1
|| sUserAgent.indexOf("Windows 7") > -1;
if (isWin7)
return "Win7";
let isWin8_1 = sUserAgent.indexOf("Windows NT 6.2") > -1
|| sUserAgent.indexOf("Windows 8") > -1;
let isWin8_2 = sUserAgent.indexOf("Windows NT 6.3") > -1
|| sUserAgent.indexOf("Windows 8.1") > -1;
if (isWin8_1 || isWin8_2)
return "Win8";
let isWin10_1 = sUserAgent.indexOf("Windows NT 6.4") > -1
|| sUserAgent.indexOf("Windows 10") > -1;
let isWin10_2 = sUserAgent.indexOf("Windows NT 10.0") > -1
|| sUserAgent.indexOf("Windows 10") > -1;
if (isWin10_1 || isWin10_2)
return "Win10";
}
return "other";
};
export {
getTerminalType,
detectOS,
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册