公寓详情加收藏和附近学校
This commit is contained in:
@@ -42,6 +42,9 @@ export default{
|
||||
},
|
||||
detailsDistance:(params={})=>{//详情页 - 距离学校距离
|
||||
return axios.get('/tenement/pc/api/details/distance',params)
|
||||
},
|
||||
apartmentCollection:(params={})=>{// 公寓列表 - 收藏
|
||||
return axios.get('/tenement/pc/api/user/apartmentCollection',params)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ axios.interceptors.request.use(
|
||||
if (config.url != "/tenement/pc/api/user/operation" && !noMask) showFullScreenLoading()
|
||||
// 开发时登录用的,可以直接替换小程序的 authorization
|
||||
// if (process.env.NODE_ENV == "development") config['headers']['authorization'] = "x2mmnl9grt51bpplj2k6ioiuummzhnw3"
|
||||
if (process.env.NODE_ENV == "development") config["headers"]["authorization"] = "gifqtoiomgb2efu7tcr16kcgs2"
|
||||
if (process.env.NODE_ENV == "development") config["headers"]["authorization"] = "mx25rp0q99x3sis8hidugttty80c5qum"
|
||||
|
||||
// 当 noMask == true 和 confing.method == 'get' 时,删除 config.params['noMask']
|
||||
if (noMask && config.method == "get") delete config.params["noMask"]
|
||||
|
||||
@@ -1,51 +1,80 @@
|
||||
|
||||
|
||||
function setSeoTitle(title) {
|
||||
document.title = '港校租房-' + title
|
||||
document.title = "港校租房-" + title
|
||||
}
|
||||
|
||||
// 跳转 url
|
||||
function redirectToExternalWebsite(url) {
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.target = '_blank';
|
||||
link.click();
|
||||
const link = document.createElement("a")
|
||||
link.href = url
|
||||
link.target = "_blank"
|
||||
link.click()
|
||||
}
|
||||
|
||||
// 跳转登录
|
||||
function goTologin() {
|
||||
let url = encodeURIComponent(location.href);
|
||||
redirectToExternalWebsite(`https://passport.gter.net/?referer=${url}`);
|
||||
let url = encodeURIComponent(location.href)
|
||||
redirectToExternalWebsite(`https://passport.gter.net/?referer=${url}`)
|
||||
}
|
||||
|
||||
// 复制方法
|
||||
function copyToClipboard(text) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const textareaEle = document.createElement("textarea");
|
||||
document.body.appendChild(textareaEle);
|
||||
const textareaEle = document.createElement("textarea")
|
||||
document.body.appendChild(textareaEle)
|
||||
// 2. 将需要复制的文本传入输入框, 并调用 select 方法, 选中输入框中文本
|
||||
textareaEle.value = text;
|
||||
textareaEle.select();
|
||||
textareaEle.readOnly = 'readOnly';
|
||||
textareaEle.value = text
|
||||
textareaEle.select()
|
||||
textareaEle.readOnly = "readOnly"
|
||||
// 3. 调用复制选中文本的方法
|
||||
document.execCommand('copy');
|
||||
document.execCommand("copy")
|
||||
// 4. 销毁输入框
|
||||
document.body.removeChild(textareaEle);
|
||||
document.body.removeChild(textareaEle)
|
||||
resolve()
|
||||
// navigator.clipboard.writeText(text).then(() => {
|
||||
// resolve()
|
||||
// }).catch((err) => {
|
||||
// reject()
|
||||
// });
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// 转换 秒数
|
||||
function secondsToHoursMinutes(seconds, type) {
|
||||
// 计算小时数
|
||||
const hours = Math.floor(seconds / 3600)
|
||||
// 计算剩余的秒数
|
||||
const remainingSecondsAfterHours = seconds % 3600
|
||||
// 计算分钟数
|
||||
const minutes = Math.floor(remainingSecondsAfterHours / 60)
|
||||
// 计算剩余的秒数
|
||||
const remainingSeconds = remainingSecondsAfterHours % 60
|
||||
|
||||
let text = ""
|
||||
if (type == "chinese") {
|
||||
if (hours != 0) text += hours + "小时"
|
||||
if (minutes != 0) text += minutes + "分钟"
|
||||
if (remainingSeconds != 0 && minutes == 0) text += remainingSeconds + "秒"
|
||||
} else {
|
||||
if (hours != 0) text += hours + "h"
|
||||
if (minutes != 0) text += minutes + "min"
|
||||
if (remainingSeconds != 0 && minutes == 0) text += remainingSeconds + "s"
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
// 转换 米数
|
||||
function metersToKilometers(input, type) {
|
||||
let text = ""
|
||||
if (input >= 1000) text = (input / 1000).toFixed(1) + (type == "chinese" ? "公里" : "km")
|
||||
else text = input + (type == "chinese" ? "米" : "m")
|
||||
return text
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setSeoTitle,
|
||||
redirectToExternalWebsite,
|
||||
goTologin,
|
||||
copyToClipboard,
|
||||
}
|
||||
secondsToHoursMinutes,
|
||||
metersToKilometers,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user