From 51896ccc10a43e75c12eb3bee249f16cdeb55204 Mon Sep 17 00:00:00 2001 From: songsong428 Date: Mon, 9 Mar 2020 14:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/script/filters.js | 24 +++++++++++++++ main.js | 5 ---- pages/add-stroke/add-stroke.vue | 9 ++++-- pages/add-stroke/components/date-selector.vue | 1 - pages/apply-code/apply-code.vue | 8 +++-- pages/basic-info/basic-info.vue | 30 ++++++++----------- pages/index/components/home.vue | 4 +-- pages/my-code/my-code.vue | 15 ++++++++-- pages/my-trips/my-trips.vue | 23 +++++++++++--- store/modules/user/actions.js | 7 +++-- 10 files changed, 89 insertions(+), 37 deletions(-) create mode 100644 common/script/filters.js diff --git a/common/script/filters.js b/common/script/filters.js new file mode 100644 index 0000000..29eabbe --- /dev/null +++ b/common/script/filters.js @@ -0,0 +1,24 @@ +// 定义过滤器 时间戳转化 +export function formatDate (date, fmt) { + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); + } + let o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds() + }; + for (let k in o) { + if (new RegExp(`(${k})`).test(fmt)) { + let str = o[k] + ''; + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str)); + } + } + return fmt; + }; + + function padLeftZero (str) { + return ('00' + str).substr(str.length); + }; \ No newline at end of file diff --git a/main.js b/main.js index 4472587..8458b43 100644 --- a/main.js +++ b/main.js @@ -10,11 +10,6 @@ Vue.prototype.$moment = moment; moment.locale('zh-cn'); -// 定义一个全局过滤器实现日期格式化 -Vue.filter('datefmt', function (input, fmtstring) { - return moment.unix(input).format(fmtstring) -}) - Vue.prototype.goHome = () => { uni.reLaunch({ url: '/pages/index/index', diff --git a/pages/add-stroke/add-stroke.vue b/pages/add-stroke/add-stroke.vue index 8d54b38..58a2786 100644 --- a/pages/add-stroke/add-stroke.vue +++ b/pages/add-stroke/add-stroke.vue @@ -164,6 +164,7 @@ export default { together, tripMode } = this; + const params = { param: { carNo, @@ -174,7 +175,7 @@ export default { tripMode } }; - console.log('params2',params) + const res = await this.$http.post(SUBMIT_JOURNEYS, params); const { success, @@ -183,13 +184,17 @@ export default { data } = res.data; if (success && code === 200) { + uni.showToast({ + title: '行程添加成功', + duration: 2000 + }); this.success = true; uni.reLaunch({ url: `/pages/index/index`, }); } else { uni.showToast({ - title: msg || '行程添加成功', + title: msg || '行程添加失败', icon: 'none' }); } diff --git a/pages/add-stroke/components/date-selector.vue b/pages/add-stroke/components/date-selector.vue index b393bc0..293c553 100644 --- a/pages/add-stroke/components/date-selector.vue +++ b/pages/add-stroke/components/date-selector.vue @@ -32,7 +32,6 @@ * @param {object} value 日历返回对象 */ handleChange(value) { - console.log('value', value.fulldate) this.time = value.fulldate; this.$emit('change', this.time); }, diff --git a/pages/apply-code/apply-code.vue b/pages/apply-code/apply-code.vue index b7a78cc..ff837d8 100644 --- a/pages/apply-code/apply-code.vue +++ b/pages/apply-code/apply-code.vue @@ -188,7 +188,7 @@ touchSick } }; - console.log('params1', params) + const res = await this.$http.post(HEALTH_SIGN, params); const { success, @@ -197,6 +197,10 @@ data } = res.data; if (success && code === 200) { + uni.showToast({ + title: '申请健康码成功', + duration: 2000 + }); this.success = true; this.setHealthCode(data.healthCode) uni.reLaunch({ @@ -204,7 +208,7 @@ }); } else { uni.showToast({ - title: msg || '申请健康码成功', + title: msg || '申请健康码失败', icon: 'none' }); } diff --git a/pages/basic-info/basic-info.vue b/pages/basic-info/basic-info.vue index ffabbad..3357b77 100644 --- a/pages/basic-info/basic-info.vue +++ b/pages/basic-info/basic-info.vue @@ -144,16 +144,6 @@ export default { this.agree = data; }, - - ceshi(){ - uni.showToast({ - title: '信息提交成功', - duration: 2000 - }); - const ggg = this.pagePath; - this.openPage(ggg); - }, - /** * 提交基本信息 */ @@ -175,17 +165,23 @@ export default { const res = await this.$http.post(SUBMIT_USER_INFO, params); const { success, code, msg, data } = res.data; if (success && code === 200) { - this.success = true; - this.setUserInfo(data); uni.showToast({ - title: '信息提交成功', + title: '基本信息提交成功', duration: 2000 }); - this.openPage(pagePath); - console.log('跳转路径',pagePath) + this.success = true; + this.setUserInfo(data); + console.log(pagePath) + if(pagePath === '/pages/basic-info/basic-info'){ + uni.reLaunch({ + url: `/pages/index/index`, + }); + }else{ + this.openPage(pagePath); + } } else { uni.showToast({ - title: msg || '提交基本信息成功', + title: msg || '基本信息提交失败', icon: 'none', }); } @@ -193,7 +189,7 @@ export default { console.log('error: ', error); if (error.msg) { uni.showToast({ - title: error.msg || '提交基本信息失败', + title: error.msg || '基本信息提交失败', icon: 'none', }); } diff --git a/pages/index/components/home.vue b/pages/index/components/home.vue index 70137ac..446c81b 100644 --- a/pages/index/components/home.vue +++ b/pages/index/components/home.vue @@ -11,14 +11,14 @@ class="bg"> - + 领取健康码 - 个人基本信息登记 + 领取健康码,查看健康状态 diff --git a/pages/my-code/my-code.vue b/pages/my-code/my-code.vue index 9ba7512..e600ccd 100644 --- a/pages/my-code/my-code.vue +++ b/pages/my-code/my-code.vue @@ -3,7 +3,7 @@ - {{ +item.time | datefmt('MM-DD') }} + {{ +item.time | formatDate }} {{ item.district }},{{ item.address }} @@ -36,6 +36,9 @@