Browse Source

用户协议

remotes/origin/HEAD
songsong428 5 years ago
parent
commit
f661d4aed9
  1. 14
      App.vue
  2. 64
      components/history-map/history-map.vue
  3. 101
      components/school-map/school-map.vue
  4. 3
      config/api/api.js
  5. 3
      config/config.user.js
  6. 5
      manifest.json
  7. 18
      pages.json
  8. 14
      pages/healthy-card/healthy-card.vue
  9. 1
      pages/index/index.vue
  10. 31
      pages/sign/sign.vue
  11. 12
      pages/statistics/components/date-selector.vue
  12. 48
      pages/statistics/components/health-data.vue
  13. 37
      pages/statistics/components/location-map.vue
  14. 18
      pages/statistics/statistics.vue
  15. 25
      pages/user-code/user-code.vue
  16. 3
      store/index.js
  17. 53
      store/modules/site/actions.js
  18. 5
      store/modules/site/index.js
  19. 12
      store/modules/site/mutations.js
  20. 5
      store/modules/site/state.js
  21. 2
      store/modules/statistics/actions.js
  22. 10
      store/modules/statistics/mutations.js
  23. 9
      store/modules/statistics/state.js
  24. 2
      store/modules/user/actions.js
  25. 5
      utils/user.js

14
App.vue

@ -4,8 +4,20 @@ import { GET_USER_INFO } from 'api/api';
export default { export default {
async onLaunch() { async onLaunch() {
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
uni.authorize({
scope: 'scope.userLocation',
success() {},
});
}
},
});
await this.login(); await this.login();
await this.getUserInfo(); await this.getUserInfo();
this.getSites();
}, },
computed: mapState('user', ['token']), computed: mapState('user', ['token']),
@ -13,6 +25,8 @@ export default {
methods: { methods: {
...mapMutations('user', ['setUserInfo','setHealthCode']), ...mapMutations('user', ['setUserInfo','setHealthCode']),
...mapActions('user', ['login']), ...mapActions('user', ['login']),
...mapActions('site', ['getSites']),
/** /**
* 查询个人信息 * 查询个人信息

64
components/history-map/history-map.vue

@ -2,7 +2,7 @@
<map <map
:latitude="latitude" :latitude="latitude"
:longitude="longitude" :longitude="longitude"
:markers="covers" :markers="markers"
:polygons="polygons" :polygons="polygons"
:polyline="polyline" :polyline="polyline"
id="map" id="map"
@ -14,67 +14,15 @@
<script> <script>
export default { export default {
props: {
markers: { type: Array, default: null },
polyline: { type: Array, default: null },
polygons: { type: Array, default: null },
},
data() { data() {
return { return {
latitude: 37.87059, latitude: 37.87059,
longitude: 112.55067, 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,
},
],
}; };
}, },

101
components/school-map/school-map.vue

@ -0,0 +1,101 @@
<template>
<map
:latitude="latitude"
:longitude="longitude"
:markers="covers"
:polygons="polygons"
:polyline="polyline"
id="map"
ref="map"
show-location="true"
style="width: 100%; height: 1000rpx;"
/>
</template>
<script>
export default {
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,
},
],
};
},
onLoad() {
this.getLocation();
},
methods: {
//
// mapgcj02
getLocation() {
uni.getLocation({
type: 'gcj02',
success: res => {
this.longitude = res.longitude;
this.latitude = res.latitude;
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
},
});
},
},
};
</script>

3
config/api/api.js

@ -25,6 +25,9 @@ export const HEALTH_SIGN = `${health}/upload`;
// 查看自己的打卡记录 // 查看自己的打卡记录
export const USER_SIGNS = `${sites}/info`; export const USER_SIGNS = `${sites}/info`;
// 获取所有场景信息
export const SITES_INFO = `${sites}/siteInfo`;
// 扫码统计 // 扫码统计
export const SCHOOL_SIGNS = `${sites}/statistics`; export const SCHOOL_SIGNS = `${sites}/statistics`;

3
config/config.user.js

@ -5,7 +5,7 @@
*/ */
// 用户登录client // 用户登录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 = { export const SIGN_IN_TYPES = {
@ -16,4 +16,5 @@ export const SIGN_IN_TYPES = {
wx: 4, wx: 4,
wx_web: 5, wx_web: 5,
wb: 6, wb: 6,
wx_work: 7,
}; };

5
manifest.json

@ -64,6 +64,11 @@
"postcss" : true, "postcss" : true,
"minified" : true "minified" : true
}, },
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于获取地理位置及地图展示"
}
},
"usingComponents" : true "usingComponents" : true
}, },
"mp-alipay" : { "mp-alipay" : {

18
pages.json

@ -6,6 +6,11 @@
"navigationBarTitleText": "山大健康码" "navigationBarTitleText": "山大健康码"
} }
}, },
{
"path": "pages/statistics/statistics",
"style": { "navigationBarTitleText": "统计" }
},
{ {
"path": "pages/my-signs/my-signs", "path": "pages/my-signs/my-signs",
"style": { "navigationBarTitleText": "我的校园打卡" } "style": { "navigationBarTitleText": "我的校园打卡" }
@ -41,10 +46,6 @@
"navigationBarTitleText": "申请健康码" "navigationBarTitleText": "申请健康码"
} }
}, },
{
"path": "pages/statistics/statistics",
"style": { "navigationBarTitleText": "统计" }
},
{ {
"path": "pages/my-code/my-code", "path": "pages/my-code/my-code",
"style": { "style": {
@ -57,6 +58,14 @@
"navigationBarTitleText": "我的行程" "navigationBarTitleText": "我的行程"
} }
}, },
{
"path": "pages/healthy-card/healthy-card",
"style": {}
},
{
"path": "pages/user-code/user-code",
"style": {}
},
{ {
"path": "pages/service-agreement/service-agreement", "path": "pages/service-agreement/service-agreement",
"style": { "style": {
@ -69,6 +78,7 @@
"navigationBarTitleText": "隐私政策" "navigationBarTitleText": "隐私政策"
} }
} }
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",

