You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
import request from '@/utils/request'
|
|
|
|
// api地址
|
|
const api = {
|
|
list: 'order.comment/list',
|
|
submit: 'order.comment/submit'
|
|
}
|
|
|
|
// 待评价订单商品列表
|
|
export const list = (orderId, param) => {
|
|
return request.get(api.list, { orderId, ...param })
|
|
}
|
|
|
|
// 创建商品评价
|
|
export const submit = (orderId, data) => {
|
|
return request.post(api.submit, { orderId, form: data })
|
|
}
|
|
|
|
// 获取默认随机图片
|
|
export const getDefaultImage = () => {
|
|
let myPix = new Array("../../../portal/images/180-180.jpg", "../../../portal/images/180-180-2.jpg", "../../../portal/images/180-180-3.jpg", "../../../portal/images/180-180-3.jpg")
|
|
let randomNum = Math.floor((Math.random() * myPix.length))
|
|
return myPix[randomNum]
|
|
}
|
|
|
|
// 倒计时
|
|
export const getDateTime = (value,status) => {
|
|
if (typeof value == "string") {
|
|
value = new Date(value.replace(/-/g, "/"));
|
|
}
|
|
let date = new Date(value);
|
|
let myDate = new Date();
|
|
let newDate = date.getTime() + (1000 * 60 * 30);
|
|
let nowDate = newDate - myDate.getTime();
|
|
let new_nowDate = parseInt(nowDate);
|
|
value = parseInt(new_nowDate / 1000 / 60);
|
|
if (status == "1") {
|
|
return value + '分';
|
|
}
|
|
return value = '--';
|
|
}
|
|
|
|
// 金额保留两位小数
|
|
export const formatAmount = (amount) => {
|
|
// 将金额保留两位小数
|
|
const formattedAmount = parseFloat(amount).toFixed(2);
|
|
|
|
// 添加千位英文逗号分隔符
|
|
const parts = formattedAmount.toString().split(".");
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
|
|
return parts.join(".");
|
|
}
|
|
|
|
export const getDateTerm = (value,status) => {
|
|
if (typeof value == "string") {
|
|
value = new Date(value.replace(/-/g, "/"));
|
|
}
|
|
let date = new Date(value);
|
|
let myDate = new Date();
|
|
let newDate = date.getTime() + (24 * 60 * 60 * 1000 * 7);
|
|
let nowDate = newDate - myDate.getTime();
|
|
let new_nowDate = parseInt(nowDate);
|
|
value = parseInt(new_nowDate / 1000 / 60 / 60 / 24);
|
|
if (status == "1" || status == "5") {
|
|
return value = '--';
|
|
} else {
|
|
if (value < 0) {
|
|
return value = '已过期';
|
|
}
|
|
return value + '天';
|
|
}
|
|
}
|