Merge branch 'master' of https://git.ddmt.top/6666/456
This commit is contained in:
commit
9c572030ab
6
package-lock.json
generated
6
package-lock.json
generated
@ -11,6 +11,7 @@
|
|||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
"element-plus": "^2.7.0",
|
"element-plus": "^2.7.0",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
|
"vue-cookies": "^1.8.4",
|
||||||
"vue-router": "^4.3.2"
|
"vue-router": "^4.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -2160,6 +2161,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/vue-cookies": {
|
||||||
|
"version": "1.8.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-cookies/-/vue-cookies-1.8.4.tgz",
|
||||||
|
"integrity": "sha512-9zjvACKE4W0kEb8OQtXzpizKhf6zfFOG/Z1TEUjSJn4Z4rintuAHo8y/FpCUhTWHMmPe8E+Fko+/tiXVM+5jOw=="
|
||||||
|
},
|
||||||
"node_modules/vue-router": {
|
"node_modules/vue-router": {
|
||||||
"version": "4.3.2",
|
"version": "4.3.2",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.3.2.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.3.2.tgz",
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
"element-plus": "^2.7.0",
|
"element-plus": "^2.7.0",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
|
"vue-cookies": "^1.8.4",
|
||||||
"vue-router": "^4.3.2"
|
"vue-router": "^4.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -3,7 +3,10 @@ import './style.css'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './/router'
|
import router from './/router'
|
||||||
import 'element-plus/dist/index.css'
|
import 'element-plus/dist/index.css'
|
||||||
|
import VueCookies from "vue-cookies";
|
||||||
|
|
||||||
|
|
||||||
const app= createApp(App)
|
const app= createApp(App)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
app.use(VueCookies);
|
||||||
|
|||||||
115
src/sdk/phalapi/PhalApi.js
Normal file
115
src/sdk/phalapi/PhalApi.js
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
import './jquery.min.js';
|
||||||
|
/**
|
||||||
|
* PhalApi框架 JS请求SDK
|
||||||
|
*
|
||||||
|
* "猫了_个咪"提供,博客地址w-blog.cn
|
||||||
|
* 有好的意见或建议请联系我-><wenzhenxi@vip.qq.com> 2015-10-20
|
||||||
|
*
|
||||||
|
* 分为3种请求方式:get,post和get_jsonp
|
||||||
|
*
|
||||||
|
* 所有请求均统一传递4个参数值(请求地址,接口名称.请求参数GET传递拼接好的参数
|
||||||
|
* Post传递数组key-value值,回调函数)
|
||||||
|
*
|
||||||
|
* 统一使用方式如下
|
||||||
|
* var url = '';
|
||||||
|
* var api = '';
|
||||||
|
* var data = '';
|
||||||
|
* query_get(url, api, data, function(rs){
|
||||||
|
* //回调函数 rs为返回结果已经反json化
|
||||||
|
* if(rs.ret == 200){
|
||||||
|
* 成功处理
|
||||||
|
* }else{
|
||||||
|
* 失败处理
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
//-------------------------------配置项------------------------------------
|
||||||
|
var debug = true; //调试模式
|
||||||
|
//-------------------------------配置项------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将对象转换为url参数字符串
|
||||||
|
* @param {*} obj
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function objectToParams(obj) {
|
||||||
|
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通的post请求方法
|
||||||
|
**/
|
||||||
|
export function query_post(api_url, api_name, data, callback){
|
||||||
|
//拼接请求的URL地址
|
||||||
|
var fullapi = api_url + '?service=' + api_name;
|
||||||
|
//执行请求
|
||||||
|
$.ajax({
|
||||||
|
url : fullapi, //请求地址
|
||||||
|
method : 'POST', //请求方式
|
||||||
|
crossDomain: true,
|
||||||
|
data : data, //请求参数
|
||||||
|
complete : function(rs){
|
||||||
|
//反Json化
|
||||||
|
rs = JSON.parse(rs.response || rs.responseText);
|
||||||
|
//把返回结果返回到控制台(debug模式自动开启)
|
||||||
|
if(debug == true){
|
||||||
|
console.log(fullapi, 'back', rs);
|
||||||
|
}
|
||||||
|
//回调函数
|
||||||
|
callback(rs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通的get请求方法
|
||||||
|
**/
|
||||||
|
export function query_get(api_url, api_name, data, callback){
|
||||||
|
//拼接请求的URL地址
|
||||||
|
var fullapi = api_url + '?service=' + api_name + objectToParams(data);
|
||||||
|
//执行请求
|
||||||
|
$.ajax({
|
||||||
|
url : fullapi, //请求地址
|
||||||
|
method : 'GET', //请求方式
|
||||||
|
complete: function(rs){
|
||||||
|
//反Json化
|
||||||
|
rs = JSON.parse(rs.response || rs.responseText);
|
||||||
|
//把返回结果返回到控制台(debug模式自动开启)
|
||||||
|
if(debug == true){
|
||||||
|
console.log(fullapi, 'back', rs);
|
||||||
|
}
|
||||||
|
//回调函数
|
||||||
|
callback(rs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JsonP请求方法(用于跨域请求,只能进行get请求)
|
||||||
|
**/
|
||||||
|
export function query_jsonp(api_url, api_name, data, callback){
|
||||||
|
//拼接请求的URL地址(&callback=1是Phalapi默认使用JsonP格式)
|
||||||
|
var fullapi = api_url + '?service=' + api_name + '&callback=1' + data;
|
||||||
|
//执行请求
|
||||||
|
$.ajax({
|
||||||
|
type : "get",
|
||||||
|
async : false,
|
||||||
|
url : fullapi, //请求参数
|
||||||
|
dataType: "jsonp",
|
||||||
|
jsonp : "callback", //传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
|
||||||
|
success : function(rs){
|
||||||
|
//把返回结果返回到控制台(debug模式自动开启)
|
||||||
|
if(debug == true){
|
||||||
|
console.log(fullapi, 'back', rs);
|
||||||
|
}
|
||||||
|
//回调函数
|
||||||
|
callback(rs);
|
||||||
|
},
|
||||||
|
error : function(error){
|
||||||
|
alert('fail');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
4
src/sdk/phalapi/jquery.min.js
vendored
Normal file
4
src/sdk/phalapi/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -54,9 +54,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { userLogin } from "../api/login";
|
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import router from '../router'
|
import router from '../router'
|
||||||
|
import { query_post } from '../sdk/phalapi/PhalApi';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -69,7 +69,7 @@ export default {
|
|||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
code: "",
|
code: "",
|
||||||
account: "ddmt",
|
username: "ddmt",
|
||||||
password: "000000",
|
password: "000000",
|
||||||
scene: "1",
|
scene: "1",
|
||||||
terminal: "4",
|
terminal: "4",
|
||||||
@ -92,6 +92,15 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
if (this.$cookies.get('user') !== null){
|
||||||
|
ElMessage({
|
||||||
|
message: '已经登陆成功,正在跳转到首页...',
|
||||||
|
type: "info",
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$router.replace('/index');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
if (localStorage.getItem("news")) {
|
if (localStorage.getItem("news")) {
|
||||||
this.form = JSON.parse(localStorage.getItem("news"));
|
this.form = JSON.parse(localStorage.getItem("news"));
|
||||||
this.checked = true;
|
this.checked = true;
|
||||||
@ -103,18 +112,61 @@ export default {
|
|||||||
ElMessage.error("账号或密码不能为空");
|
ElMessage.error("账号或密码不能为空");
|
||||||
} else {
|
} else {
|
||||||
// this.$router.push('/index')
|
// this.$router.push('/index')
|
||||||
this.query.account = this.form.username;
|
this.query.username = this.form.username;
|
||||||
this.query.password = this.form.password;
|
this.query.password = this.form.password;
|
||||||
userLogin(this.query).then((response) => {
|
|
||||||
|
if (this.create) {
|
||||||
|
query_post('http://localhost:8018/', 'App.User.Ceate', this.query, (response)=>{
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
if(response.ret == 200){
|
||||||
|
if(response.data.code == 0){
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: response.msg,
|
message: response.data.msg,
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
|
// 注册成功后重定向到主页
|
||||||
|
this.$cookies.set('user', response.data.token, 60*60*72);
|
||||||
|
router.push('/index');
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: response.data.msg,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: response.msg,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
query_post('http://localhost:8018/', 'App.User.Login', this.query, (response)=>{
|
||||||
|
console.log(response);
|
||||||
|
if(response.ret == 200){
|
||||||
|
if(response.data.code == 0){
|
||||||
|
ElMessage({
|
||||||
|
message: response.data.msg,
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
this.$cookies.set('user', response.data.token, 60*60*72);
|
||||||
// 登录成功后重定向到主页
|
// 登录成功后重定向到主页
|
||||||
router.push('/index');
|
router.push('/index');
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: response.data.msg,
|
||||||
|
type: "error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: response.msg,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
remenber(data) {
|
remenber(data) {
|
||||||
this.checked = data;
|
this.checked = data;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user