14
pages/healthy-card/healthy-card.vue

@ -0,0 +1,14 @@
<template>
<view>扫别人的码</view>
</template>
<script>
export default {
data() {
return {};
},
};
</script>
<style lang="scss">
</style>

1
pages/index/index.vue

@ -36,6 +36,7 @@ export default {
uni.scanCode({ uni.scanCode({
onlyFromCamera: true, onlyFromCamera: true,
success: res => { success: res => {
console.log('res: ', res);
console.log('条码类型:' + res.scanType); console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result); console.log('条码内容:' + res.result);
}, },

31
pages/sign/sign.vue

@ -4,7 +4,7 @@
<view class="text-xxl padding text-center margin-top-xl"> <view class="text-xxl padding text-center margin-top-xl">
<text class="text-black text-bold">{{ address }}</text> <text class="text-black text-bold">{{ address }}</text>
</view> </view>
<button @tap="handleSign" class="cu-btn lg bg-purple margin sign-btn">打卡</button> <button @tap="handleSign(siteId)" class="cu-btn lg bg-purple margin sign-btn">{{ typeText }}</button>
</template> </template>
<view class="success" v-else> <view class="success" v-else>
<view class="cuIcon-roundcheckfill text-green"></view> <view class="cuIcon-roundcheckfill text-green"></view>
@ -15,6 +15,7 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex';
import { formatQuery } from 'utils/util'; import { formatQuery } from 'utils/util';
import { SCAN_SIGN } from 'api/api'; import { SCAN_SIGN } from 'api/api';
@ -25,23 +26,31 @@ export default {
address: '图书馆', address: '图书馆',
siteId: '', siteId: '',
siteName: '', siteName: '',
success: true, success: false,
type: 0, // 0 / 1
}; };
}, },
computed: {
typeText() {
return this.type === 0 ? '进场打卡' : '出场打卡';
},
},
onLoad(options) { onLoad(options) {
try { try {
console.log('options: ', options);
const query = formatQuery(decodeURIComponent(options.scene)); const query = formatQuery(decodeURIComponent(options.scene));
const { siteId, siteName } = query; console.log('query: ', query);
this.siteId = query.siteId; const { d, t } = query;
this.siteName = query.siteName; this.siteId = d;
this.type = +t;
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);
} }
}, },
methods: { methods: {
...mapActions('site', ['sign']),
/** /**
* 扫码打卡 * 扫码打卡
* @param {string} siteId 场所id * @param {string} siteId 场所id
@ -50,18 +59,10 @@ export default {
try { try {
console.log('打卡'); console.log('打卡');
const params = { param: { siteId } }; const params = { param: { siteId } };
const res = await this.$http.post(SCAN_SIGN, params); await this.sign(params);
const { success, code, msg, data } = res.data;
if (success && code === 200) {
this.success = true; this.success = true;
} else {
uni.showToast({ title: msg || '打卡失败', icon: 'none' });
}
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);
if (error.msg) {
uni.showToast({ title: error.msg || '打卡失败', icon: 'none' });
}
} }
}, },
}, },

12
pages/statistics/components/date-selector.vue

@ -58,10 +58,20 @@ export default {
*/ */
handleChange(value) { handleChange(value) {
const { before, after } = value.range; const { before, after } = value.range;
//
//
if (before && !after) {
this.start = before; this.start = before;
this.end = before;
} else if (!before && after) {
this.end = after; this.end = after;
this.start = after;
} else if (before && after) {
this.start = before;
this.end = after;
}
this.menu = ''; this.menu = '';
this.$emit('change', before, after); this.$emit('change', this.start, this.end);
}, },
/** /**

48
pages/statistics/components/health-data.vue

@ -11,21 +11,9 @@
<view class="card-content"> <view class="card-content">
<view class="data-wrap"> <view class="data-wrap">
<view class="data-item"> <view :key="index" class="data-item" v-for="(item, index) in shoolSignNumber">
<view class="data-text text-green">100</view> <view :class="[generateColor(item.name)]" class="data-text">{{ item.number }}</view>
<view class="data-title">正常</view> <view class="data-title">{{ item.name }}</view>
</view>
<view class="data-item">
<view class="data-text text-red">9</view>
<view class="data-title">发烧</view>
</view>
<view class="data-item">
<view class="data-text text-purple">10</view>
<view class="data-title">其他</view>
</view>
<view class="data-item">
<view class="data-text text-orange">50</view>
<view class="data-title">未上报</view>
</view> </view>
</view> </view>
</view> </view>
@ -33,15 +21,41 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex';
export default { export default {
name: 'HealthData', name: 'HealthData',
data() { data() {
return {}; return {};
}, },
onLoad() {}, computed: mapState('statistics', ['shoolSignNumber']),
methods: {}, methods: {
/**
* 生成文本的颜色
* @param {string} name 类目名称
* @returns {string} color 颜色string
*/
generateColor(name) {
let color = 'text-green';
switch (name) {
case '发烧':
color = 'text-red';
break;
case '其他':
color = 'text-purple';
break;
case '未上报':
color = 'text-orange';
break;
default:
color = 'text-green';
break;
}
return color;
},
},
}; };
</script> </script>

