diff --git a/App.vue b/App.vue index e429760..a0bfe21 100644 --- a/App.vue +++ b/App.vue @@ -4,8 +4,20 @@ import { GET_USER_INFO } from 'api/api'; export default { async onLaunch() { + uni.getSetting({ + success(res) { + if (!res.authSetting['scope.userLocation']) { + uni.authorize({ + scope: 'scope.userLocation', + success() {}, + }); + } + }, + }); + await this.login(); await this.getUserInfo(); + this.getSites(); }, computed: mapState('user', ['token']), @@ -13,6 +25,8 @@ export default { methods: { ...mapMutations('user', ['setUserInfo','setHealthCode']), ...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/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 6d6d4e8..c2bccb0 100644 --- a/pages.json +++ b/pages.json @@ -6,6 +6,11 @@ "navigationBarTitleText": "山大健康码" } }, + { + "path": "pages/statistics/statistics", + "style": { "navigationBarTitleText": "统计" } + }, + { "path": "pages/my-signs/my-signs", "style": { "navigationBarTitleText": "我的校园打卡" } @@ -41,10 +46,6 @@ "navigationBarTitleText": "申请健康码" } }, - { - "path": "pages/statistics/statistics", - "style": { "navigationBarTitleText": "统计" } - }, { "path": "pages/my-code/my-code", "style": { @@ -57,6 +58,14 @@ "navigationBarTitleText": "我的行程" } }, + { + "path": "pages/healthy-card/healthy-card", + "style": {} + }, + { + "path": "pages/user-code/user-code", + "style": {} + }, { "path": "pages/service-agreement/service-agreement", "style": { @@ -69,6 +78,7 @@ "navigationBarTitleText": "隐私政策" } } + ], "globalStyle": { "navigationBarTextStyle": "black", 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..f678f61 100644 --- a/pages/sign/sign.vue +++ b/pages/sign/sign.vue @@ -4,7 +4,7 @@ {{ address }} - + @@ -15,6 +15,7 @@ diff --git a/pages/statistics/components/location-map.vue b/pages/statistics/components/location-map.vue index 5f87024..5fc36c1 100644 --- a/pages/statistics/components/location-map.vue +++ b/pages/statistics/components/location-map.vue @@ -11,21 +11,46 @@ - + 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 @@ + + + + + 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 dd8489d..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 || []; }, /** @@ -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..dee34b3 100644 --- a/store/modules/statistics/state.js +++ b/store/modules/statistics/state.js @@ -1,7 +1,12 @@ const state = { userSigns: [], // 用户个人打卡记录 - shoolSigns: [], // 校园的打卡记录 - shoolSignNumber: [], // 健康上报数目统计 + schoolSigns: [], // 校园的打卡记录 + shoolSignNumber: [ + { name: '正常', number: '-' }, + { name: '发烧', number: '-' }, + { name: '其他', number: '-' }, + { name: '未上报', number: '-' }, + ], // 健康上报数目统计 }; export default state; diff --git a/store/modules/user/actions.js b/store/modules/user/actions.js index 19dea1b..7897c3d 100644 --- a/store/modules/user/actions.js +++ b/store/modules/user/actions.js @@ -10,12 +10,14 @@ 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 {