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