hookehuyr

🐞 fix: 时间解析问题处理,把dayjs换成moment

1 <!-- 1 <!--
2 * @Date: 2022-09-20 15:39:37 2 * @Date: 2022-09-20 15:39:37
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-28 13:32:41 4 + * @LastEditTime: 2022-10-31 17:13:44
5 * @FilePath: /swx/src/components/activity-card.vue 5 * @FilePath: /swx/src/components/activity-card.vue
6 * @Description: 活动卡片组件 6 * @Description: 活动卡片组件
7 --> 7 -->
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
66 import { ref, defineProps, computed } from 'vue' 66 import { ref, defineProps, computed } from 'vue'
67 import icon_address from '@/images/icon/address@2x.png' 67 import icon_address from '@/images/icon/address@2x.png'
68 import Taro from '@tarojs/taro' 68 import Taro from '@tarojs/taro'
69 -import * as dayjs from 'dayjs' 69 +import moment from '@/utils/moment.min.js'
70 70
71 const props = defineProps({ 71 const props = defineProps({
72 data: Object, 72 data: Object,
...@@ -78,7 +78,7 @@ const props = defineProps({ ...@@ -78,7 +78,7 @@ const props = defineProps({
78 // }) 78 // })
79 79
80 const formatDate = (date) => { 80 const formatDate = (date) => {
81 - return dayjs(date).format('YYYY-MM-DD HH:mm') 81 + return moment(date).format('YYYY-MM-DD HH:mm')
82 } 82 }
83 83
84 const formatStatus = (item) => { 84 const formatStatus = (item) => {
...@@ -86,13 +86,13 @@ const formatStatus = (item) => { ...@@ -86,13 +86,13 @@ const formatStatus = (item) => {
86 return '已结束'; 86 return '已结束';
87 } else if (item?.status === 'disable') { 87 } else if (item?.status === 'disable') {
88 return '未发布'; 88 return '未发布';
89 - } else if (dayjs(item.server_time).isBefore(dayjs(item.reg_begin_time))) { 89 + } else if (moment(item.server_time).isBefore(moment(item.reg_begin_time))) {
90 return '报名未开始'; 90 return '报名未开始';
91 - } else if (dayjs(item.reg_begin_time).isBefore(dayjs(item.server_time)) && dayjs(item.server_time).isBefore(dayjs(item.reg_end_time))) { 91 + } else if (moment(item.reg_begin_time).isBefore(moment(item.server_time)) && moment(item.server_time).isBefore(moment(item.reg_end_time))) {
92 return '报名中'; 92 return '报名中';
93 - } else if (dayjs(item.reg_end_time).isBefore(dayjs(item.server_time)) && dayjs(item.server_time).isBefore(dayjs(item.activity_time))) { 93 + } else if (moment(item.reg_end_time).isBefore(moment(item.server_time)) && moment(item.server_time).isBefore(moment(item.activity_time))) {
94 return '报名结束'; 94 return '报名结束';
95 - } else if (dayjs(item.activity_time).isBefore(dayjs(item.server_time))) { 95 + } else if (moment(item.activity_time).isBefore(moment(item.server_time))) {
96 return '活动进行中'; 96 return '活动进行中';
97 } 97 }
98 } 98 }
......
1 <!-- 1 <!--
2 * @Date: 2022-09-26 14:36:57 2 * @Date: 2022-09-26 14:36:57
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-31 11:28:15 4 + * @LastEditTime: 2022-10-31 17:17:34
5 * @FilePath: /swx/src/pages/activityDetail/index.vue 5 * @FilePath: /swx/src/pages/activityDetail/index.vue
6 * @Description: 活动详情页 6 * @Description: 活动详情页
7 --> 7 -->
...@@ -150,7 +150,7 @@ import activityBar from '@/components/activity-bar.vue' ...@@ -150,7 +150,7 @@ import activityBar from '@/components/activity-bar.vue'
150 import Taro from '@tarojs/taro' 150 import Taro from '@tarojs/taro'
151 import PosterBuilder from '@/components/PosterBuilder/index.vue'; 151 import PosterBuilder from '@/components/PosterBuilder/index.vue';
152 import { ref, onMounted } from "vue"; 152 import { ref, onMounted } from "vue";
153 -import * as dayjs from 'dayjs' 153 +import moment from '@/utils/moment.min.js'
154 import { infoUserAPI } from '@/api/User/index'; 154 import { infoUserAPI } from '@/api/User/index';
155 import { qrCodeActivityAPI } from '@/api/Activity/index'; 155 import { qrCodeActivityAPI } from '@/api/Activity/index';
156 import icon_share from '@/images/icon/share.png' 156 import icon_share from '@/images/icon/share.png'
...@@ -167,7 +167,7 @@ onMounted(async () => { ...@@ -167,7 +167,7 @@ onMounted(async () => {
167 }) 167 })
168 168
169 const formatDate = (date) => { 169 const formatDate = (date) => {
170 - return dayjs(date).format('YYYY-MM-DD HH:mm') 170 + return moment(date).format('YYYY-MM-DD HH:mm')
171 } 171 }
172 172
173 const show_share = ref(false); 173 const show_share = ref(false);
......
1 <!-- 1 <!--
2 * @Date: 2022-09-21 16:04:10 2 * @Date: 2022-09-21 16:04:10
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-31 14:20:36 4 + * @LastEditTime: 2022-10-31 17:26:24
5 * @FilePath: /swx/src/pages/createActivity/index.vue 5 * @FilePath: /swx/src/pages/createActivity/index.vue
6 * @Description: 创建活动页面 6 * @Description: 创建活动页面
7 --> 7 -->
...@@ -277,10 +277,8 @@ import mixin from '@/utils/mixin'; ...@@ -277,10 +277,8 @@ import mixin from '@/utils/mixin';
277 import BASE_URL from '@/utils/config'; 277 import BASE_URL from '@/utils/config';
278 import Toast from '@/components/vant-weapp/toast/toast'; 278 import Toast from '@/components/vant-weapp/toast/toast';
279 import { randomId } from '@/utils/tools' 279 import { randomId } from '@/utils/tools'
280 -import * as dayjs from 'dayjs' 280 +import moment from '@/utils/moment.min.js'
281 import { activityInfoAPI } from '@/api/Host/index'; 281 import { activityInfoAPI } from '@/api/Host/index';
282 -var isBetween = require('dayjs/plugin/isBetween')
283 -dayjs.extend(isBetween);
284 282
285 const activity_name = ref(''); 283 const activity_name = ref('');
286 const onChange = ({ detail }) => { 284 const onChange = ({ detail }) => {
...@@ -695,11 +693,11 @@ const validForm = () => { // 校验表单 ...@@ -695,11 +693,11 @@ const validForm = () => { // 校验表单
695 Toast('报名截止时间不能为空'); 693 Toast('报名截止时间不能为空');
696 return false; 694 return false;
697 } 695 }
698 - if (!dayjs(reg_begin_time.value).isBefore(dayjs(reg_end_time.value))) { 696 + if (!moment(reg_begin_time.value).isBefore(moment(reg_end_time.value))) {
699 Toast('报名开始时间不能晚于报名截止时间'); 697 Toast('报名开始时间不能晚于报名截止时间');
700 return false; 698 return false;
701 } 699 }
702 - if (!dayjs(activity_time.value).isBetween(dayjs(reg_begin_time.value), dayjs(reg_end_time.value), null, '[]')) { 700 + if (!moment(activity_time.value).isBetween(moment(reg_begin_time.value), moment(reg_end_time.value), null, '[]')) {
703 Toast('活动时间请在报名时间之间'); 701 Toast('活动时间请在报名时间之间');
704 return false; 702 return false;
705 } 703 }
...@@ -764,11 +762,11 @@ const onSubmit = async () => { ...@@ -764,11 +762,11 @@ const onSubmit = async () => {
764 762
765 // 格式化活动时间 763 // 格式化活动时间
766 const formatInfoDate = (date) => { 764 const formatInfoDate = (date) => {
767 - const formatYear = dayjs(date).$y; 765 + const formatYear = moment(date).year();
768 - const formatMonth = dayjs(date).$M; 766 + const formatMonth = moment(date).month();
769 - const formatDay = dayjs(date).$D; 767 + const formatDay = moment(date).dates();
770 - const formatHour = dayjs(date).$H; 768 + const formatHour = moment(date).hour();
771 - const formatMin = dayjs(date).$m; 769 + const formatMin = moment(date).minute()
772 return new Date(formatYear, formatMonth, formatDay, formatHour, formatMin); 770 return new Date(formatYear, formatMonth, formatDay, formatHour, formatMin);
773 } 771 }
774 772
...@@ -811,13 +809,14 @@ const updateActivityInfo = async ({ activity, host }) => { ...@@ -811,13 +809,14 @@ const updateActivityInfo = async ({ activity, host }) => {
811 signInfo.value = signInfo.value.concat(activity.fields); 809 signInfo.value = signInfo.value.concat(activity.fields);
812 } 810 }
813 // 活动时间 811 // 活动时间
814 - activity_time.value = dayjs(activity.activity_time).format('YYYY-MM-DD HH:mm'); 812 + activity_time.value = moment(activity.activity_time).format('YYYY-MM-DD HH:mm');
815 // 开始时间 813 // 开始时间
816 - reg_begin_time.value = dayjs(activity.reg_begin_time).format('YYYY-MM-DD HH:mm'); 814 + reg_begin_time.value = moment(activity.reg_begin_time).format('YYYY-MM-DD HH:mm');
817 // 结束时间 815 // 结束时间
818 - reg_end_time.value = dayjs(activity.reg_end_time).format('YYYY-MM-DD HH:mm'); 816 + reg_end_time.value = moment(activity.reg_end_time).format('YYYY-MM-DD HH:mm');
819 // 默认弹框活动时间 817 // 默认弹框活动时间
820 defaultActivityTime = formatInfoDate(activity.activity_time); 818 defaultActivityTime = formatInfoDate(activity.activity_time);
819 + console.warn(defaultActivityTime);
821 defaultStartTime = formatInfoDate(activity.reg_begin_time); 820 defaultStartTime = formatInfoDate(activity.reg_begin_time);
822 defaultEndTime = formatInfoDate(activity.reg_end_time); 821 defaultEndTime = formatInfoDate(activity.reg_end_time);
823 // 人数限制字段 822 // 人数限制字段
......
...@@ -119,7 +119,7 @@ setTimeout(() => { ...@@ -119,7 +119,7 @@ setTimeout(() => {
119 <script> 119 <script>
120 import "./index.less"; 120 import "./index.less";
121 import { listRegAPI, statusRegAPI } from '@/api/Reg/index'; 121 import { listRegAPI, statusRegAPI } from '@/api/Reg/index';
122 -import * as dayjs from 'dayjs' 122 +import moment from '@/utils/moment.min.js'
123 import { activityInfoAPI } from '@/api/Host/index'; 123 import { activityInfoAPI } from '@/api/Host/index';
124 import { $ } from '@tarojs/extend' 124 import { $ } from '@tarojs/extend'
125 import Dialog from '@/components/vant-weapp/dialog/dialog'; 125 import Dialog from '@/components/vant-weapp/dialog/dialog';
...@@ -159,7 +159,7 @@ export default { ...@@ -159,7 +159,7 @@ export default {
159 const info = await activityInfoAPI({ i: getCurrentPageParam().id }); 159 const info = await activityInfoAPI({ i: getCurrentPageParam().id });
160 if (info.code) { 160 if (info.code) {
161 // 判断是否超过活动时间 161 // 判断是否超过活动时间
162 - if (dayjs(info.data.activity.activity_time).isBefore(dayjs(info.data.server_time))) { 162 + if (moment(info.data.activity.activity_time).isBefore(moment(info.data.server_time))) {
163 this.absent = true; 163 this.absent = true;
164 } 164 }
165 } 165 }
......
1 <!-- 1 <!--
2 * @Date: 2022-09-21 14:51:44 2 * @Date: 2022-09-21 14:51:44
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-28 18:01:09 4 + * @LastEditTime: 2022-10-31 17:17:07
5 * @FilePath: /swx/src/pages/my/index.vue 5 * @FilePath: /swx/src/pages/my/index.vue
6 * @Description: 我的页面 6 * @Description: 我的页面
7 --> 7 -->
...@@ -145,7 +145,7 @@ import "./index.less"; ...@@ -145,7 +145,7 @@ import "./index.less";
145 import { $ } from '@tarojs/extend' 145 import { $ } from '@tarojs/extend'
146 import mixin from '@/utils/mixin'; 146 import mixin from '@/utils/mixin';
147 import { infoUserAPI } from '@/api/User/index'; 147 import { infoUserAPI } from '@/api/User/index';
148 -import * as dayjs from 'dayjs' 148 +import moment from '@/utils/moment.min.js'
149 149
150 export default { 150 export default {
151 name: "myPage", 151 name: "myPage",
...@@ -175,7 +175,7 @@ export default { ...@@ -175,7 +175,7 @@ export default {
175 }, 175 },
176 methods: { 176 methods: {
177 formatDate (date) { 177 formatDate (date) {
178 - return dayjs(date).format('YYYY-MM-DD HH:mm') 178 + return moment(date).format('YYYY-MM-DD HH:mm')
179 }, 179 },
180 } 180 }
181 }; 181 };
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-31 15:17:17 4 + * @LastEditTime: 2022-10-31 17:16:06
5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue 5 * @FilePath: /swx/src/pages/myCreateActivity/index.vue
6 * @Description: 创建的活动页面 6 * @Description: 创建的活动页面
7 --> 7 -->
...@@ -118,7 +118,7 @@ import { $ } from '@tarojs/extend' ...@@ -118,7 +118,7 @@ import { $ } from '@tarojs/extend'
118 import mixin from '@/utils/mixin'; 118 import mixin from '@/utils/mixin';
119 import { getCurrentPageParam } from "@/utils/weapp"; 119 import { getCurrentPageParam } from "@/utils/weapp";
120 import { hostListAPI } from '@/api/Host/index' 120 import { hostListAPI } from '@/api/Host/index'
121 -import * as dayjs from 'dayjs' 121 +import moment from '@/utils/moment.min.js'
122 import { addListAPI, endActivityAPI, delActivityAPI, copyActivityAPI } from '@/api/Activity/index'; 122 import { addListAPI, endActivityAPI, delActivityAPI, copyActivityAPI } from '@/api/Activity/index';
123 import { hostStore } from '@/stores/host' 123 import { hostStore } from '@/stores/host'
124 124
...@@ -217,7 +217,7 @@ export default { ...@@ -217,7 +217,7 @@ export default {
217 }, 217 },
218 methods: { 218 methods: {
219 formatDate (date) { 219 formatDate (date) {
220 - return dayjs(date).format('YYYY-MM-DD HH:mm') 220 + return moment(date).format('YYYY-MM-DD HH:mm')
221 }, 221 },
222 onScrollToLower () { 222 onScrollToLower () {
223 if(!this.flag){ 223 if(!this.flag){
...@@ -258,21 +258,21 @@ export default { ...@@ -258,21 +258,21 @@ export default {
258 // '一个月之内', '三个月之内', '一年之内' 258 // '一个月之内', '三个月之内', '一年之内'
259 let yearMonthDay = ''; 259 let yearMonthDay = '';
260 if (this.filter_time === '一个月之内') { 260 if (this.filter_time === '一个月之内') {
261 - yearMonthDay = dayjs(this.server_time).subtract(1, 'month'); 261 + yearMonthDay = moment(this.server_time).subtract(1, 'month');
262 this.defaultIndex = 1; 262 this.defaultIndex = 1;
263 this.status_type = '一个月之内'; 263 this.status_type = '一个月之内';
264 } 264 }
265 if (this.filter_time === '三个月之内') { 265 if (this.filter_time === '三个月之内') {
266 - yearMonthDay = dayjs(this.server_time).subtract(3, 'month'); 266 + yearMonthDay = moment(this.server_time).subtract(3, 'month');
267 this.defaultIndex = 2; 267 this.defaultIndex = 2;
268 this.status_type = '三个月之内'; 268 this.status_type = '三个月之内';
269 } 269 }
270 if (this.filter_time === '一年之内') { 270 if (this.filter_time === '一年之内') {
271 - yearMonthDay = dayjs(this.server_time).subtract(1, 'year'); 271 + yearMonthDay = moment(this.server_time).subtract(1, 'year');
272 this.defaultIndex = 3; 272 this.defaultIndex = 3;
273 this.status_type = '一年之内'; 273 this.status_type = '一年之内';
274 } 274 }
275 - this.time_begin = `${dayjs(yearMonthDay).format('YYYY-MM-DD')} ${dayjs(this.server_time).format('HH:mm')}`; 275 + this.time_begin = `${moment(yearMonthDay).format('YYYY-MM-DD')} ${moment(this.server_time).format('HH:mm')}`;
276 this.time_end = this.server_time; 276 this.time_end = this.server_time;
277 if (this.filter_time === '全部') { 277 if (this.filter_time === '全部') {
278 this.time_begin = ''; 278 this.time_begin = '';
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-31 15:19:15 4 + * @LastEditTime: 2022-10-31 17:15:17
5 * @FilePath: /swx/src/pages/myFollowUser/index.vue 5 * @FilePath: /swx/src/pages/myFollowUser/index.vue
6 * @Description: 陪伴的用户页面 6 * @Description: 陪伴的用户页面
7 --> 7 -->
...@@ -122,10 +122,10 @@ import { $ } from '@tarojs/extend' ...@@ -122,10 +122,10 @@ import { $ } from '@tarojs/extend'
122 import mixin from '@/utils/mixin'; 122 import mixin from '@/utils/mixin';
123 import { getCurrentPageParam } from "@/utils/weapp"; 123 import { getCurrentPageParam } from "@/utils/weapp";
124 import { hostListAPI } from '@/api/Host/index' 124 import { hostListAPI } from '@/api/Host/index'
125 -import * as dayjs from 'dayjs' 125 +import moment from '@/utils/moment.min.js'
126 126
127 const formatDate = (date) => { 127 const formatDate = (date) => {
128 - return dayjs(date).format('YYYY-MM-DD HH:mm') 128 + return moment(date).format('YYYY-MM-DD HH:mm')
129 } 129 }
130 130
131 const onPhoneClick = (number) => { 131 const onPhoneClick = (number) => {
...@@ -229,7 +229,7 @@ export default { ...@@ -229,7 +229,7 @@ export default {
229 }, 229 },
230 methods: { 230 methods: {
231 formatDate (date) { 231 formatDate (date) {
232 - return dayjs(date).format('YYYY-MM-DD HH:mm') 232 + return moment(date).format('YYYY-MM-DD HH:mm')
233 }, 233 },
234 onScrollToLower () { 234 onScrollToLower () {
235 if(!this.flag){ 235 if(!this.flag){
......
1 <!-- 1 <!--
2 * @Date: 2022-09-29 16:32:03 2 * @Date: 2022-09-29 16:32:03
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-26 15:52:36 4 + * @LastEditTime: 2022-10-31 17:16:24
5 * @FilePath: /swx/src/pages/userInfo/index.vue 5 * @FilePath: /swx/src/pages/userInfo/index.vue
6 * @Description: 用户资料 6 * @Description: 用户资料
7 --> 7 -->
...@@ -119,7 +119,7 @@ import "./index.less"; ...@@ -119,7 +119,7 @@ import "./index.less";
119 import { infoMemberAPI } from '@/api/Member/index'; 119 import { infoMemberAPI } from '@/api/Member/index';
120 import { getCurrentPageParam } from "@/utils/weapp"; 120 import { getCurrentPageParam } from "@/utils/weapp";
121 import mixin from '@/utils/mixin'; 121 import mixin from '@/utils/mixin';
122 -import * as dayjs from 'dayjs' 122 +import moment from '@/utils/moment.min.js'
123 123
124 export default { 124 export default {
125 name: "userInfoPage", 125 name: "userInfoPage",
...@@ -182,7 +182,7 @@ export default { ...@@ -182,7 +182,7 @@ export default {
182 this.show_partner_popup = false; 182 this.show_partner_popup = false;
183 }, 183 },
184 formatDate (date) { 184 formatDate (date) {
185 - return dayjs(date).format('YYYY-MM-DD HH:mm') 185 + return moment(date).format('YYYY-MM-DD HH:mm')
186 } 186 }
187 } 187 }
188 }; 188 };
......
This diff is collapsed. Click to expand it.
1 /* 1 /*
2 * @Date: 2022-04-18 15:59:42 2 * @Date: 2022-04-18 15:59:42
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-10-18 14:55:28 4 + * @LastEditTime: 2022-10-31 17:26:32
5 * @FilePath: /swx/src/utils/tools.js 5 * @FilePath: /swx/src/utils/tools.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
8 -import dayjs from 'dayjs';
9 import Taro from '@tarojs/taro' 8 import Taro from '@tarojs/taro'
9 +import moment from '@/utils/moment.min.js'
10 10
11 // 格式化时间 11 // 格式化时间
12 const formatDate = (date) => { 12 const formatDate = (date) => {
13 - return dayjs(date).format('YYYY-MM-DD HH:mm'); 13 + return moment(date).format('YYYY-MM-DD HH:mm')
14 }; 14 };
15 15
16 /** 16 /**
......