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. 16
      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 {
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']),
/**
* 查询个人信息

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

@ -2,7 +2,7 @@
<map
:latitude="latitude"
:longitude="longitude"
:markers="covers"
:markers="markers"
:polygons="polygons"
:polyline="polyline"
id="map"
@ -14,67 +14,15 @@
<script>
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,
},
],
};
},

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 SITES_INFO = `${sites}/siteInfo`;
// 扫码统计
export const SCHOOL_SIGNS = `${sites}/statistics`;

3
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,
};

5
manifest.json

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

18
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",

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({
onlyFromCamera: true,
success: res => {
console.log('res: ', res);
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
},

31
pages/sign/sign.vue

@ -4,7 +4,7 @@
<view class="text-xxl padding text-center margin-top-xl">
<text class="text-black text-bold">{{ address }}</text>
</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>
<view class="success" v-else>
<view class="cuIcon-roundcheckfill text-green"></view>
@ -15,6 +15,7 @@
</template>
<script>
import { mapActions } from 'vuex';
import { formatQuery } from 'utils/util';
import { SCAN_SIGN } from 'api/api';
@ -25,23 +26,31 @@ export default {
address: '图书馆',
siteId: '',
siteName: '',
success: true,
success: false,
type: 0, // 0 / 1
};
},
computed: {
typeText() {
return this.type === 0 ? '进场打卡' : '出场打卡';
},
},
onLoad(options) {
try {
console.log('options: ', options);
const query = formatQuery(decodeURIComponent(options.scene));
const { siteId, siteName } = query;
this.siteId = query.siteId;
this.siteName = query.siteName;
console.log('query: ', query);
const { d, t } = query;
this.siteId = d;
this.type = +t;
} catch (error) {
console.log('error: ', error);
}
},
methods: {
...mapActions('site', ['sign']),
/**
* 扫码打卡
* @param {string} siteId 场所id
@ -50,18 +59,10 @@ export default {
try {
console.log('打卡');
const params = { param: { siteId } };
const res = await this.$http.post(SCAN_SIGN, params);
const { success, code, msg, data } = res.data;
if (success && code === 200) {
await this.sign(params);
this.success = true;
} else {
uni.showToast({ title: msg || '打卡失败', icon: 'none' });
}
} catch (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) {
const { before, after } = value.range;
//
//
if (before && !after) {
this.start = before;
this.end = before;
} else if (!before && after) {
this.end = after;
this.start = after;
} else if (before && after) {
this.start = before;
this.end = after;
}
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="data-wrap">
<view class="data-item">
<view class="data-text text-green">100</view>
<view class="data-title">正常</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 :key="index" class="data-item" v-for="(item, index) in shoolSignNumber">
<view :class="[generateColor(item.name)]" class="data-text">{{ item.number }}</view>
<view class="data-title">{{ item.name }}</view>
</view>
</view>
</view>
@ -33,15 +21,41 @@
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'HealthData',
data() {
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>

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

@ -11,21 +11,46 @@
<view class="card-content">
<view class="map-wrap">
<history-map />
<history-map :markers="markers" />
</view>
</view>
</view>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'LocationMap',
data() {
return {};
},
onLoad() {},
computed: {
...mapState('statistics', ['schoolSigns']),
methods: {},
//
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);
});
return result;
},
},
};
</script>

16
pages/statistics/statistics.vue

@ -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);

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

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

10
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;
},
};

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

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

5
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 {

Loading…
Cancel
Save