Browse Source

用户协议

remotes/origin/HEAD
songsong428 5 years ago
parent
commit
d38d3d293b
  1. 50
      App.vue
  2. 57
      components/user-agreement/user-agreement.vue
  3. 7
      main.js
  4. 19
      pages.json
  5. 64
      pages/basic-info/basic-info.vue
  6. 14
      pages/my-code/my-code.vue
  7. 13
      pages/privacy-aolicy/privacy-aolicy.vue
  8. 13
      pages/service-agreement/service-agreement.vue
  9. 1
      store/modules/user/actions.js
  10. 9
      store/modules/user/mutations.js
  11. 1
      store/modules/user/state.js

50
App.vue

@ -1,13 +1,61 @@
<script>
import { mapActions } from 'vuex';
import { mapState, mapMutations, mapActions } from 'vuex';
import { GET_USER_INFO } from 'api/api';
export default {
async onLaunch() {
await this.login();
await this.getUserInfo();
},
computed: mapState('user', ['token']),
methods: {
...mapMutations('user', ['setUserInfo','setHealthCode']),
...mapActions('user', ['login']),
/**
* 查询个人信息
*/
async getUserInfo() {
try {
const { token } = this;
const params = {
param: {
token
}
};
const res = await this.$http.post(GET_USER_INFO, params);
const {
success,
code,
msg,
data
} = res.data;
if (success && code === 200) {
this.setUserInfo(data);
if(data.healthCodeList && data.healthCodeList.length>0){
const oldCode = data.healthCodeList[0].healthCode;
this.setHealthCode(oldCode)
}
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'
});
}
}
},
},
};
</script>

57
components/user-agreement/user-agreement.vue

@ -0,0 +1,57 @@
<template>
<view class="margin flex flex-wrap">
<view @click="changeIntentions" class="iconfont agree-box" :class="[agree ? 'text-blue icon-check-square': 'text-gray icon-border']"></view>
<view class="text-df text-black flex-sub agree-text">
请认真阅读
<text class="text-blue" @tap="serviceAgreement">用户服务协议</text>
<text class="text-blue" @tap="privacyAolicy">隐私政策</text>,
勾选代表您已同意此协议
</view>
</view>
</template>
<script>
export default {
data() {
return {
agree: false,
};
},
onLoad(op) {},
methods: {
changeIntentions(){
if(!this.agree){
this.agree = true;
}else{
this.agree = false;
}
this.$emit('changeIntentions',this.agree)
},
//
serviceAgreement(){
uni.navigateTo({
url: '/pages/service-agreement/service-agreement',
});
},
//
privacyAolicy(){
uni.navigateTo({
url: '/pages/privacy-aolicy/privacy-aolicy',
});
}
},
};
</script>
<style lang="scss" scoped>
.agree-box {
width: 70rpx;
}
.agree-text {
line-height: 60rpx;
}
</style>

7
main.js

