Feat:寻看点和抽奖
This commit is contained in:
+45
-4
@@ -85,6 +85,47 @@ export function formatDateTime(time, format) {
|
||||
});
|
||||
}
|
||||
|
||||
export function timeNow(updateTime) {
|
||||
if (updateTime === null) {
|
||||
return ''
|
||||
}
|
||||
let now = new Date().getTime()
|
||||
let second = Math.floor((now - updateTime) / (1000))
|
||||
let minute = Math.floor(second / 60)
|
||||
let hour = Math.floor(minute / 60)
|
||||
let day = Math.floor(hour / 24)
|
||||
let month = Math.floor(day / 31)
|
||||
let year = Math.floor(month / 12)
|
||||
|
||||
console.log(hour);
|
||||
console.log(minute);
|
||||
if (year > 0) {
|
||||
return year + '年前'
|
||||
} else if (month > 0) {
|
||||
return month + '月前'
|
||||
} else if (day > 0) {
|
||||
let ret = day + '天前'
|
||||
if (day >= 7 && day < 14) {
|
||||
ret = '1周前'
|
||||
} else if (day >= 14 && day < 21) {
|
||||
ret = '2周前'
|
||||
} else if (day >= 21 && day < 28) {
|
||||
ret = '3周前'
|
||||
} else if (day >= 28 && day < 31) {
|
||||
ret = '4周前'
|
||||
}
|
||||
return ret
|
||||
} else if (hour > 0) {
|
||||
return hour + '小时前'
|
||||
} else if (minute > 0) {
|
||||
return minute + '分钟前'
|
||||
} else if (second > 0) {
|
||||
return second + '秒前'
|
||||
} else {
|
||||
return '刚刚'
|
||||
}
|
||||
}
|
||||
|
||||
export function diffDay(start, end) {
|
||||
var dateBegin = new Date(start.replace(/-/g, "/"));
|
||||
var dateEnd = new Date(end.replace(/-/g, "/"));
|
||||
@@ -426,7 +467,7 @@ export const handleGetUserInfo = () => {
|
||||
}
|
||||
|
||||
if (url == '/pages/home/index' || url == '/pages/shop/GoodsClass/index' || url ==
|
||||
'/pages/shop/ShoppingCart/index' || url == '/pages/user/User/index') {
|
||||
'/pages/cart' || url == '/pages/user/User/index') {
|
||||
switchTab({
|
||||
path: `${url}`,
|
||||
query
|
||||
@@ -559,7 +600,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
})
|
||||
// if (isAuth) {
|
||||
// // 有token
|
||||
// if (path == '/pages/home/index' || path == '/pages/shop/GoodsClass/index' || path == '/pages/shop/ShoppingCart/index' || path == '/pages/user/User/index') {
|
||||
// if (path == '/pages/home/index' || path == '/pages/shop/GoodsClass/index' || path == '/pages/cart' || path == '/pages/user/User/index') {
|
||||
// // switchTab({
|
||||
// // path: parseUrl(location),
|
||||
// // })
|
||||
@@ -612,7 +653,7 @@ export async function routerPermissions(url, type) {
|
||||
login(loginInfo).then(res => {
|
||||
// 登录成功,跳转到需要跳转的页面
|
||||
store.commit("updateAuthorizationPage", false);
|
||||
if (path == '/pages/shop/ShoppingCart/index' || path == '/pages/user/User/index') {
|
||||
if (path == '/pages/cart' || path == '/pages/user/User/index') {
|
||||
return
|
||||
}
|
||||
if (type == 'reLaunch') {
|
||||
@@ -646,7 +687,7 @@ export async function routerPermissions(url, type) {
|
||||
})
|
||||
} else {
|
||||
// 跳转到登录页面或者授权页面
|
||||
// path == '/pages/shop/ShoppingCart/index' ||
|
||||
// path == '/pages/cart' ||
|
||||
if ( path == '/pages/user/User/index') {
|
||||
switchTab({
|
||||
path,
|
||||
|
||||
+17
-11
@@ -1,6 +1,6 @@
|
||||
import Fly from "flyio/dist/npm/wx";
|
||||
import { handleLoginFailure } from "@/utils";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
import {handleLoginFailure} from "@/utils";
|
||||
import {VUE_APP_API_URL} from "@/config";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
|
||||
const fly = new Fly()
|
||||
@@ -17,20 +17,20 @@ fly.interceptors.response.use(
|
||||
console.log('发送请求失败', error)
|
||||
console.log('————————')
|
||||
handleLoginFailure();
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
return Promise.reject({msg: "未登录", toLogin: true});
|
||||
}
|
||||
if (error.status == 401) {
|
||||
console.log('————————')
|
||||
console.log('登录失效 401', error)
|
||||
console.log('————————')
|
||||
handleLoginFailure();
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
return Promise.reject({msg: "未登录", toLogin: true});
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
const defaultOpt = { login: true };
|
||||
const defaultOpt = {login: true};
|
||||
|
||||
function baseRequest(options) {
|
||||
|
||||
@@ -45,7 +45,7 @@ function baseRequest(options) {
|
||||
}
|
||||
|
||||
// 结构请求需要的参数
|
||||
const { url, params, data, login, ...option } = options
|
||||
const {url, params, data, login, ...option} = options
|
||||
|
||||
// 发起请求
|
||||
return fly.request(url, params || data, {
|
||||
@@ -53,15 +53,21 @@ function baseRequest(options) {
|
||||
}).then(res => {
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200) {
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
return Promise.reject({msg: "请求失败", res, data});
|
||||
}
|
||||
if ([401, 403].indexOf(data.status) !== -1) {
|
||||
handleLoginFailure();
|
||||
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
|
||||
return Promise.reject({msg: res.data.msg, res, data, toLogin: true});
|
||||
} else if (data.status === 200) {
|
||||
return Promise.resolve(data, res);
|
||||
} else {
|
||||
return Promise.reject({ msg: res.data.msg, res, data });
|
||||
uni.showToast({
|
||||
title: res.data.msg,
|
||||
icon: 'none',
|
||||
success() {
|
||||
}
|
||||
})
|
||||
return Promise.reject({msg: res.data.msg, res, data});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -81,7 +87,7 @@ const request = ["post", "put", "patch"].reduce((request, method) => {
|
||||
*/
|
||||
request[method] = (url, data = {}, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, data, method }, defaultOpt, options)
|
||||
Object.assign({url, data, method}, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
return request;
|
||||
@@ -97,7 +103,7 @@ const request = ["post", "put", "patch"].reduce((request, method) => {
|
||||
*/
|
||||
request[method] = (url, params = {}, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, params, method }, defaultOpt, options)
|
||||
Object.assign({url, params, method}, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user