Browse Source

首页展示

remotes/origin/HEAD
songsong428 5 years ago
parent
commit
51896ccc10
  1. 24
      common/script/filters.js
  2. 5
      main.js
  3. 9
      pages/add-stroke/add-stroke.vue
  4. 1
      pages/add-stroke/components/date-selector.vue
  5. 8
      pages/apply-code/apply-code.vue
  6. 28
      pages/basic-info/basic-info.vue
  7. 4
      pages/index/components/home.vue
  8. 15
      pages/my-code/my-code.vue
  9. 23
      pages/my-trips/my-trips.vue
  10. 7
      store/modules/user/actions.js

24
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);
};

5
main.js

@ -10,11 +10,6 @@ Vue.prototype.$moment = moment;
moment.locale('zh-cn'); moment.locale('zh-cn');
// 定义一个全局过滤器实现日期格式化
Vue.filter('datefmt', function (input, fmtstring) {
return moment.unix(input).format(fmtstring)
})
Vue.prototype.goHome = () => { Vue.prototype.goHome = () => {
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index', url: '/pages/index/index',

9
pages/add-stroke/add-stroke.vue

@ -164,6 +164,7 @@ export default {
together, together,
tripMode tripMode
} = this; } = this;
const params = { const params = {
param: { param: {
carNo, carNo,
@ -174,7 +175,7 @@ export default {
tripMode tripMode
} }
}; };
console.log('params2',params)
const res = await this.$http.post(SUBMIT_JOURNEYS, params); const res = await this.$http.post(SUBMIT_JOURNEYS, params);
const { const {
success, success,
@ -183,13 +184,17 @@ export default {
data data
} = res.data; } = res.data;
if (success && code === 200) { if (success && code === 200) {
uni.showToast({
title: '行程添加成功',
duration: 2000
});
this.success = true; this.success = true;
uni.reLaunch({ uni.reLaunch({
url: `/pages/index/index`, url: `/pages/index/index`,
}); });
} else { } else {
uni.showToast({ uni.showToast({
title: msg || '行程添加成功', title: msg || '行程添加失败',
icon: 'none' icon: 'none'
}); });
} }

1
pages/add-stroke/components/date-selector.vue

@ -32,7 +32,6 @@
* @param {object} value 日历返回对象 * @param {object} value 日历返回对象
*/ */
handleChange(value) { handleChange(value) {
console.log('value', value.fulldate)
this.time = value.fulldate; this.time = value.fulldate;
this.$emit('change', this.time); this.$emit('change', this.time);
}, },

8
pages/apply-code/apply-code.vue

@ -188,7 +188,7 @@
touchSick touchSick
} }
}; };
console.log('params1', params)
const res = await this.$http.post(HEALTH_SIGN, params); const res = await this.$http.post(HEALTH_SIGN, params);
const { const {
success, success,
@ -197,6 +197,10 @@
data data
} = res.data; } = res.data;
if (success && code === 200) { if (success && code === 200) {
uni.showToast({
title: '申请健康码成功',
duration: 2000
});
this.success = true; this.success = true;
this.setHealthCode(data.healthCode) this.setHealthCode(data.healthCode)
uni.reLaunch({ uni.reLaunch({
@ -204,7 +208,7 @@
}); });
} else { } else {
uni.showToast({ uni.showToast({
title: msg || '申请健康码成功', title: msg || '申请健康码失败',
icon: 'none' icon: 'none'
}); });
} }

28
pages/basic-info/basic-info.vue

@ -144,16 +144,6 @@ export default {
this.agree = data; 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 res = await this.$http.post(SUBMIT_USER_INFO, params);
const { success, code, msg, data } = res.data; const { success, code, msg, data } = res.data;
if (success && code === 200) { if (success && code === 200) {
this.success = true;
this.setUserInfo(data);
uni.showToast({ uni.showToast({
title: '信息提交成功', title: '基本信息提交成功',
duration: 2000 duration: 2000
}); });
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); this.openPage(pagePath);
console.log('跳转路径',pagePath) }
} else { } else {
uni.showToast({ uni.showToast({
title: msg || '提交基本信息成功', title: msg || '基本信息提交失败',
icon: 'none', icon: 'none',
}); });
} }
@ -193,7 +189,7 @@ export default {
console.log('error: ', error); console.log('error: ', error);
if (error.msg) { if (error.msg) {
uni.showToast({ uni.showToast({
title: error.msg || '提交基本信息失败', title: error.msg || '基本信息提交失败',
icon: 'none', icon: 'none',
}); });
} }

4
pages/index/components/home.vue

@ -11,14 +11,14 @@
class="bg"></image> class="bg"></image>
<view :class="healthCode ? 'box1' : 'box'"> <view :class="healthCode ? 'box1' : 'box'">
<view v-show="!(userInfo && userInfo.id)" class="cu-card flex margin bg-white shadow card-radius" hover-class="cc-active" @tap="openPage('/pages/basic-info/basic-info')"> <view v-show="!healthCode" class="cu-card flex margin bg-white shadow card-radius" hover-class="cc-active" @tap="openPage('/pages/apply-code/apply-code')">
<view class="flex align-center padding"> <view class="flex align-center padding">
<view class="round lg cu-avatar icon1"> <view class="round lg cu-avatar icon1">
<view class="iconfont icon-qrcode"></view> <view class="iconfont icon-qrcode"></view>
</view> </view>
<view class="padding-left-sm flex-sub"> <view class="padding-left-sm flex-sub">
<view class="text-xl">领取健康码</view> <view class="text-xl">领取健康码</view>
<view class="text-df padding-top-xs description">个人基本信息登记</view> <view class="text-df padding-top-xs description">领取健康码查看健康状态</view>
</view> </view>
</view> </view>
</view> </view>

15
pages/my-code/my-code.vue

@ -3,7 +3,7 @@
<!-- 添加 --> <!-- 添加 -->
<button class="shadow round bg-cyan add-btn iconfont icon-plus" hover-class="cc-active" @tap="openPage('/pages/apply-code/apply-code')"></button> <button class="shadow round bg-cyan add-btn iconfont icon-plus" hover-class="cc-active" @tap="openPage('/pages/apply-code/apply-code')"></button>
<view v-if="tableList && tableList.length>0" class="cu-timeline" :key="index" v-for="(item,index) in tableList"> <view v-if="tableList && tableList.length>0" class="cu-timeline" :key="index" v-for="(item,index) in tableList">
<view class="cu-time">{{ +item.time | datefmt('MM-DD') }}</view> <view class="cu-time">{{ +item.time | formatDate }}</view>
<view class="cu-item text-blue cuIcon-locationfill"> <view class="cu-item text-blue cuIcon-locationfill">
<view class="content shadow-blur bg-blue light"> <view class="content shadow-blur bg-blue light">
{{ item.district }}{{ item.address }} {{ item.district }}{{ item.address }}
@ -36,6 +36,9 @@
</template> </template>
<script> <script>
import {
formatDate
} from 'common/script/filters';
import { import {
showToast showToast
} from 'common/script/util'; } from 'common/script/util';
@ -53,6 +56,14 @@
computed: mapState('user', ['token','userInfo','status']), computed: mapState('user', ['token','userInfo','status']),
//
filters: {
formatDate(time) {
var data = new Date(time);
return formatDate(data, 'MM-dd');
}
},
onLoad() { onLoad() {
const startTime = +this.$moment() const startTime = +this.$moment()
.startOf('year') .startOf('year')
@ -88,7 +99,7 @@
this.tableList = data; this.tableList = data;
} else { } else {
uni.showToast({ uni.showToast({
title: msg || '获取健康打卡记录成功', title: msg || '获取健康打卡记录失败',
icon: 'none' icon: 'none'
}); });
} }

23
pages/my-trips/my-trips.vue

@ -3,10 +3,10 @@
<!-- 添加 --> <!-- 添加 -->
<button class="shadow round bg-cyan add-btn iconfont icon-plus" hover-class="cc-active" @tap="openPage('/pages/add-stroke/add-stroke')"></button> <button class="shadow round bg-cyan add-btn iconfont icon-plus" hover-class="cc-active" @tap="openPage('/pages/add-stroke/add-stroke')"></button>
<view v-if="tableList && tableList.length>0" class="cu-timeline" :key="index" v-for="(item,index) in tableList"> <view v-if="tableList && tableList.length>0" class="cu-timeline" :key="index" v-for="(item,index) in tableList">
<view class="cu-time">{{ +item.startTime | datefmt('MM-DD') }}</view> <view class="cu-time">{{ +item.startTime | formatDate }}</view>
<view class="cu-item cuIcon-timefill text-blue"> <view class="cu-item cuIcon-timefill text-blue">
<view class="content shadow-blur bg-blue light"> <view class="content shadow-blur bg-blue light">
{{ +item.startTime | datefmt('MM月DD日') }} -- {{ +item.endTime | datefmt('MM月DD日') }} {{ +item.startTime | formatDate }} {{ +item.endTime | formatDate }}
</view> </view>
</view> </view>
<view class="cu-item cuIcon-tagfill text-green"> <view class="cu-item cuIcon-tagfill text-green">
@ -35,6 +35,9 @@
</template> </template>
<script> <script>
import {
formatDate
} from 'common/script/filters';
import { import {
showToast showToast
} from 'common/script/util'; } from 'common/script/util';
@ -80,6 +83,14 @@
computed: mapState('user', ['token']), computed: mapState('user', ['token']),
//
filters: {
formatDate(time) {
var data = new Date(time);
return formatDate(data, 'MM-dd');
}
},
onLoad() { onLoad() {
const startTime = +this.$moment() const startTime = +this.$moment()
.startOf('year') .startOf('year')
@ -108,12 +119,16 @@
msg, msg,
data data
} = res.data; } = res.data;
if (success && code === 200) { if (success && code === 200) {
this.success = true; this.success = true;
this.tableList = data; this.tableList = data;
const fff = this.$moment(1583683200000).format('YY-MM-DD')
} else { } else {
uni.showToast({ uni.showToast({
title: msg || '获取健康打卡记录成功', title: msg || '查询行程失败',
icon: 'none' icon: 'none'
}); });
} }
@ -121,7 +136,7 @@
console.log('error: ', error); console.log('error: ', error);
if (error.msg) { if (error.msg) {
uni.showToast({ uni.showToast({
title: error.msg || '获取健康打卡记录失败', title: error.msg || '查询行程失败',
icon: 'none' icon: 'none'
}); });
} }

7
store/modules/user/actions.js

@ -1,4 +1,4 @@
import { showModal, showToast } from 'utils/ui'; import { showLoading, hideLoading, showModal, showToast } from 'utils/ui';
import { mpLogin, signIn } from 'utils/user'; import { mpLogin, signIn } from 'utils/user';
import { UPDATE_USER } from 'api/user'; import { UPDATE_USER } from 'api/user';
import { GET_USER_INFO, HEALTH_TYPE_STATUS } from 'api/api'; import { GET_USER_INFO, HEALTH_TYPE_STATUS } from 'api/api';
@ -69,9 +69,11 @@ const actions = {
*/ */
getUserInfo({ commit }, params) { getUserInfo({ commit }, params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
showLoading();
http http
.post(GET_USER_INFO, params) .post(GET_USER_INFO, params)
.then(res => { .then(res => {
hideLoading();
const { data } = res.data; const { data } = res.data;
resolve(data); resolve(data);
// 获取自己的信息采取设置 // 获取自己的信息采取设置
@ -86,7 +88,8 @@ const actions = {
} }
}) })
.catch(data => { .catch(data => {
showToast(data.msg || '查询个人信息成功'); hideLoading();
showToast(data.msg || '查询个人信息失败');
reject(data); reject(data);
}); });
}); });

Loading…
Cancel
Save