@ -22,8 +22,11 @@ Vue.prototype.goHome = () => {
* @param {string} query 参数字符串a=x&b=y
*/
Vue.prototype.openPage = function(path, query = '') {
let url = query ? `${path}?${query}` : path;
uni.navigateTo({ url });
let url = query ? `${path}?${query}` : path;
if(!store.state.user.userInfo) {
url = '/pages/basic-info/basic-info';
}
uni.navigateTo({ url });
};
App.mpType = 'app';

19
pages.json

@ -1,12 +1,5 @@
{
"pages": [
// {
// "path": "pages/my-code/my-code",
// "style": {
// "navigationBarTitleText": "我的健康打卡"
// }
// },
{
"path": "pages/index/index",
"style": {
@ -63,6 +56,18 @@
"style": {
"navigationBarTitleText": "我的行程"
}
},
{
"path": "pages/service-agreement/service-agreement",
"style": {
"navigationBarTitleText": "服务协议"
}
},
{
"path": "pages/privacy-aolicy/privacy-aolicy",
"style": {
"navigationBarTitleText": "隐私政策"
}
}
],
"globalStyle": {

64
pages/basic-info/basic-info.vue

@ -2,20 +2,20 @@
<view>
<form class="padding-lr cu-form-group flex-direction">
<view class="cu-form-group flex flex-direction padding-tb">
<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>姓名</view>
<input placeholder="请输入真实姓名" name="input" type="text" v-model="name" />
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>姓名</view>
<input :disabled="userInfo ? true : false" placeholder="请输入真实姓名" name="input" type="text" v-model="name" />
</view>
<view class="cu-form-group flex flex-direction padding-tb">
<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>身份证</view>
<input placeholder="请输入身份证号" name="input" type="text" v-model="idCard" />
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>身份证</view>
<input :disabled="userInfo ? true : false" placeholder="请输入身份证号" name="input" type="text" v-model="idCard" />
</view>
<view class="cu-form-group flex flex-direction padding-tb">
<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>联系方式</view>
<input placeholder="请输入手机号码" name="input" type="number" v-model="phone" />
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>联系方式</view>
<input :disabled="userInfo ? true : false" placeholder="请输入手机号码" name="input" type="number" v-model="phone" />
</view>
<view class="cu-form-group flex flex-direction padding-tb">
<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>身份</view>
<radio-group class="block" @change="RadioChange">
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>身份</view>
<radio-group class="block" @change="RadioChange" v-if="!userInfo">
<view class="flex">
<view class="flex-sub margin-tb-sm" v-for="(identity,index) in identitys" :key="index">
<label class="flex justify-between align-center">
@ -25,13 +25,15 @@
</view>
</view>
</radio-group>
<input v-else disabled name="input" type="text" :value="current === 0 ? '学生' : current === 1 ? '教师' : '工作人员'" />
</view>
<view class="cu-form-group flex flex-direction padding-tb">
<view class="title padding-bottom-sm"><span class="text-red padding-right-xs">*</span>学号</view>
<input placeholder="请输入学号" name="input" type="text" v-model="studentID" />
<view class="title padding-bottom-sm"><span v-show="!userInfo" class="text-red padding-right-xs">*</span>学号</view>
<input :disabled="userInfo ? true : false" placeholder="请输入学号" name="input" type="text" v-model="studentID" />
</view>
</form>
<button class="bg-cyan margin primary-btn" hover-class="cc-active" @tap="handleSubmitUserInfo">确认提交</button>
<user-agreement v-if="!userInfo" @changeIntentions='changeIntentions'></user-agreement>
<button v-show="!userInfo" class="bg-cyan margin primary-btn" hover-class="cc-active" @tap="handleSubmitUserInfo">确认提交</button>
</view>
</template>
@ -42,6 +44,7 @@
import {
SUBMIT_USER_INFO
} from 'api/api';
import { mapState,mapMutations } from 'vuex';
export default {
data() {
@ -63,10 +66,25 @@
},
],
studentID: '',
current: 0
current: 0,
agree: false
};
},
created() {
if(this.userInfo){
this.name = this.userInfo.name;
this.idCard = this.userInfo.idCard;
this.phone = this.userInfo.phone;
this.studentID = this.userInfo.no;
this.current = this.userInfo.post;
}
},
computed: mapState('user', ['userInfo']),
methods: {
...mapMutations('user', ['setUserInfo']),
RadioChange: function(evt) {
for (let i = 0; i < this.identitys.length; i++) {
if (this.identitys[i].value === evt.target.value) {
@ -76,6 +94,10 @@
}
},
changeIntentions(data){
this.agree = data;
},
/**
* 提交基本信息
*/
@ -109,12 +131,14 @@
} = res.data;
if (success && code === 200) {
console.log('data', data)
name = data.name;
idCard = data.idCard;
phone = data.phone;
studentID = data.no;
current = data.post;
this.setUserInfo(data);
// name = data.name;
// idCard = data.idCard;
// phone = data.phone;
// studentID = data.no;
// current = data.post;
this.success = true;
uni.reLaunch({
url: `/pages/apply-code/apply-code`,
});
@ -137,7 +161,7 @@
//
checkRules() {
const { name,idCard,phone,identitys,studentID } = this;
const { name,idCard,phone,identitys,studentID,agree } = this;
if (!name) {
showToast('请输入姓名');
return;
@ -158,6 +182,10 @@
showToast('请输入学号');
return;
}
if(!agree) {
showToast('请选择是否同意《用户服务协议》和《隐私政策》');
return;
}
return true;
},

14
pages/my-code/my-code.vue

@ -37,6 +37,10 @@
import {
showToast
} from 'common/script/util';
import {
SUBMIT_USER_INFO
} from 'api/api';
import { mapState,mapMutations } from 'vuex';
export default {
data() {
@ -77,7 +81,17 @@
],
};
},
created() {
if(this.userInfo){
}
},
computed: mapState('user', ['userInfo']),
methods: {
...mapMutations('user', ['setUserInfo']),
},
};

13
pages/privacy-aolicy/privacy-aolicy.vue

@ -0,0 +1,13 @@
<template>
<web-view :webview-styles="webviewStyles" src="https://www.yuque.com/docs/share/aaa64c6d-225e-4ee3-be6c-b511565c8bd4?#"></web-view>
</template>
<script>
export default {
data() {
return {
url: ''
}
},
}
</script>

13
pages/service-agreement/service-agreement.vue

@ -0,0 +1,13 @@
<template>
<web-view :webview-styles="webviewStyles" :src="url"></web-view>
</template>
<script>
export default {
data() {
return {
url: 'https://www.yuque.com/docs/share/00738d22-45de-46d0-8473-4275ac421fbd?#'
}
},
}
</script>

1
store/modules/user/actions.js

@ -12,6 +12,7 @@ const actions = {
.then(data => {
commit('setToken', data.token);
commit('setUser', data);
resolve(data);
})
.catch(err => {

9
store/modules/user/mutations.js

@ -43,6 +43,15 @@ const mutations = {
setHealthCode(state, data) {
state.healthCode = data;
},
/**
* 设置个人信息 userInfo
* @param {*} state
* @param {string} data
*/
setUserInfo(state, data) {
state.userInfo = data;
},
};
export default mutations;

1
store/modules/user/state.js

@ -2,6 +2,7 @@ const state = {
token: '',
user: null,
healthCode: '', // 健康码
userInfo: '', // 个人基本信息
};
export default state;

Loading…
Cancel
Save