37
pages/statistics/components/location-map.vue

@ -11,21 +11,46 @@
<view class="card-content"> <view class="card-content">
<view class="map-wrap"> <view class="map-wrap">
<history-map /> <history-map :markers="markers" />
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { mapState } from 'vuex';
export default { export default {
name: 'LocationMap', name: 'LocationMap',
data() {
return {};
},
onLoad() {}, computed: {
...mapState('statistics', ['schoolSigns']),
//
markers() {
if (!this.schoolSigns) return null;
const result = [];
this.schoolSigns.forEach(item => {
const content = `${item.siteName}\n${item.number}`;
const obj = {
latitude: item.latitude,
longitude: item.longitude,
iconPath: '/static/location.png',
callout: {
content,
display: 'ALWAYS',
color: '#fff',
padding: 4,
bgColor: '#0A97C6',
borderRadius: 2,
textAlign: 'center',
},
};
result.push(obj);
});
methods: {}, return result;
},
},
}; };
</script> </script>

18
pages/statistics/statistics.vue

@ -43,7 +43,7 @@ export default {
this.$moment(end) this.$moment(end)
.endOf('day') .endOf('day')
.format('x') - 0; .format('x') - 0;
console.log('startTime,endTime: ', startTime, endTime); console.log('startTime, endTime: ', startTime, endTime);
// //
this.getSchoolSignsData(startTime, endTime); this.getSchoolSignsData(startTime, endTime);
// //
@ -52,12 +52,12 @@ export default {
/** /**
* 获取校园打卡的数据 * 获取校园打卡的数据
* @param {number} start 开始时间 * @param {number} startTime 开始时间
* @param {number} end 截止时间 * @param {number} endTime 截止时间
*/ */
getSchoolSignsData(start, end) { getSchoolSignsData(startTime, endTime) {
try { try {
const params = { param: { start, end } }; const params = { param: { startTime, endTime } };
this.getSchoolSigns(params); this.getSchoolSigns(params);
} catch (error) { } catch (error) {
console.log('getSchoolSignsData error: ', error); console.log('getSchoolSignsData error: ', error);
@ -66,12 +66,12 @@ export default {
/** /**
* 获取健康上报的数目数据 * 获取健康上报的数目数据
* @param {number} start 开始时间 * @param {number} startTime 开始时间
* @param {number} end 截止时间 * @param {number} endTime 截止时间
*/ */
getSchoolSignsNumberData(start, end) { getSchoolSignsNumberData(startTime, endTime) {
try { try {
const params = { param: { start, end } }; const params = { param: { startTime, endTime } };
this.getSchoolSignsNumber(params); this.getSchoolSignsNumber(params);
} catch (error) { } catch (error) {
console.log('getSchoolSignsNumberData error: ', error); console.log('getSchoolSignsNumberData error: ', error);

25
pages/user-code/user-code.vue

@ -0,0 +1,25 @@
<template>
<view>扫了别人的码 看其健康状态</view>
</template>
<script>
import { formatQuery } from 'utils/util';
export default {
data() {
return {};
},
onLoad(options) {
try {
const query = formatQuery(decodeURIComponent(options.scene));
console.log('query: ', query);
} catch (error) {
console.log('error: ', error);
}
},
};
</script>
<style lang="scss">
</style>

3
store/index.js

@ -1,11 +1,12 @@
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import user from './modules/user/index'; import user from './modules/user/index';
import site from './modules/site/index';
import statistics from './modules/statistics/index'; import statistics from './modules/statistics/index';
Vue.use(Vuex); Vue.use(Vuex);
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { user, statistics }, modules: { user, site, statistics },
}); });
export default store; export default store;

53
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;

5
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 };

12
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;

5
store/modules/site/state.js

@ -0,0 +1,5 @@
const state = {
sites: [], // 所有的场所信息
};
export default state;

2
store/modules/statistics/actions.js

@ -64,11 +64,13 @@ const actions = {
http http
.post(HEALTH_TYPE_STATISTICS, params) .post(HEALTH_TYPE_STATISTICS, params)
.then(res => { .then(res => {
hideLoading();
const { data } = res.data; const { data } = res.data;
commit('setShoolSignNumber', data); commit('setShoolSignNumber', data);
resolve(data); resolve(data);
}) })
.catch(data => { .catch(data => {
hideLoading();
showToast(data.msg || '获取健康上报数据失败'); showToast(data.msg || '获取健康上报数据失败');
reject(data); reject(data);
}); });

10
store/modules/statistics/mutations.js

@ -14,7 +14,7 @@ const mutations = {
* @param {array} data * @param {array} data
*/ */
setSchoolSigns(state, data) { setSchoolSigns(state, data) {
state.shoolSigns = data || []; state.schoolSigns = data || [];
}, },
/** /**
@ -23,7 +23,13 @@ const mutations = {
* @param {array} data * @param {array} data
*/ */
setShoolSignNumber(state, data) { setShoolSignNumber(state, data) {
state.shoolSignNumber = data || []; const arr = [
{ name: '正常', number: '-' },
{ name: '发烧', number: '-' },
{ name: '其他', number: '-' },
{ name: '未上报', number: '-' },
];
state.shoolSignNumber = data || arr;
}, },
}; };

9
store/modules/statistics/state.js

@ -1,7 +1,12 @@
const state = { const state = {
userSigns: [], // 用户个人打卡记录 userSigns: [], // 用户个人打卡记录
shoolSigns: [], // 校园的打卡记录 schoolSigns: [], // 校园的打卡记录
shoolSignNumber: [], // 健康上报数目统计 shoolSignNumber: [
{ name: '正常', number: '-' },
{ name: '发烧', number: '-' },
{ name: '其他', number: '-' },
{ name: '未上报', number: '-' },
], // 健康上报数目统计
}; };
export default state; export default state;

2
store/modules/user/actions.js

@ -10,12 +10,14 @@ const actions = {
mpLogin() mpLogin()
.then(params => signIn(params)) .then(params => signIn(params))
.then(data => { .then(data => {
console.log('login data: ', data);
commit('setToken', data.token); commit('setToken', data.token);
commit('setUser', data); commit('setUser', data);
resolve(data); resolve(data);
}) })
.catch(err => { .catch(err => {
console.log('login err: ', err);
// showModal(err.msg || '登录失败'); // showModal(err.msg || '登录失败');
reject(err); reject(err);
}); });

5
utils/user.js

@ -77,8 +77,8 @@ export const wxWorkLogin = () => {
success(response) { success(response) {
if (response.code) { if (response.code) {
const params = { const params = {
client: SIGN_IN_CLIENTS['mp'], client: SIGN_IN_CLIENTS['wx_work'],
type: SIGN_IN_TYPES['mp'], type: SIGN_IN_TYPES['wx_work'],
data: { identifier: response.code, credential: 'health' }, data: { identifier: response.code, credential: 'health' },
redirect: 'https://test.tall.wiki/gateway/health/initMsg', redirect: 'https://test.tall.wiki/gateway/health/initMsg',
}; };
@ -99,6 +99,7 @@ export const wxWorkLogin = () => {
export const mpLogin = () => { export const mpLogin = () => {
try { try {
const res = uni.getSystemInfoSync(); const res = uni.getSystemInfoSync();
console.log('res.environment: ', res.environment);
if (res.environment === 'wxwork') { if (res.environment === 'wxwork') {
return wxWorkLogin(); return wxWorkLogin();
} else { } else {

Loading…
Cancel
Save