🔧 config: 修改配置

This commit is contained in:
wangsongsole 2024-04-21 13:56:53 +08:00
parent db06ad440d
commit 5be32eb31c
1 changed files with 88 additions and 88 deletions

176
api2_0.js
View File

@ -1,15 +1,15 @@
let baseurl = "http://pre.marketapi.1688sup.com"; let baseurl = "http://192.168.6.75"
let pathname = window.location.host; let pathname = window.location.host
function global_dev_fun(hots) { function global_dev_fun(hots) {
if (hots.includes("test")) { if (hots.includes("test")) {
baseurl = "http://192.168.6.75"; baseurl = "http://192.168.6.75"
return; return
} }
if (hots.includes("pre")) { if (hots.includes("pre")) {
baseurl = "http://pre.marketapi.1688sup.com"; baseurl = "http://pre.marketapi.1688sup.com"
return; return
} }
if ( if (
@ -18,31 +18,31 @@ function global_dev_fun(hots) {
hots.includes("86885") || hots.includes("86885") ||
hots.includes("22233") hots.includes("22233")
) { ) {
baseurl = "https://marketapi.1688sup.com"; baseurl = "https://marketapi.1688sup.com"
return; return
} }
} }
global_dev_fun(pathname); global_dev_fun(pathname)
//统一请求 //统一请求
axios.interceptors.request.use((config) => { axios.interceptors.request.use((config) => {
// config.headers.Version = 'v1.3.0'; // config.headers.Version = 'v1.3.0';
return config; return config
}); })
const req = { const req = {
//get请求 //get请求
axiosGet(url, params) { axiosGet(url, params) {
const obj = { method: "get", url: baseurl + url, params }; const obj = { method: "get", url: baseurl + url, params }
var result = axios(obj) var result = axios(obj)
.then(function (res) { .then(function (res) {
return res.data; return res.data
}) })
.catch(function (error) { .catch(function (error) {
return; return
}); })
return result; return result
}, },
//获取key列表 //获取key列表
@ -56,13 +56,13 @@ const req = {
} }
}) })
.then((res) => { .then((res) => {
return res; return res
}) })
.catch((error) => { .catch((error) => {
alert("服务器错误"); alert("服务器错误")
return "exception=" + error; return "exception=" + error
}); })
return result; return result
}, },
//post请求 //post请求
axiosPost(url, data) { axiosPost(url, data) {
@ -75,12 +75,12 @@ const req = {
} }
}) })
.then((res) => { .then((res) => {
return res.data; return res.data
}) })
.catch((error) => { .catch((error) => {
// return "exception=" + error // return "exception=" + error
}); })
return result; return result
}, },
//put请求 //put请求
axiosPut(url, data) { axiosPut(url, data) {
@ -93,65 +93,65 @@ const req = {
} }
}) })
.then((res) => { .then((res) => {
return res.data; return res.data
}) })
.catch((error) => { .catch((error) => {
alert("服务器错误"); alert("服务器错误")
return "exception=" + error; return "exception=" + error
}); })
return result; return result
}
} }
};
//图形验证码 //图形验证码
function captchaimg() { function captchaimg() {
let parmas = {}; let parmas = {}
let customsessionid = ""; let customsessionid = ""
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest()
xhr.open("GET", baseurl + "/auth/login/verify"); xhr.open("GET", baseurl + "/auth/login/verify")
// xhr.setRequestHeader('Version', 'v1.1.0'); // xhr.setRequestHeader('Version', 'v1.1.0');
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer"
xhr.onreadystatechange = function (response) { xhr.onreadystatechange = function (response) {
response.header = { response.header = {
Accept: "application/json", Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8" "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
};
var img = document.getElementById("captcha_img");
var byteArray = new Uint8Array(response.target.response);
var binary = "";
for (var i = 0; i < byteArray.byteLength; i++) {
binary += String.fromCharCode(byteArray[i]);
} }
let str = "data:image/png;base64," + window.btoa(binary); var img = document.getElementById("captcha_img")
img.src = str; var byteArray = new Uint8Array(response.target.response)
customsessionid = xhr.getResponseHeader("Unique-Str"); var binary = ""
sessionStorage.setItem("unique_str", customsessionid); for (var i = 0; i < byteArray.byteLength; i++) {
}; binary += String.fromCharCode(byteArray[i])
xhr.send(); }
let str = "data:image/png;base64," + window.btoa(binary)
img.src = str
customsessionid = xhr.getResponseHeader("Unique-Str")
sessionStorage.setItem("unique_str", customsessionid)
}
xhr.send()
} }
/*公共方法提取 */ /*公共方法提取 */
//!商品的各种异常状态。1是可以兑换不作提示 //!商品的各种异常状态。1是可以兑换不作提示
//!type:1 兑换码 2:立减金 3:红包 //!type:1 兑换码 2:立减金 3:红包
const product_status = (status, row) => { const product_status = (status, row) => {
const message = JSON.parse(sessionStorage.getItem("message")); const message = JSON.parse(sessionStorage.getItem("message"))
const messageCurrent = {}; const messageCurrent = {}
message.map((item) => { message.map((item) => {
if (item.type == row.type || item.type == 0) { if (item.type == row.type || item.type == 0) {
return (messageCurrent[item.message_type] = replaceVariables( return (messageCurrent[item.message_type] = replaceVariables(
row.type, row.type,
item, item,
row row
)); ))
}
})
return messageCurrent[status]
} }
});
return messageCurrent[status];
};
/* 替换变量 */ /* 替换变量 */
function replaceVariables(type, val, row) { function replaceVariables(type, val, row) {
let mes = ""; let mes = ""
let prompt = val.customize || val.default; let prompt = val.customize || val.default
switch (Number(type)) { switch (Number(type)) {
case 2: case 2:
mes = prompt mes = prompt
@ -164,22 +164,22 @@ function replaceVariables(type, val, row) {
row.entity.time_limit.effect_time.end_time row.entity.time_limit.effect_time.end_time
) )
.replace("${start_time}", row.entity.time_limit.receive_time.start_time) .replace("${start_time}", row.entity.time_limit.receive_time.start_time)
.replace("${end_time}", row.entity.time_limit.receive_time.end_time); .replace("${end_time}", row.entity.time_limit.receive_time.end_time)
break; break
case 3: case 3:
mes = prompt mes = prompt
.replace("${effect_time_start}", row.entity.begin_time) .replace("${effect_time_start}", row.entity.begin_time)
.replace("${effect_time_end}", row.entity.end_time); .replace("${effect_time_end}", row.entity.end_time)
break; break
default: default:
mes = prompt mes = prompt
.replace("${start_time}", row.begin_time) .replace("${start_time}", row.begin_time)
.replace("${end_time}", row.end_time) .replace("${end_time}", row.end_time)
.replace("${effect_time_start}", row.begin_time) .replace("${effect_time_start}", row.begin_time)
.replace("${effect_time_end}", row.end_time); .replace("${effect_time_end}", row.end_time)
break; break
} }
return mes; return mes
} }
/* 周天排序 */ /* 周天排序 */
@ -192,78 +192,78 @@ function sortWeeks(weeks) {
{ id: 5, name: "周五" }, { id: 5, name: "周五" },
{ id: 6, name: "周六" }, { id: 6, name: "周六" },
{ id: 7, name: "周日" } { id: 7, name: "周日" }
]; ]
var _weeks = weeks var _weeks = weeks
.map((item) => .map((item) =>
staticWeeks.filter((item1) => item1.name === item || item1.id == item) staticWeeks.filter((item1) => item1.name === item || item1.id == item)
) )
.flat(Infinity) .flat(Infinity)
.sort((a, b) => a.id - b.id); .sort((a, b) => a.id - b.id)
//将weeks清空并将排序好的值赋给weeks //将weeks清空并将排序好的值赋给weeks
const weeksData = []; const weeksData = []
if (isContinuityNum(_weeks.map((item) => item.id)) && _weeks.length > 1) { if (isContinuityNum(_weeks.map((item) => item.id)) && _weeks.length > 1) {
weeksData.push(`${_weeks[0].name}${_weeks.slice(-1)[0].name}`); weeksData.push(`${_weeks[0].name}${_weeks.slice(-1)[0].name}`)
} else { } else {
for (var i = 0; i < _weeks.length; i++) { for (var i = 0; i < _weeks.length; i++) {
weeksData.push(_weeks[i].name); weeksData.push(_weeks[i].name)
} }
} }
return weeksData; return weeksData
} }
//判断一串数字是否是连续的 //判断一串数字是否是连续的
function isContinuityNum(num) { function isContinuityNum(num) {
let array = []; let array = []
if (num instanceof Array) { if (num instanceof Array) {
array = [...num]; array = [...num]
} else { } else {
array = Array.from(num.toString()); //转换为数组 array = Array.from(num.toString()) //转换为数组
} }
var i = array[0]; var i = array[0]
var isContinuation = true; var isContinuation = true
for (var e in array) { for (var e in array) {
if (array[e] != i) { if (array[e] != i) {
isContinuation = false; isContinuation = false
break; break
} }
i++; i++
} }
return isContinuation; return isContinuation
} }
//判断是不是微信 //判断是不是微信
function isWx() { function isWx() {
var ua = window.navigator.userAgent.toLowerCase(); var ua = window.navigator.userAgent.toLowerCase()
if (ua.match(/MicroMessenger/i) == "micromessenger") { if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true; return true
} }
return false; return false
} }
//判断是不是钉钉 //判断是不是钉钉
function isAli() { function isAli() {
var ua = window.navigator.userAgent.toLowerCase(); var ua = window.navigator.userAgent.toLowerCase()
if (ua.match(/dingtalk/i) == "dingtalk") { if (ua.match(/dingtalk/i) == "dingtalk") {
return true; return true
} }
return false; return false
} }
//判断是不是微信小程序环境打开 //判断是不是微信小程序环境打开
function isWxminiprogram() { function isWxminiprogram() {
const ua = navigator.userAgent.toLowerCase(); const ua = navigator.userAgent.toLowerCase()
const isWeixin = ua.indexOf("micromessenger") != -1; const isWeixin = ua.indexOf("micromessenger") != -1
if (isWeixin) { if (isWeixin) {
if (window.__wxjs_environment == "miniprogram") { if (window.__wxjs_environment == "miniprogram") {
return true; return true
} else { } else {
return false; return false
} }
} else { } else {
return false; return false
} }
} }