请求修改
This commit is contained in:
@@ -47,24 +47,24 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getData () {
|
getData () {
|
||||||
this.$api.get('http://autophp.wyk/api/index/index').then(res => {
|
this.$api.get(this.$api.phpURL + 'api/index/index').then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
prev_page () {
|
prev_page () {
|
||||||
this.$api.get('http://autophp.wyk/api/index/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'api/index/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
next_page () {
|
next_page () {
|
||||||
this.$api.get('http://autophp.wyk/api/index/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'api/index/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleCurrentChange: function (currentPage) {
|
handleCurrentChange: function (currentPage) {
|
||||||
this.pageNum = currentPage
|
this.pageNum = currentPage
|
||||||
this.$api.get('http://autophp.wyk/api/index/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'api/index/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick (row) {
|
handleClick (row) {
|
||||||
this.$api.post('http://autophp.wyk/order/CashOutAdmin/getOneInfo', {id: row.id}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/CashOutAdmin/getOneInfo', {id: row.id}).then(res => {
|
||||||
this.form = res.data
|
this.form = res.data
|
||||||
})
|
})
|
||||||
this.dialogFormVisible = true
|
this.dialogFormVisible = true
|
||||||
@@ -112,24 +112,24 @@ export default {
|
|||||||
return ''
|
return ''
|
||||||
},
|
},
|
||||||
getData () {
|
getData () {
|
||||||
this.$api.get('http://autophp.wyk/order/CashOutAdmin/getData').then(res => {
|
this.$api.get(this.$api.phpURL + 'order/CashOutAdmin/getData').then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
prev_page () {
|
prev_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
next_page () {
|
next_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleCurrentChange: function (currentPage) {
|
handleCurrentChange: function (currentPage) {
|
||||||
this.pageNum = currentPage
|
this.pageNum = currentPage
|
||||||
this.$api.get('http://autophp.wyk/order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/CashOutAdmin/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -138,13 +138,13 @@ export default {
|
|||||||
this.$message.error('请填写备注')
|
this.$message.error('请填写备注')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
this.$api.post('http://autophp.wyk/order/CashOutAdmin/handle', {info}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/CashOutAdmin/handle', {info}).then(res => {
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
this.form.status = this.dealStatus(this.form.status)
|
this.form.status = this.dealStatus(this.form.status)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
search () {
|
search () {
|
||||||
this.$api.post('http://autophp.wyk/order/CashOutAdmin/search', {username: this.search_info}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/CashOutAdmin/search', {username: this.search_info}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -101,29 +101,29 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getData () {
|
getData () {
|
||||||
this.$api.get('http://autophp.wyk/order/IncomeCheck/getList').then(res => {
|
this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList').then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
prev_page () {
|
prev_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
next_page () {
|
next_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleCurrentChange: function (currentPage) {
|
handleCurrentChange: function (currentPage) {
|
||||||
this.pageNum = currentPage
|
this.pageNum = currentPage
|
||||||
this.$api.get('http://autophp.wyk/order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
search () {
|
search () {
|
||||||
this.$api.post('http://autophp.wyk/order/IncomeCheck/search', {time: this.timeSearh}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/IncomeCheck/search', {time: this.timeSearh}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = 0
|
this.count = 0
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ export default {
|
|||||||
this.searchModel.PackageId = this.searchModel.pModel[1]
|
this.searchModel.PackageId = this.searchModel.pModel[1]
|
||||||
}
|
}
|
||||||
this.searchModel.OrderTypes = this.searchModel.OrderTypes.toString()
|
this.searchModel.OrderTypes = this.searchModel.OrderTypes.toString()
|
||||||
this.$api.get('http://autophp.wyk/order/failed/getFailedList', this.searchModel).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/failed/getFailedList', this.searchModel).then(res => {
|
||||||
this.retData = res
|
this.retData = res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick (row) {
|
handleClick (row) {
|
||||||
this.$api.get('http://autophp.wyk/order/TbRefund/getOneInfo', {id: row.Id}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/TbRefund/getOneInfo', {id: row.Id}).then(res => {
|
||||||
this.form = res.data
|
this.form = res.data
|
||||||
})
|
})
|
||||||
this.$confirm('此操作只可进行一次, 是否继续?', '提示', {
|
this.$confirm('此操作只可进行一次, 是否继续?', '提示', {
|
||||||
@@ -78,7 +78,7 @@ export default {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$api.post('http://autophp.wyk/order/TbRefund/handle', {row}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/TbRefund/handle', {row}).then(res => {
|
||||||
if (res.balance) {
|
if (res.balance) {
|
||||||
row.f_balance = res.balance
|
row.f_balance = res.balance
|
||||||
}
|
}
|
||||||
@@ -92,35 +92,35 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getData () {
|
getData () {
|
||||||
this.$api.get('http://autophp.wyk/order/TbRefund/refundList').then(res => {
|
this.$api.get(this.$api.phpURL + 'order/TbRefund/refundList').then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
prev_page () {
|
prev_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
next_page () {
|
next_page () {
|
||||||
this.$api.get('http://autophp.wyk/order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleCurrentChange: function (currentPage) {
|
handleCurrentChange: function (currentPage) {
|
||||||
this.pageNum = currentPage
|
this.pageNum = currentPage
|
||||||
this.$api.get('http://autophp.wyk/order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
this.$api.get(this.$api.phpURL + 'order/TbRefund/pageList', {page: this.pageNum}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
search () {
|
search () {
|
||||||
this.$api.post('http://autophp.wyk/order/TbRefund/search', {Phone: this.search_info}).then(res => {
|
this.$api.post(this.$api.phpURL + 'order/TbRefund/search', {Phone: this.search_info}).then(res => {
|
||||||
this.tableData = res.data
|
this.tableData = res.data
|
||||||
this.count = parseInt(res.count)
|
this.count = parseInt(res.count)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
submit (info) {
|
submit (info) {
|
||||||
this.$api.post('http://autophp.wyk/order/TbRefund/handle', {info}).then(res => {})
|
this.$api.post(this.$api.phpURL + 'order/TbRefund/handle', {info}).then(res => {})
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ export default {
|
|||||||
let user_info = this.$local.getUserByCache().Manager.RealName
|
let user_info = this.$local.getUserByCache().Manager.RealName
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
if (userId) {
|
if (userId) {
|
||||||
this.$api.post('http://autophp.wyk/logs/index/clickInfo', {
|
this.$api.post(this.$api.phpURL + 'logs/index/clickInfo', {
|
||||||
user: user_info,
|
user: user_info,
|
||||||
operation: '点击客户信息产品账号',
|
operation: '点击客户信息产品账号',
|
||||||
record: '查看该客户的产品信息',
|
record: '查看该客户的产品信息',
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ export default {
|
|||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
let user_info = this.$local.getUserByCache().Manager.RealName
|
let user_info = this.$local.getUserByCache().Manager.RealName
|
||||||
this.$api.post('http://autophp.wyk/logs/index/clickVipInfo', {
|
this.$api.post(this.$api.phpURL + 'logs/index/clickVipInfo', {
|
||||||
user: user_info,
|
user: user_info,
|
||||||
operation: '点击客户管理',
|
operation: '点击客户管理',
|
||||||
record: '查询客户信息列表'
|
record: '查询客户信息列表'
|
||||||
@@ -315,7 +315,7 @@ export default {
|
|||||||
showHandle (r) {
|
showHandle (r) {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
let user_info = this.$local.getUserByCache().Manager.RealName
|
let user_info = this.$local.getUserByCache().Manager.RealName
|
||||||
this.$api.post('http://autophp.wyk/logs/index/hoveInfo', {
|
this.$api.post(this.$api.phpURL + 'logs/index/hoveInfo', {
|
||||||
user: user_info,
|
user: user_info,
|
||||||
operation: '点击客户信息会员价',
|
operation: '点击客户信息会员价',
|
||||||
record: '查看会员的产品价格',
|
record: '查看会员的产品价格',
|
||||||
@@ -326,7 +326,7 @@ export default {
|
|||||||
this.$api.getDownloadFile('/baseinfo/v1/user/Export')
|
this.$api.getDownloadFile('/baseinfo/v1/user/Export')
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
let user_info = this.$local.getUserByCache().Manager.RealName
|
let user_info = this.$local.getUserByCache().Manager.RealName
|
||||||
this.$api.post('http://autophp.wyk/logs/index/export', {
|
this.$api.post(this.$api.phpURL + 'logs/index/export', {
|
||||||
user: user_info,
|
user: user_info,
|
||||||
operation: '点击导出所有客户信息',
|
operation: '点击导出所有客户信息',
|
||||||
record: '导出所有客户信息列表',
|
record: '导出所有客户信息列表',
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export default {
|
|||||||
if (this.current.UserId) {
|
if (this.current.UserId) {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
let user_info = this.$local.getUserByCache().Manager.RealName
|
let user_info = this.$local.getUserByCache().Manager.RealName
|
||||||
this.$api.post('http://autophp.wyk/logs/index/clickInfo', {
|
this.$api.post(this.$api.phpURL + 'logs/index/clickInfo', {
|
||||||
user: user_info,
|
user: user_info,
|
||||||
operation: '点击客户信息会员价',
|
operation: '点击客户信息会员价',
|
||||||
record: '查看会员的产品价格',
|
record: '查看会员的产品价格',
|
||||||
|
|||||||
@@ -1,116 +1,116 @@
|
|||||||
import axios from "axios";
|
import axios from 'axios'
|
||||||
import qs from 'qs';
|
import qs from 'qs'
|
||||||
import router from "../../router";
|
import router from '../../router'
|
||||||
import { Message } from "element-ui";
|
import { Message } from 'element-ui'
|
||||||
import saveAs from "./../lib/filesaver";
|
import saveAs from './../lib/filesaver'
|
||||||
import NProgress from 'nprogress';
|
import NProgress from 'nprogress'
|
||||||
import './../../../static/css/nprogress.css';
|
import './../../../static/css/nprogress.css'
|
||||||
|
|
||||||
var http = require("./httpurl");
|
var http = require('./httpurl')
|
||||||
function getUserToken(){
|
function getUserToken () {
|
||||||
var data = window.localStorage.getItem("etorcurrentuser");
|
var data = window.localStorage.getItem('etorcurrentuser')
|
||||||
if(data)
|
if (data) { return JSON.parse(data).Token }
|
||||||
return JSON.parse(data).Token;
|
return ''
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var bmsAxios = axios.create({
|
var bmsAxios = axios.create({
|
||||||
// timeout: 120000,
|
// timeout: 120000,
|
||||||
// withCredentials: true,
|
// withCredentials: true,
|
||||||
baseURL: http.baseURL,
|
baseURL: http.baseURL,
|
||||||
headers: {
|
headers: {
|
||||||
post: {
|
post: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
|
||||||
bmsAxios.interceptors.request.use(
|
bmsAxios.interceptors.request.use(
|
||||||
config => {
|
config => {
|
||||||
var data = "";
|
var data = ''
|
||||||
if (window.localStorage.getItem("etorcurrentuser")) {
|
if (window.localStorage.getItem('etorcurrentuser')) {
|
||||||
data = window.localStorage.getItem("etorcurrentuser");
|
data = window.localStorage.getItem('etorcurrentuser')
|
||||||
}
|
|
||||||
|
|
||||||
if (data == "") {
|
|
||||||
config.headers.token = "";
|
|
||||||
config.headers.sid = sid || 0;
|
|
||||||
} else {
|
|
||||||
config.headers.token = JSON.parse(data).Token;
|
|
||||||
//var TenantId = JSON.parse(data).Manager.TenantId;
|
|
||||||
//var OperaterID = JSON.parse(data).Manager.ID;
|
|
||||||
}
|
|
||||||
var sid = window.localStorage.getItem("sid");
|
|
||||||
config.headers.sid = sid || 0;
|
|
||||||
removeNullAndUndefinedProperty(config.data)//没用的参数不要传
|
|
||||||
removeNullAndUndefinedProperty(config.params)//没用的参数不要传
|
|
||||||
if (config.url != "Permission/AgainGetToken") {
|
|
||||||
window.localStorage.setItem(
|
|
||||||
"lastrequesttime",
|
|
||||||
JSON.stringify(Date.now())
|
|
||||||
); //记录用户最后请求时间
|
|
||||||
}
|
|
||||||
//debugger
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
if (data == '') {
|
||||||
|
config.headers.token = ''
|
||||||
|
// eslint-disable-next-line no-use-before-define
|
||||||
|
config.headers.sid = sid || 0
|
||||||
|
} else {
|
||||||
|
config.headers.token = JSON.parse(data).Token
|
||||||
|
// var TenantId = JSON.parse(data).Manager.TenantId;
|
||||||
|
// var OperaterID = JSON.parse(data).Manager.ID;
|
||||||
|
}
|
||||||
|
var sid = window.localStorage.getItem('sid')
|
||||||
|
config.headers.sid = sid || 0
|
||||||
|
removeNullAndUndefinedProperty(config.data)// 没用的参数不要传
|
||||||
|
removeNullAndUndefinedProperty(config.params)// 没用的参数不要传
|
||||||
|
if (config.url != 'Permission/AgainGetToken') {
|
||||||
|
window.localStorage.setItem(
|
||||||
|
'lastrequesttime',
|
||||||
|
JSON.stringify(Date.now())
|
||||||
|
) // 记录用户最后请求时间
|
||||||
|
}
|
||||||
|
// debugger
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
// 返回状态
|
// 返回状态
|
||||||
let onceMessage = false;
|
let onceMessage = false
|
||||||
bmsAxios.interceptors.response.use(
|
bmsAxios.interceptors.response.use(
|
||||||
res => {
|
res => {
|
||||||
return res;
|
return res
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
//有异常
|
// 有异常
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
switch (error.response.status) {
|
switch (error.response.status) {
|
||||||
case 401:
|
case 401:
|
||||||
if (onceMessage) return;
|
if (onceMessage) return
|
||||||
onceMessage = true;
|
onceMessage = true
|
||||||
// Message.error("信息过期,请重新登陆");
|
// Message.error("信息过期,请重新登陆");
|
||||||
router.replace({
|
router.replace({
|
||||||
path: "/login",
|
path: '/login',
|
||||||
query: {
|
query: {
|
||||||
redirect: router.currentRoute.fullPath
|
redirect: router.currentRoute.fullPath
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 204:
|
|
||||||
Message.error("暂无数据");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
break
|
||||||
return Promise.reject(error);
|
case 204:
|
||||||
|
Message.error('暂无数据')
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
export function get(url, config) {
|
return Promise.reject(error)
|
||||||
return new Promise((resolve, reject) => {
|
}
|
||||||
bmsAxios.get(url, {
|
)
|
||||||
params: config,
|
|
||||||
paramsSerializer: function (params) {
|
export function get (url, config) {
|
||||||
return qs.stringify(params, { arrayFormat: 'repeat' })
|
return new Promise((resolve, reject) => {
|
||||||
}
|
bmsAxios.get(url, {
|
||||||
}).then(
|
params: config,
|
||||||
response => {
|
paramsSerializer: function (params) {
|
||||||
if (response.data.Code == 10000) {
|
return qs.stringify(params, { arrayFormat: 'repeat' })
|
||||||
return resolve(response.data);
|
}
|
||||||
} else {
|
}).then(
|
||||||
Message.error(response.data.Message||"数据异常")
|
response => {
|
||||||
}
|
if (response.data.Code == 10000) {
|
||||||
},
|
return resolve(response.data)
|
||||||
err => {
|
} else {
|
||||||
reject(err);
|
Message.error(response.data.Message || '数据异常')
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
.catch(error => {
|
err => {
|
||||||
reject(error);
|
reject(err)
|
||||||
});
|
}
|
||||||
});
|
)
|
||||||
|
.catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function post (url, params) {
|
export function post (url, params) {
|
||||||
@@ -142,203 +142,207 @@ export function post (url, params) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function put(url, params) {
|
export function put (url, params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bmsAxios.put(url, params).then(
|
bmsAxios.put(url, params).then(
|
||||||
response => {
|
response => {
|
||||||
resolve(response.data);
|
resolve(response.data)
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
reject(err);
|
reject(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
export function del(url, config) {
|
export function del (url, config) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bmsAxios.delete(url, { params: config }).then(
|
bmsAxios.delete(url, { params: config }).then(
|
||||||
response => {
|
response => {
|
||||||
resolve(response.data);
|
resolve(response.data)
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
reject(err);
|
reject(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject(error);
|
reject(error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
/** 使用 get HTTP Method 下载文件 */
|
/** 使用 get HTTP Method 下载文件 */
|
||||||
export function getDownloadFile(url, params, name) {
|
export function getDownloadFile (url, params, name) {
|
||||||
NProgress.start();
|
NProgress.start()
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
bmsAxios
|
bmsAxios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
params: params
|
params: params
|
||||||
},
|
|
||||||
responseType: "blob"
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
//确定最终文件名
|
|
||||||
const fileNameHeader = "x-suggested-filename";
|
|
||||||
let suggestedFileName = response.headers[fileNameHeader] || name;
|
|
||||||
if (suggestedFileName)
|
|
||||||
suggestedFileName = decodeURIComponent(suggestedFileName);
|
|
||||||
const effectiveFileName =
|
|
||||||
suggestedFileName === undefined ? "untitled" : suggestedFileName;
|
|
||||||
|
|
||||||
//长度为零给出提示,扔出错误
|
|
||||||
if (response.data.size == 0) throw new Error("文件长度为0");
|
|
||||||
|
|
||||||
//返回json,进行解析,获取Message,扔出错误
|
|
||||||
if (response.data.type == "application/json") {
|
|
||||||
let reader = new FileReader();
|
|
||||||
reader.onload = function (event) {
|
|
||||||
var message = JSON.parse(event.target.result);
|
|
||||||
reject(new Error(message.Message)); //拒绝
|
|
||||||
};
|
|
||||||
reader.readAsText(response.data);
|
|
||||||
} else {
|
|
||||||
saveAs(response.data, effectiveFileName);
|
|
||||||
resolve(); //解决
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(e => reject(e)).finally(function () {
|
|
||||||
NProgress.done();
|
|
||||||
}); //拒绝
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export function all(urlArr) { //并发请求
|
|
||||||
if (urlArr.length > 6) {
|
|
||||||
throw '当前不支持数量大于6个的并发请求';
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios.all(urlArr).then(
|
|
||||||
axios.spread((v0, v1, v2, v3, v4, v5) => {
|
|
||||||
let ret = {};
|
|
||||||
arguments.forEach((item, idx) => {
|
|
||||||
if (item)
|
|
||||||
ret[`ret${idx}`] = item
|
|
||||||
})
|
|
||||||
resolve(item);
|
|
||||||
}),
|
|
||||||
err => {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function axiosHttp(url, params, type = 'get') {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
axios[type](url, { params: params }).then(
|
|
||||||
response => {
|
|
||||||
resolve(response.data);
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
).catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function removeNullAndUndefinedProperty(model) {//移除对象中值为null、undefined的属性
|
|
||||||
if (model) {
|
|
||||||
for (let key in model) {
|
|
||||||
if (model[key] === null || typeof (model[key]) === 'undefined') {
|
|
||||||
delete model[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createFileInput(accept, onSelect) {
|
|
||||||
var lastFileInput = document.getElementById("f1_id");
|
|
||||||
if (lastFileInput != null) {
|
|
||||||
document.body.removeChild(lastFileInput);
|
|
||||||
}
|
|
||||||
lastFileInput = document.createElement("input");
|
|
||||||
lastFileInput.type = "file";
|
|
||||||
lastFileInput.name = "f1";
|
|
||||||
lastFileInput.id = "f1_id";
|
|
||||||
accept && (lastFileInput.accept = accept);
|
|
||||||
lastFileInput.setAttribute("style", "display:none;");
|
|
||||||
document.body.appendChild(lastFileInput);
|
|
||||||
lastFileInput.onchange = function (e) {
|
|
||||||
var f = lastFileInput.files[0];
|
|
||||||
onSelect && onSelect(f)
|
|
||||||
}
|
|
||||||
return lastFileInput;
|
|
||||||
}
|
|
||||||
export function getUuid(length) {
|
|
||||||
return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
|
|
||||||
}
|
|
||||||
|
|
||||||
//通过axios上传文件
|
|
||||||
export function upload(url, uconfig) {
|
|
||||||
var uconfig = uconfig || {};
|
|
||||||
var params = uconfig.params || {};
|
|
||||||
var accept = uconfig.accept || "image/gif, image/jpeg,image/jpg,image/png,image/*";
|
|
||||||
var onProgress = uconfig.onProgress || function () { };
|
|
||||||
var onStart = uconfig.onStart || function () { };
|
|
||||||
var uuid = uconfig.uuid || getUuid(10);
|
|
||||||
let config = {
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
"token":getUserToken(),
|
|
||||||
"sid":0
|
|
||||||
},
|
},
|
||||||
transformRequest: [function (data) {
|
responseType: 'blob'
|
||||||
return data
|
})
|
||||||
}],
|
.then(response => {
|
||||||
onUploadProgress: e => {
|
// 确定最终文件名
|
||||||
var completeProgress = ((e.loaded / e.total * 100) | 0);
|
const fileNameHeader = 'x-suggested-filename'
|
||||||
onProgress && onProgress(uuid, completeProgress);
|
let suggestedFileName = response.headers[fileNameHeader] || name
|
||||||
console.log("onUploadProgress:" + completeProgress);
|
if (suggestedFileName) { suggestedFileName = decodeURIComponent(suggestedFileName) }
|
||||||
}
|
const effectiveFileName =
|
||||||
}
|
suggestedFileName === undefined ? 'untitled' : suggestedFileName
|
||||||
let formData = new FormData();
|
|
||||||
for (let key of Object.keys(params)) {
|
|
||||||
formData.append(key, params[key] !== null ? params[key] : '')
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
var lastFileInput = createFileInput(accept, file => {
|
|
||||||
if (!file)
|
|
||||||
reject("没有选择文件")
|
|
||||||
formData.append(file.name, file);
|
|
||||||
onStart && onStart(uuid, file);
|
|
||||||
|
|
||||||
var uploadAxios = axios.create({
|
// 长度为零给出提示,扔出错误
|
||||||
// withCredentials: true,
|
// eslint-disable-next-line eqeqeq
|
||||||
baseURL: http.baseURL
|
if (response.data.size == 0) throw new Error('文件长度为0')
|
||||||
});
|
|
||||||
uploadAxios.post(url, formData, config).then(
|
// 返回json,进行解析,获取Message,扔出错误
|
||||||
response => { resolve(response.data) },
|
// eslint-disable-next-line eqeqeq
|
||||||
err => { reject(err) }
|
if (response.data.type == 'application/json') {
|
||||||
).catch(error => { reject(error) })
|
let reader = new FileReader()
|
||||||
|
reader.onload = function (event) {
|
||||||
|
var message = JSON.parse(event.target.result)
|
||||||
|
reject(new Error(message.Message)) // 拒绝
|
||||||
|
}
|
||||||
|
reader.readAsText(response.data)
|
||||||
|
} else {
|
||||||
|
saveAs(response.data, effectiveFileName)
|
||||||
|
resolve() // 解决
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => reject(e)).finally(function () {
|
||||||
|
NProgress.done()
|
||||||
|
}) // 拒绝
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function all (urlArr) { // 并发请求
|
||||||
|
if (urlArr.length > 6) {
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
|
throw '当前不支持数量大于6个的并发请求'
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios.all(urlArr).then(
|
||||||
|
axios.spread((v0, v1, v2, v3, v4, v5) => {
|
||||||
|
let ret = {}
|
||||||
|
arguments.forEach((item, idx) => {
|
||||||
|
if (item) { ret[`ret${idx}`] = item }
|
||||||
})
|
})
|
||||||
lastFileInput.click();
|
// eslint-disable-next-line no-undef
|
||||||
});
|
resolve(item)
|
||||||
|
}),
|
||||||
|
err => {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function axiosHttp (url, params, type = 'get') {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
axios[type](url, { params: params }).then(
|
||||||
|
response => {
|
||||||
|
resolve(response.data)
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function removeNullAndUndefinedProperty (model) { // 移除对象中值为null、undefined的属性
|
||||||
|
if (model) {
|
||||||
|
for (let key in model) {
|
||||||
|
if (model[key] === null || typeof (model[key]) === 'undefined') {
|
||||||
|
delete model[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFileInput (accept, onSelect) {
|
||||||
|
var lastFileInput = document.getElementById('f1_id')
|
||||||
|
if (lastFileInput != null) {
|
||||||
|
document.body.removeChild(lastFileInput)
|
||||||
|
}
|
||||||
|
lastFileInput = document.createElement('input')
|
||||||
|
lastFileInput.type = 'file'
|
||||||
|
lastFileInput.name = 'f1'
|
||||||
|
lastFileInput.id = 'f1_id'
|
||||||
|
accept && (lastFileInput.accept = accept)
|
||||||
|
lastFileInput.setAttribute('style', 'display:none;')
|
||||||
|
document.body.appendChild(lastFileInput)
|
||||||
|
lastFileInput.onchange = function (e) {
|
||||||
|
var f = lastFileInput.files[0]
|
||||||
|
onSelect && onSelect(f)
|
||||||
|
}
|
||||||
|
return lastFileInput
|
||||||
|
}
|
||||||
|
export function getUuid (length) {
|
||||||
|
return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过axios上传文件
|
||||||
|
export function upload (url, uconfig) {
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
|
var uconfig = uconfig || {}
|
||||||
|
var params = uconfig.params || {}
|
||||||
|
var accept = uconfig.accept || 'image/gif, image/jpeg,image/jpg,image/png,image/*'
|
||||||
|
var onProgress = uconfig.onProgress || function () { }
|
||||||
|
var onStart = uconfig.onStart || function () { }
|
||||||
|
var uuid = uconfig.uuid || getUuid(10)
|
||||||
|
let config = {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
'token': getUserToken(),
|
||||||
|
'sid': 0
|
||||||
|
},
|
||||||
|
transformRequest: [function (data) {
|
||||||
|
return data
|
||||||
|
}],
|
||||||
|
onUploadProgress: e => {
|
||||||
|
var completeProgress = ((e.loaded / e.total * 100) | 0)
|
||||||
|
onProgress && onProgress(uuid, completeProgress)
|
||||||
|
console.log('onUploadProgress:' + completeProgress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let formData = new FormData()
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
formData.append(key, params[key] !== null ? params[key] : '')
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var lastFileInput = createFileInput(accept, file => {
|
||||||
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
|
if (!file) { reject('没有选择文件') }
|
||||||
|
formData.append(file.name, file)
|
||||||
|
onStart && onStart(uuid, file)
|
||||||
|
|
||||||
|
var uploadAxios = axios.create({
|
||||||
|
// withCredentials: true,
|
||||||
|
baseURL: http.baseURL
|
||||||
|
})
|
||||||
|
uploadAxios.post(url, formData, config).then(
|
||||||
|
response => { resolve(response.data) },
|
||||||
|
err => { reject(err) }
|
||||||
|
).catch(error => { reject(error) })
|
||||||
|
})
|
||||||
|
lastFileInput.click()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
baseURL: http.baseURL,
|
baseURL: http.baseURL,
|
||||||
get,
|
phpURL: http.phpURL,
|
||||||
post,
|
get,
|
||||||
del,
|
post,
|
||||||
put,
|
del,
|
||||||
upload,//:httpfile.upload,
|
put,
|
||||||
getDownloadFile,
|
upload, // :httpfile.upload,
|
||||||
all(urlArr) { //并发请求
|
getDownloadFile,
|
||||||
return all(urlArr);
|
all (urlArr) { // 并发请求
|
||||||
}
|
return all(urlArr)
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,19 +6,27 @@ const devUrlNew = 'http://localhost:5000/api/'
|
|||||||
const testUrlNew = 'http://localhost:5000/api/'
|
const testUrlNew = 'http://localhost:5000/api/'
|
||||||
const prodUrlNew = 'http://www.juip.com/api/'// "http://api.yk.hncore.net/api/"/"http://hapi.hncore.net/api"
|
const prodUrlNew = 'http://www.juip.com/api/'// "http://api.yk.hncore.net/api/"/"http://hapi.hncore.net/api"
|
||||||
|
|
||||||
|
const devPhpUrlNew = 'http://autophp.wyk/'
|
||||||
|
const prodPhpUrlNew = 'http://php-api.juip.com/'
|
||||||
|
|
||||||
var baseURL = devUrlNew
|
var baseURL = devUrlNew
|
||||||
|
var phpURL = devPhpUrlNew
|
||||||
|
|
||||||
switch (process.env.NODE_ENV) {
|
switch (process.env.NODE_ENV) {
|
||||||
case 'development':
|
case 'development':
|
||||||
baseURL = devUrlNew
|
baseURL = devUrlNew
|
||||||
|
phpURL = devPhpUrlNew
|
||||||
break
|
break
|
||||||
case 'test':
|
case 'test':
|
||||||
baseURL = testUrlNew
|
baseURL = testUrlNew
|
||||||
|
phpURL = devPhpUrlNew
|
||||||
break
|
break
|
||||||
case 'production':
|
case 'production':
|
||||||
baseURL = prodUrlNew
|
baseURL = prodUrlNew
|
||||||
|
phpURL = prodPhpUrlNew
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
baseURL
|
baseURL,
|
||||||
|
phpURL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,127 +1,129 @@
|
|||||||
|
|
||||||
var _setCache=(str)=> {//1支持多用户登录同端,2处理个别浏览器缓存未清理干净
|
var _setCache = (str)=> {// 1支持多用户登录同端,2处理个别浏览器缓存未清理干净
|
||||||
let _managerId = 0
|
let _managerId = 0
|
||||||
_managerId=window.localStorage.getItem('unique_login');//唯一登录标识
|
_managerId = window.localStorage.getItem('unique_login')// 唯一登录标识
|
||||||
return `${str}_${_managerId}`
|
return `${str}_${_managerId}`
|
||||||
};
|
}
|
||||||
export default {
|
export default {
|
||||||
setUserCache(data){//设置登录用户信息缓存
|
setUserCache (data) {// 设置登录用户信息缓存
|
||||||
let _unique_login=data.Manager.ID+data.Manager.Logincode
|
// eslint-disable-next-line camelcase
|
||||||
let _cacheName=`etorcurrentuser_${_unique_login}`
|
let _unique_login = data.Manager.ID + data.Manager.Logincode
|
||||||
window.localStorage.setItem( _cacheName, JSON.stringify(data));
|
// eslint-disable-next-line camelcase
|
||||||
window.localStorage.setItem('unique_login', _unique_login);
|
let _cacheName = `etorcurrentuser_${_unique_login}`
|
||||||
window.localStorage.setItem("etorcurrentuser",JSON.stringify(data));//兼容未使用公共方法的页面
|
window.localStorage.setItem(_cacheName, JSON.stringify(data))
|
||||||
|
window.localStorage.setItem('unique_login', _unique_login)
|
||||||
|
window.localStorage.setItem('etorcurrentuser',JSON.stringify(data))// 兼容未使用公共方法的页面
|
||||||
},
|
},
|
||||||
getUserByCache: function () {//获取用户信息缓存
|
getUserByCache: function () {// 获取用户信息缓存
|
||||||
let _cacheName=_setCache("etorcurrentuser")
|
let _cacheName = _setCache('etorcurrentuser')
|
||||||
var str= window.localStorage.getItem(_cacheName);
|
var str = window.localStorage.getItem(_cacheName)
|
||||||
return JSON.parse(str);
|
return JSON.parse(str)
|
||||||
},
|
},
|
||||||
setMenus(data){
|
setMenus (data) {
|
||||||
let _cacheName="pmenus"
|
let _cacheName = 'pmenus'
|
||||||
window.localStorage.setItem( _cacheName, JSON.stringify(data));
|
window.localStorage.setItem(_cacheName, JSON.stringify(data))
|
||||||
},
|
},
|
||||||
getMenus(){
|
getMenus () {
|
||||||
let _cacheName="pmenus"
|
let _cacheName = 'pmenus'
|
||||||
var str= window.localStorage.getItem(_cacheName);
|
var str = window.localStorage.getItem(_cacheName)
|
||||||
return JSON.parse(str);
|
return JSON.parse(str)
|
||||||
},
|
},
|
||||||
isRoot: function () {//是否超级管理员
|
isRoot: function () {// 是否超级管理员
|
||||||
var currentUser=this.getUserByCache();
|
var currentUser = this.getUserByCache()
|
||||||
var isRoot=currentUser.Manager.IsRootUser;
|
var isRoot = currentUser.Manager.IsRootUser
|
||||||
return isRoot;
|
return isRoot
|
||||||
},
|
},
|
||||||
freshToken(type) {
|
freshToken (type) {
|
||||||
//刷新token
|
// 刷新token
|
||||||
// 0刷新过期时间,1刷新管理小区
|
// 0刷新过期时间,1刷新管理小区
|
||||||
let etorcurrentuser=this.getUserByCache()
|
let etorcurrentuser = this.getUserByCache()
|
||||||
newapi
|
newapi
|
||||||
.AgainGetToken({ Token: etorcurrentuser.Token, Type: type })
|
.AgainGetToken({ Token: etorcurrentuser.Token, Type: type })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.Code == 10000) {
|
if (res.Code == 10000) {
|
||||||
console.log(`刷新token成功`);
|
console.log(`刷新token成功`)
|
||||||
etorcurrentuser.Token = res.Data;
|
etorcurrentuser.Token = res.Data
|
||||||
this.setUserCache(etorcurrentuser)
|
this.setUserCache(etorcurrentuser)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(res => { });
|
.catch(res => { })
|
||||||
},
|
},
|
||||||
arr: [],
|
arr: [],
|
||||||
dbclick: function (tag) {
|
dbclick: function (tag) {
|
||||||
var img_obj = document.getElementsByClassName(tag);
|
var img_obj = document.getElementsByClassName(tag)
|
||||||
var body = document.getElementsByTagName("body")[0];
|
var body = document.getElementsByTagName('body')[0]
|
||||||
var obj_arr = new Array();
|
var obj_arr = new Array()
|
||||||
var img_arr = new Array();
|
var img_arr = new Array()
|
||||||
var nowindex = 0;
|
var nowindex = 0
|
||||||
for (var i = 0; i < img_obj.length; i++) {
|
for (var i = 0; i < img_obj.length; i++) {
|
||||||
obj_arr.push(img_obj[i]);
|
obj_arr.push(img_obj[i])
|
||||||
img_arr.push(img_obj[i].getAttribute("src"));
|
img_arr.push(img_obj[i].getAttribute('src'))
|
||||||
img_obj[i].ondblclick = function () {
|
img_obj[i].ondblclick = function () {
|
||||||
var nowurl = this.getAttribute("src");
|
var nowurl = this.getAttribute('src')
|
||||||
//获取到当前点击是第几个元素
|
// 获取到当前点击是第几个元素
|
||||||
for (var t = 0; t < img_arr.length; t++) {
|
for (var t = 0; t < img_arr.length; t++) {
|
||||||
if (img_arr[t] == nowurl) nowindex = t;
|
if (img_arr[t] == nowurl) nowindex = t
|
||||||
}
|
}
|
||||||
var cover_div = document.createElement("div");
|
var cover_div = document.createElement('div')
|
||||||
var center_div = document.createElement("div");
|
var center_div = document.createElement('div')
|
||||||
var img_box = document.createElement("div");
|
var img_box = document.createElement('div')
|
||||||
var leftspan = document.createElement("span");
|
var leftspan = document.createElement('span')
|
||||||
var rightspan = document.createElement("span");
|
var rightspan = document.createElement('span')
|
||||||
|
|
||||||
cover_div.className = "cover-div";
|
cover_div.className = 'cover-div'
|
||||||
center_div.className = "center-div";
|
center_div.className = 'center-div'
|
||||||
img_box.className = "readimg_box";
|
img_box.className = 'readimg_box'
|
||||||
leftspan.className = "leftspan";
|
leftspan.className = 'leftspan'
|
||||||
rightspan.className = "rightspan";
|
rightspan.className = 'rightspan'
|
||||||
|
|
||||||
center_div.appendChild(img_box);
|
center_div.appendChild(img_box)
|
||||||
body.appendChild(cover_div);
|
body.appendChild(cover_div)
|
||||||
body.appendChild(center_div);
|
body.appendChild(center_div)
|
||||||
body.appendChild(leftspan);
|
body.appendChild(leftspan)
|
||||||
body.appendChild(rightspan);
|
body.appendChild(rightspan)
|
||||||
//外层div点击的时候,删除
|
// 外层div点击的时候,删除
|
||||||
cover_div.onclick = function () {
|
cover_div.onclick = function () {
|
||||||
body.removeChild(cover_div);
|
body.removeChild(cover_div)
|
||||||
body.removeChild(leftspan);
|
body.removeChild(leftspan)
|
||||||
body.removeChild(rightspan);
|
body.removeChild(rightspan)
|
||||||
body.removeChild(center_div);
|
body.removeChild(center_div)
|
||||||
center_div.removeChild(img_box);
|
center_div.removeChild(img_box)
|
||||||
};
|
};
|
||||||
//添加图片
|
// 添加图片
|
||||||
|
|
||||||
for (var n = 0; n < img_arr.length; n++) {
|
for (var n = 0; n < img_arr.length; n++) {
|
||||||
var oimg = document.createElement("img");
|
var oimg = document.createElement('img')
|
||||||
oimg.className = "img_cover";
|
oimg.className = 'img_cover'
|
||||||
oimg.src = img_arr[n];
|
oimg.src = img_arr[n]
|
||||||
img_box.appendChild(oimg);
|
img_box.appendChild(oimg)
|
||||||
}
|
}
|
||||||
img_box.style.marginLeft = -nowindex * 500 + "px";
|
img_box.style.marginLeft = -nowindex * 500 + 'px'
|
||||||
rightspan.onclick = function () {
|
rightspan.onclick = function () {
|
||||||
nowindex++;
|
nowindex++
|
||||||
if (nowindex >= img_arr.length - 1) {
|
if (nowindex >= img_arr.length - 1) {
|
||||||
nowindex = img_arr.length - 1;
|
nowindex = img_arr.length - 1
|
||||||
}
|
}
|
||||||
img_box.style.marginLeft = -nowindex * 500 + "px";
|
img_box.style.marginLeft = -nowindex * 500 + 'px'
|
||||||
};
|
};
|
||||||
leftspan.onclick = function () {
|
leftspan.onclick = function () {
|
||||||
//console.log(img_arr.length - 1);
|
// console.log(img_arr.length - 1);
|
||||||
//console.log(nowindex);
|
// console.log(nowindex);
|
||||||
nowindex--;
|
nowindex--
|
||||||
if (nowindex <= 0) {
|
if (nowindex <= 0) {
|
||||||
nowindex = 0;
|
nowindex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
img_box.style.marginLeft = -nowindex * 500 + "px";
|
img_box.style.marginLeft = -nowindex * 500 + 'px'
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uploadimg: function () {
|
uploadimg: function () {
|
||||||
var input = document.createElement("input");
|
var input = document.createElement('input')
|
||||||
input.setAttribute("type", "file");
|
input.setAttribute('type', 'file')
|
||||||
var event = document.createEvent("MouseEvents");
|
var event = document.createEvent('MouseEvents')
|
||||||
event.initMouseEvent(
|
event.initMouseEvent(
|
||||||
"click",
|
'click',
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
window,
|
window,
|
||||||
@@ -136,18 +138,18 @@ export default {
|
|||||||
false,
|
false,
|
||||||
0,
|
0,
|
||||||
null
|
null
|
||||||
);
|
)
|
||||||
input.dispatchEvent(event);
|
input.dispatchEvent(event)
|
||||||
// this.makebase64()
|
// this.makebase64()
|
||||||
var that = this;
|
var that = this
|
||||||
// console.log(that.makebase64)
|
// console.log(that.makebase64)
|
||||||
input.onchange = function (e) {
|
input.onchange = function (e) {
|
||||||
var f = input.files[0];
|
var f = input.files[0]
|
||||||
console.log("e");
|
console.log('e')
|
||||||
console.log(e);
|
console.log(e)
|
||||||
console.log("input.files");
|
console.log('input.files')
|
||||||
console.log(f.name);
|
console.log(f.name)
|
||||||
console.log(f.size / 1024);
|
console.log(f.size / 1024)
|
||||||
// if(f.name)
|
// if(f.name)
|
||||||
if (f.size / 1024 > 2048) {
|
if (f.size / 1024 > 2048) {
|
||||||
// alert('图片大小不能超过2m')
|
// alert('图片大小不能超过2m')
|
||||||
@@ -155,19 +157,19 @@ export default {
|
|||||||
// type: 'error',
|
// type: 'error',
|
||||||
// message: '图片大小不能超过2m'
|
// message: '图片大小不能超过2m'
|
||||||
// })
|
// })
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
var reader = new FileReader();
|
var reader = new FileReader()
|
||||||
console.log("reader1");
|
console.log('reader1')
|
||||||
console.log(reader);
|
console.log(reader)
|
||||||
reader.readAsDataURL(f);
|
reader.readAsDataURL(f)
|
||||||
console.log("reader");
|
console.log('reader')
|
||||||
console.log(reader);
|
console.log(reader)
|
||||||
reader.onloadend = function (e) {
|
reader.onloadend = function (e) {
|
||||||
e = window.event || e;
|
e = window.event || e
|
||||||
|
|
||||||
var imgbase = e.target.result;
|
var imgbase = e.target.result
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,23 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* @Descripttion: e
|
||||||
|
* @version: w
|
||||||
|
* @Author: kangkang
|
||||||
|
* @Date: 2020-09-30 21:48:44
|
||||||
|
* @LastEditors: kangkang
|
||||||
|
* @LastEditTime: 2020-10-24 15:30:56
|
||||||
|
*/
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state:{
|
state: {
|
||||||
userInfo:null,
|
userInfo: null,
|
||||||
currentNav:'首页',
|
currentNav: '首页',
|
||||||
menus:[],
|
menus: []
|
||||||
},
|
},
|
||||||
mutations:{
|
mutations: {
|
||||||
updateUserInfo:function(state, data) {
|
updateUserInfo: function (state, data) {
|
||||||
state.userInfo = data;
|
state.userInfo = data
|
||||||
},
|
},
|
||||||
setCurrentNav:function(state,data){
|
setCurrentNav: function (state, data) {
|
||||||
state.currentNav=data;
|
state.currentNav = data
|
||||||
},
|
},
|
||||||
setMnus:function(state,data){
|
setMnus: function (state, data) {
|
||||||
state.menus=data;
|
state.menus = data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user