Commit d32c1704 by zhangmeng

修复状态不对的bug

parent 51b5bd15
......@@ -9,9 +9,9 @@ import Vue from 'vue';
* @param {消息} msg
*/
export const log = (msg) => {
if (_isDev && console && console.log) {
console.log(msg)
}
if (_isDev && console && console.log) {
console.log(msg)
}
}
......@@ -20,12 +20,12 @@ export const log = (msg) => {
* @param {String/Number} num
*/
export const fillZero = (num) => {
num = num * 1;
if (num < 10) {
return '0' + num;
} else {
return num;
}
num = num * 1;
if (num < 10) {
return '0' + num;
} else {
return num;
}
}
/**
......@@ -34,65 +34,65 @@ export const fillZero = (num) => {
* @param {*转换的格式} type
*/
export const formateDateTimeByType = (date, type = 'yyyy-MM-dd-HH-mm-ss') => {
if (!date){return ''}
if (typeof date === 'number') {
date = new Date(date);
}
if (typeof date === 'string') {
return date
} else {
var year = type.indexOf('yyyy') >= 0 ? (fillZero(date.getFullYear())) : '';
var month = type.indexOf('MM') >= 0 ? ('-' + fillZero(date.getMonth() + 1)) : '';
var day = type.indexOf('dd') >= 0 ? ('-' + fillZero(date.getDate())+'') : '';
var hours = type.indexOf('HH') >= 0 ? (' ' + fillZero(date.getHours())) : '';
var min = type.indexOf('mm') >= 0 ? (':' + fillZero(date.getMinutes())) : '';
var sec = type.indexOf('ss') >= 0 ? (':' + fillZero(date.getSeconds())) : '';
// console.log(year+month+day+hours+min+sec);
return year + month + day + hours + min + sec;
}
if (!date) { return '' }
if (typeof date === 'number') {
date = new Date(date);
}
if (typeof date === 'string') {
return date
} else {
var year = type.indexOf('yyyy') >= 0 ? (fillZero(date.getFullYear())) : '';
var month = type.indexOf('MM') >= 0 ? ('-' + fillZero(date.getMonth() + 1)) : '';
var day = type.indexOf('dd') >= 0 ? ('-' + fillZero(date.getDate()) + '') : '';
var hours = type.indexOf('HH') >= 0 ? (' ' + fillZero(date.getHours())) : '';
var min = type.indexOf('mm') >= 0 ? (':' + fillZero(date.getMinutes())) : '';
var sec = type.indexOf('ss') >= 0 ? (':' + fillZero(date.getSeconds())) : '';
// console.log(year+month+day+hours+min+sec);
return year + month + day + hours + min + sec;
}
}
export const numberToChinese = (num) => {
var chnNumChar = {
:0,
:1,
:2,
:3,
:4,
:5,
:6,
:7,
:8,
:9,
:10
};
let result = '';
for(let i in chnNumChar) {
if (num === chnNumChar[i]) {
result = i
var chnNumChar = {
: 0,
: 1,
: 2,
: 3,
: 4,
: 5,
: 6,
: 7,
: 8,
: 9,
: 10
};
let result = '';
for (let i in chnNumChar) {
if (num === chnNumChar[i]) {
result = i
}
}
}
return result;
return result;
}
export const numberToWeekChinese = (num) => {
var chnNumChar = {
:0,
:1,
:2,
:3,
:4,
:5,
:6
};
let result = '--';
for(let i in chnNumChar) {
if (num === chnNumChar[i]) {
result = i
var chnNumChar = {
: 0,
: 1,
: 2,
: 3,
: 4,
: 5,
: 6
};
let result = '--';
for (let i in chnNumChar) {
if (num === chnNumChar[i]) {
result = i
}
}
}
return result;
return result;
}
......@@ -102,97 +102,118 @@ export const numberToWeekChinese = (num) => {
*/
export const resetParams = (obj) => {
for (let item in obj) {
if (item && obj[item]) {
switch (obj[item].constructor) {
case Array:
obj[item] = [];
break;
case String:
obj[item] = '';
break;
case Number:
obj[item] = 0;
break;
case Boolean:
obj[item] = false;
break;
default:
obj[item] = '';
break;
for (let item in obj) {
if (item && obj[item]) {
switch (obj[item].constructor) {
case Array:
obj[item] = [];
break;
case String:
obj[item] = '';
break;
case Number:
obj[item] = 0;
break;
case Boolean:
obj[item] = false;
break;
default:
obj[item] = '';
break;
}
}
}
}
}
}
// 交换数组元素
function swapItems(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr;
};
// 上移
export const upRecord = function(arr, $index) {
if($index == 0) {
return;
}
swapItems(arr, $index, $index - 1);
if ($index == 0) {
return;
}
swapItems(arr, $index, $index - 1);
};
// 下移
export const downRecord = function(arr, $index) {
if($index == arr.length -1) {
return;
}
swapItems(arr, $index, $index + 1);
if ($index == arr.length - 1) {
return;
}
swapItems(arr, $index, $index + 1);
};
//字符串判断是否为空
export const voidStr = function(str,msg) {
if (!str) {
Vue.prototype.$tips({type:'warning',message:msg || '内容填写不全'})
return true;
} else {
return false;
}
export const voidStr = function(str, msg) {
if (!str) {
Vue.prototype.$tips({ type: 'warning', message: msg || '内容填写不全' })
return true;
} else {
return false;
}
}
/**
* 频率控制 返回函数连续调用时,action 执行频率限定为 次 / delay
* @param delay {number} 延迟时间,单位毫秒
* @param action {function} 请求关联函数,实际应用需要调用的函数
* @return {function} 返回客户调用函数
*/
export const throttle = function(delay, action){
var last = 0;
return function(){
var curr = +new Date()
if (curr - last > delay){
action.apply(this, arguments)
last = curr
* 频率控制 返回函数连续调用时,action 执行频率限定为 次 / delay
* @param delay {number} 延迟时间,单位毫秒
* @param action {function} 请求关联函数,实际应用需要调用的函数
* @return {function} 返回客户调用函数
*/
export const throttle = function(delay, action) {
var last = 0;
return function() {
var curr = +new Date()
if (curr - last > delay) {
action.apply(this, arguments)
last = curr
}
}
}
}
/**
* 验证是否为网址
*/
export const checkUrl = function (urlString) {
if(urlString!=""){
var reg=/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
if(!reg.test(urlString)){
Vue.prototype.$tips({type:"warning",message:"网址不规范,示例:http://www.domain.com"});
return true;
export const checkUrl = function(urlString) {
if (urlString != "") {
var reg = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
if (!reg.test(urlString)) {
Vue.prototype.$tips({ type: "warning", message: "网址不规范,示例:http://www.domain.com" });
return true;
}
} else {
Vue.prototype.$tips({ type: "warning", message: "网址不规范,示例:http://www.domain.com" });
return true;
}
}else {
Vue.prototype.$tips({type:"warning",message:"网址不规范,示例:http://www.domain.com"});
return true;
}
return false;
return false;
}
// 对Date的扩展,将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
// 例子:
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
export const format = function(date, fmt) { //author: meizz
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ export default {
},
methods:{
filterAvatar(img) {
return img?img.replace(/^http/,'https'):this.defaultAvatar;
return img?img.replace(/^http(s)?/,'https'):this.defaultAvatar;
},
getSingleInfo() {
getMemberInfo({memberId:this.row.memberId}).then(res => {
......
......@@ -60,7 +60,7 @@
<script>
import { getPageCardsList, deleteProService } from '@/service/api/mallApi.js';
import updateCount from '../common/update-count';
import {formateDateTimeByType} from '@/utils/index.js';
import {formateDateTimeByType,format} from '@/utils/index.js';
export default {
name: 'coupon-list',
components: {
......@@ -141,10 +141,10 @@ export default {
dhzt_show_html = '<span class="dm-status--warning">未在兑换时间</span>';
dhzt_show = '未在兑换时间';
for(var k=0;k<item.exchangeTimeList.length;k++) {
var _o = item.exchangeTimeList[k] ;
var _o = item.exchangeTimeList[k] ;
var start = _o.exchangeTimeBeginNumber ;
var end = _o.exchangeTimeEndNumber ;
var _now = Date.now() ;
var _now = format(new Date(),'hhmm') ;
if(_now >= start && _now <= end) {
dhzt_show_html = '<span class="dm-status--primary">正常</span>';
dhzt_show = '正常';
......@@ -167,7 +167,8 @@ export default {
if(item.status==1) {
dhzt_show_html = '<span class="dm-status--info">已下架</span>';
dhzt_show = "已下架" ;
}
}
return {
text:dhzt_show,
html:dhzt_show_html
......
......@@ -234,6 +234,7 @@ export default {
})();
}
},
// 新增兑换时段-部分时段
addTimeRange() {
let length = this.timeRangeList.length;
......@@ -258,8 +259,6 @@ export default {
// 提交保存
submitService() {
console.log(this.form.cashCost, this.form.costValue)
if (this.form.costValue < this.form.cashCost) {
this.$tips({ type: 'warning', message: '现金费用不能大于礼品成本' });
return;
......@@ -268,6 +267,10 @@ export default {
this.$tips({ type: 'warning', message: '礼品主图不能为空' });
return;
}
if (this.form.changeType === 1 && !this.form.proReferId) {
this.$tips({ type: 'warning', message: '请选择优惠券' });
return;
}
let params = {
integralMallProId: this.form.integralMallProId || '',
proType: this.form.changeType === 1 ? 2 : 3, // 商品类型 1 优惠券,2礼品,3实物
......
......@@ -93,7 +93,7 @@
<script>
import { getPageGiftList, getCategoryList, deleteProService ,setHotStatusService} from '@/service/api/mallApi.js';
import updateCount from '../common/update-count';
import {formateDateTimeByType} from '@/utils/index.js';
import {formateDateTimeByType,format} from '@/utils/index.js';
export default {
name: 'gift-list',
components: {
......@@ -188,7 +188,7 @@ export default {
var _o = item.exchangeTimeList[k] ;
var start = _o.exchangeTimeBeginNumber ;
var end = _o.exchangeTimeEndNumber ;
var _now = Date.now() ;
var _now = format(new Date(),'hhmm') ;
if(_now >= start && _now <= end) {
dhzt_show_html = '<span class="dm-status--primary">正常</span>';
dhzt_show = '正常';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment