From a2ba0c4546bf727ca0ec23bea7c6edf575883614 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Fri, 6 Mar 2020 22:39:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 10 +++++ manifest.json | 5 +++ pages.json | 15 ++++++- pages/healthy-card/healthy-card.vue | 14 ++++++ pages/index/index.vue | 1 + pages/sign/sign.vue | 2 +- pages/statistics/components/health-data.vue | 48 +++++++++++++-------- pages/statistics/statistics.vue | 18 ++++---- pages/user-code/user-code.vue | 25 +++++++++++ 9 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 pages/healthy-card/healthy-card.vue create mode 100644 pages/user-code/user-code.vue diff --git a/App.vue b/App.vue index 02c7786..29e26ad 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,16 @@ import { mapActions } from 'vuex'; export default { async onLaunch() { await this.login(); + uni.getSetting({ + success(res) { + if (!res.authSetting['scope.userLocation']) { + uni.authorize({ + scope: 'scope.userLocation', + success() {}, + }); + } + }, + }); }, methods: { diff --git a/manifest.json b/manifest.json index c0f4472..e81bf4b 100644 --- a/manifest.json +++ b/manifest.json @@ -64,6 +64,11 @@ "postcss" : true, "minified" : true }, + "permission": { + "scope.userLocation": { + "desc": "你的位置信息将用于获取地理位置及地图展示" + } + }, "usingComponents" : true }, "mp-alipay" : { diff --git a/pages.json b/pages.json index e19261a..75f7690 100644 --- a/pages.json +++ b/pages.json @@ -13,6 +13,11 @@ "navigationBarTitleText": "山大健康码" } }, + { + "path": "pages/statistics/statistics", + "style": { "navigationBarTitleText": "统计" } + }, + { "path": "pages/my-signs/my-signs", "style": { "navigationBarTitleText": "我的校园打卡" } @@ -64,7 +69,15 @@ "navigationBarTitleText": "我的行程" } } - ], + ,{ + "path" : "pages/healthy-card/healthy-card", + "style" : {} + } + ,{ + "path" : "pages/user-code/user-code", + "style" : {} + } + ], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "山大健康码", diff --git a/pages/healthy-card/healthy-card.vue b/pages/healthy-card/healthy-card.vue new file mode 100644 index 0000000..97fb425 --- /dev/null +++ b/pages/healthy-card/healthy-card.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue index 99e3a37..2d68c41 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -36,6 +36,7 @@ export default { uni.scanCode({ onlyFromCamera: true, success: res => { + console.log('res: ', res); console.log('条码类型:' + res.scanType); console.log('条码内容:' + res.result); }, diff --git a/pages/sign/sign.vue b/pages/sign/sign.vue index 7d69e59..114b115 100644 --- a/pages/sign/sign.vue +++ b/pages/sign/sign.vue @@ -25,7 +25,7 @@ export default { address: '图书馆', siteId: '', siteName: '', - success: true, + success: false, }; }, diff --git a/pages/statistics/components/health-data.vue b/pages/statistics/components/health-data.vue index 9bbd8dc..44bf7c2 100644 --- a/pages/statistics/components/health-data.vue +++ b/pages/statistics/components/health-data.vue @@ -11,21 +11,9 @@ - - 100 - 正常 - - - 9 - 发烧 - - - 10 - 其他 - - - 50 - 未上报 + + {{ item.number }} + {{ item.name }} @@ -33,15 +21,41 @@ diff --git a/pages/statistics/statistics.vue b/pages/statistics/statistics.vue index d282278..e9700e0 100644 --- a/pages/statistics/statistics.vue +++ b/pages/statistics/statistics.vue @@ -43,7 +43,7 @@ export default { this.$moment(end) .endOf('day') .format('x') - 0; - console.log('startTime,endTime: ', startTime, endTime); + console.log('startTime, endTime: ', startTime, endTime); // 获取校园打卡的数据 this.getSchoolSignsData(startTime, endTime); // 获取健康上报数目数据 @@ -52,12 +52,12 @@ export default { /** * 获取校园打卡的数据 - * @param {number} start 开始时间 - * @param {number} end 截止时间 + * @param {number} startTime 开始时间 + * @param {number} endTime 截止时间 */ - getSchoolSignsData(start, end) { + getSchoolSignsData(startTime, endTime) { try { - const params = { param: { start, end } }; + const params = { param: { startTime, endTime } }; this.getSchoolSigns(params); } catch (error) { console.log('getSchoolSignsData error: ', error); @@ -66,12 +66,12 @@ export default { /** * 获取健康上报的数目数据 - * @param {number} start 开始时间 - * @param {number} end 截止时间 + * @param {number} startTime 开始时间 + * @param {number} endTime 截止时间 */ - getSchoolSignsNumberData(start, end) { + getSchoolSignsNumberData(startTime, endTime) { try { - const params = { param: { start, end } }; + const params = { param: { startTime, endTime } }; this.getSchoolSignsNumber(params); } catch (error) { console.log('getSchoolSignsNumberData error: ', error); diff --git a/pages/user-code/user-code.vue b/pages/user-code/user-code.vue new file mode 100644 index 0000000..c43b673 --- /dev/null +++ b/pages/user-code/user-code.vue @@ -0,0 +1,25 @@ + + + + + From 91022bfd6ef20967b231bcfc55d7bb84dd39c0e4 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Sat, 7 Mar 2020 16:15:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=81=A5=E5=BA=B7=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E6=95=B0=E7=9B=AE=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 70 +++++++++++++-------------- store/modules/statistics/mutations.js | 8 ++- store/modules/statistics/state.js | 7 ++- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/pages.json b/pages.json index 75f7690..819997a 100644 --- a/pages.json +++ b/pages.json @@ -41,43 +41,39 @@ "navigationBarTitleText": "基本信息填写" } }, - { - "path": "pages/add-stroke/add-stroke", - "style": { - "navigationBarTitleText": "添加行程" - } - }, - { - "path": "pages/apply-code/apply-code", - "style": { - "navigationBarTitleText": "申请健康码" - } - }, - { - "path": "pages/statistics/statistics", - "style": { "navigationBarTitleText": "统计" } - }, - { - "path": "pages/my-code/my-code", - "style": { - "navigationBarTitleText": "我的健康打卡" - } - }, - { - "path": "pages/my-trips/my-trips", - "style": { - "navigationBarTitleText": "我的行程" - } - } - ,{ - "path" : "pages/healthy-card/healthy-card", - "style" : {} - } - ,{ - "path" : "pages/user-code/user-code", - "style" : {} - } - ], + { + "path": "pages/add-stroke/add-stroke", + "style": { + "navigationBarTitleText": "添加行程" + } + }, + { + "path": "pages/apply-code/apply-code", + "style": { + "navigationBarTitleText": "申请健康码" + } + }, + { + "path": "pages/my-code/my-code", + "style": { + "navigationBarTitleText": "我的健康打卡" + } + }, + { + "path": "pages/my-trips/my-trips", + "style": { + "navigationBarTitleText": "我的行程" + } + }, + { + "path": "pages/healthy-card/healthy-card", + "style": {} + }, + { + "path": "pages/user-code/user-code", + "style": {} + } + ], "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "山大健康码", diff --git a/store/modules/statistics/mutations.js b/store/modules/statistics/mutations.js index dd8489d..4e42cea 100644 --- a/store/modules/statistics/mutations.js +++ b/store/modules/statistics/mutations.js @@ -23,7 +23,13 @@ const mutations = { * @param {array} data */ setShoolSignNumber(state, data) { - state.shoolSignNumber = data || []; + const arr = [ + { name: '正常', number: '-' }, + { name: '发烧', number: '-' }, + { name: '其他', number: '-' }, + { name: '未上报', number: '-' }, + ]; + state.shoolSignNumber = data || arr; }, }; diff --git a/store/modules/statistics/state.js b/store/modules/statistics/state.js index 0770464..8e546cb 100644 --- a/store/modules/statistics/state.js +++ b/store/modules/statistics/state.js @@ -1,7 +1,12 @@ const state = { userSigns: [], // 用户个人打卡记录 shoolSigns: [], // 校园的打卡记录 - shoolSignNumber: [], // 健康上报数目统计 + shoolSignNumber: [ + { name: '正常', number: '-' }, + { name: '发烧', number: '-' }, + { name: '其他', number: '-' }, + { name: '未上报', number: '-' }, + ], // 健康上报数目统计 }; export default state; From ecaace8ef6bc991e99b644af9f4604ba65437469 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Sat, 7 Mar 2020 19:05:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?1.=E6=89=93=E5=8D=A1=202.=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 5 +- components/history-map/history-map.vue | 64 ++--------- components/school-map/school-map.vue | 101 ++++++++++++++++++ config/api/api.js | 3 + config/config.user.js | 3 +- pages.json | 7 -- pages/sign/sign.vue | 31 +++--- pages/statistics/components/date-selector.vue | 16 ++- pages/statistics/components/location-map.vue | 37 +++++-- store/index.js | 3 +- store/modules/site/actions.js | 53 +++++++++ store/modules/site/index.js | 5 + store/modules/site/mutations.js | 12 +++ store/modules/site/state.js | 5 + store/modules/statistics/actions.js | 2 + store/modules/statistics/mutations.js | 2 +- store/modules/statistics/state.js | 2 +- store/modules/user/actions.js | 2 + utils/user.js | 5 +- 19 files changed, 262 insertions(+), 96 deletions(-) create mode 100644 components/school-map/school-map.vue create mode 100644 store/modules/site/actions.js create mode 100644 store/modules/site/index.js create mode 100644 store/modules/site/mutations.js create mode 100644 store/modules/site/state.js diff --git a/App.vue b/App.vue index 29e26ad..1f730f4 100644 --- a/App.vue +++ b/App.vue @@ -3,7 +3,6 @@ import { mapActions } from 'vuex'; export default { async onLaunch() { - await this.login(); uni.getSetting({ success(res) { if (!res.authSetting['scope.userLocation']) { @@ -14,10 +13,14 @@ export default { } }, }); + + await this.login(); + this.getSites(); }, methods: { ...mapActions('user', ['login']), + ...mapActions('site', ['getSites']), }, }; diff --git a/components/history-map/history-map.vue b/components/history-map/history-map.vue index 00bcadc..6c635bd 100644 --- a/components/history-map/history-map.vue +++ b/components/history-map/history-map.vue @@ -2,7 +2,7 @@ export default { + props: { + markers: { type: Array, default: null }, + polyline: { type: Array, default: null }, + polygons: { type: Array, default: null }, + }, data() { return { latitude: 37.87059, longitude: 112.55067, - covers: [ - { - latitude: 37.87059, - longitude: 112.55067, - iconPath: '../../static/location.png', - callout: { - content: 'test', - color: '#fff', - padding: 4, - bgColor: '#0A97C6', - borderRadius: 2, - textAlign: 'center', - }, - }, - { - latitude: 37.87, - longitude: 112.5506, - iconPath: '../../static/location.png', - }, - { - latitude: 37.8701, - longitude: 112.55, - iconPath: '../../static/location.png', - }, - { - latitude: 37.86, - longitude: 112.5496, - iconPath: '../../static/location.png', - }, - ], - polyline: [ - { - points: [ - { latitude: 37.87059, longitude: 112.55067 }, - { latitude: 37.87, longitude: 112.5506 }, - { latitude: 37.8701, longitude: 112.55 }, - { latitude: 37.86, longitude: 112.5496 }, - ], - arrowLine: true, - dottedLine: true, - borderColor: '#cccccc', - }, - ], - polygons: [ - { - points: [ - { latitude: 37.87059, longitude: 112.55067 }, - { latitude: 37.87, longitude: 112.5506 }, - { latitude: 37.8701, longitude: 112.55 }, - { latitude: 37.86, longitude: 112.5496 }, - ], - strokeWidth: 0, - strokeColor: '#00000000', - fillColor: '#cce6ff88', - zIndex: 0, - }, - ], }; }, diff --git a/components/school-map/school-map.vue b/components/school-map/school-map.vue new file mode 100644 index 0000000..00bcadc --- /dev/null +++ b/components/school-map/school-map.vue @@ -0,0 +1,101 @@ + + + diff --git a/config/api/api.js b/config/api/api.js index 83ad5a0..0e001a8 100644 --- a/config/api/api.js +++ b/config/api/api.js @@ -25,6 +25,9 @@ export const HEALTH_SIGN = `${health}/upload`; // 查看自己的打卡记录 export const USER_SIGNS = `${sites}/info`; +// 获取所有场景信息 +export const SITES_INFO = `${sites}/siteInfo`; + // 扫码统计 export const SCHOOL_SIGNS = `${sites}/statistics`; diff --git a/config/config.user.js b/config/config.user.js index 34c05d9..ad91371 100644 --- a/config/config.user.js +++ b/config/config.user.js @@ -5,7 +5,7 @@ */ // 用户登录client -export const SIGN_IN_CLIENTS = { mp: 0, h5: 1, android: 2, ios: 3 }; +export const SIGN_IN_CLIENTS = { mp: 0, h5: 1, android: 2, ios: 3, wx_work: 4 }; // 用户登录类型 export const SIGN_IN_TYPES = { @@ -16,4 +16,5 @@ export const SIGN_IN_TYPES = { wx: 4, wx_web: 5, wb: 6, + wx_work: 7, }; diff --git a/pages.json b/pages.json index 819997a..7758094 100644 --- a/pages.json +++ b/pages.json @@ -1,12 +1,5 @@ { "pages": [ - // { - // "path": "pages/my-code/my-code", - // "style": { - // "navigationBarTitleText": "我的健康打卡" - // } - // }, - { "path": "pages/index/index", "style": { diff --git a/pages/sign/sign.vue b/pages/sign/sign.vue index 114b115..f678f61 100644 --- a/pages/sign/sign.vue +++ b/pages/sign/sign.vue @@ -4,7 +4,7 @@ {{ address }} - + @@ -15,6 +15,7 @@ diff --git a/store/index.js b/store/index.js index e30e291..61aa120 100644 --- a/store/index.js +++ b/store/index.js @@ -1,11 +1,12 @@ import Vue from 'vue'; import Vuex from 'vuex'; import user from './modules/user/index'; +import site from './modules/site/index'; import statistics from './modules/statistics/index'; Vue.use(Vuex); const store = new Vuex.Store({ - modules: { user, statistics }, + modules: { user, site, statistics }, }); export default store; diff --git a/store/modules/site/actions.js b/store/modules/site/actions.js new file mode 100644 index 0000000..1b3e901 --- /dev/null +++ b/store/modules/site/actions.js @@ -0,0 +1,53 @@ +import { http } from 'plugins/request/index'; +import { showLoading, hideLoading, showToast, showModal } from 'utils/ui'; +import { SITES_INFO, SCAN_SIGN } from 'api/api'; + +const actions = { + /** + * 获取所有场所信息 + * @param {*} commit + */ + getSites({ commit }) { + return new Promise((resolve, reject) => { + showLoading(); + http + .post(SITES_INFO) + .then(res => { + hideLoading(); + const { data } = res.data; + commit('setSites', data); + resolve(data); + }) + .catch(data => { + hideLoading(); + showToast(data.msg || '获取场所信息失败'); + reject(data); + }); + }); + }, + + /** + * 扫码打卡 提交打卡记录 + * @param {*} commit + * @param {object} params 提交服务端的数据 + */ + sign({ commit }, params) { + return new Promise((resolve, reject) => { + showLoading(); + http + .post(SCAN_SIGN, params) + .then(res => { + hideLoading(); + const { data } = res.data; + resolve(data); + }) + .catch(data => { + hideLoading(); + showToast(data.msg || '打卡失败'); + reject(data); + }); + }); + }, +}; + +export default actions; diff --git a/store/modules/site/index.js b/store/modules/site/index.js new file mode 100644 index 0000000..e67cdeb --- /dev/null +++ b/store/modules/site/index.js @@ -0,0 +1,5 @@ +import state from './state'; +import mutations from './mutations'; +import actions from './actions.js'; + +export default { namespaced: true, state, actions, mutations }; diff --git a/store/modules/site/mutations.js b/store/modules/site/mutations.js new file mode 100644 index 0000000..2329876 --- /dev/null +++ b/store/modules/site/mutations.js @@ -0,0 +1,12 @@ +const mutations = { + /** + * 设置所有的场所值 + * @param {object} state + * @param {array} data + */ + setSites(state, data) { + state.sites = data || []; + }, +}; + +export default mutations; diff --git a/store/modules/site/state.js b/store/modules/site/state.js new file mode 100644 index 0000000..c730759 --- /dev/null +++ b/store/modules/site/state.js @@ -0,0 +1,5 @@ +const state = { + sites: [], // 所有的场所信息 +}; + +export default state; diff --git a/store/modules/statistics/actions.js b/store/modules/statistics/actions.js index f5de065..399d247 100644 --- a/store/modules/statistics/actions.js +++ b/store/modules/statistics/actions.js @@ -64,11 +64,13 @@ const actions = { http .post(HEALTH_TYPE_STATISTICS, params) .then(res => { + hideLoading(); const { data } = res.data; commit('setShoolSignNumber', data); resolve(data); }) .catch(data => { + hideLoading(); showToast(data.msg || '获取健康上报数据失败'); reject(data); }); diff --git a/store/modules/statistics/mutations.js b/store/modules/statistics/mutations.js index 4e42cea..3356f07 100644 --- a/store/modules/statistics/mutations.js +++ b/store/modules/statistics/mutations.js @@ -14,7 +14,7 @@ const mutations = { * @param {array} data */ setSchoolSigns(state, data) { - state.shoolSigns = data || []; + state.schoolSigns = data || []; }, /** diff --git a/store/modules/statistics/state.js b/store/modules/statistics/state.js index 8e546cb..dee34b3 100644 --- a/store/modules/statistics/state.js +++ b/store/modules/statistics/state.js @@ -1,6 +1,6 @@ const state = { userSigns: [], // 用户个人打卡记录 - shoolSigns: [], // 校园的打卡记录 + schoolSigns: [], // 校园的打卡记录 shoolSignNumber: [ { name: '正常', number: '-' }, { name: '发烧', number: '-' }, diff --git a/store/modules/user/actions.js b/store/modules/user/actions.js index 8f216c2..37d9e72 100644 --- a/store/modules/user/actions.js +++ b/store/modules/user/actions.js @@ -10,11 +10,13 @@ const actions = { mpLogin() .then(params => signIn(params)) .then(data => { + console.log('login data: ', data); commit('setToken', data.token); commit('setUser', data); resolve(data); }) .catch(err => { + console.log('login err: ', err); // showModal(err.msg || '登录失败'); reject(err); }); diff --git a/utils/user.js b/utils/user.js index 73b4ccc..b478e8e 100644 --- a/utils/user.js +++ b/utils/user.js @@ -77,8 +77,8 @@ export const wxWorkLogin = () => { success(response) { if (response.code) { const params = { - client: SIGN_IN_CLIENTS['mp'], - type: SIGN_IN_TYPES['mp'], + client: SIGN_IN_CLIENTS['wx_work'], + type: SIGN_IN_TYPES['wx_work'], data: { identifier: response.code, credential: 'health' }, redirect: 'https://test.tall.wiki/gateway/health/initMsg', }; @@ -99,6 +99,7 @@ export const wxWorkLogin = () => { export const mpLogin = () => { try { const res = uni.getSystemInfoSync(); + console.log('res.environment: ', res.environment); if (res.environment === 'wxwork') { return wxWorkLogin(); } else {