From d38d3d293bfc81e7eda8b5210d43cdc7da5b02b0 Mon Sep 17 00:00:00 2001 From: songsong428 Date: Sat, 7 Mar 2020 20:11:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 50 ++++++++++++++- components/user-agreement/user-agreement.vue | 57 +++++++++++++++++ main.js | 7 +- pages.json | 19 ++++-- pages/basic-info/basic-info.vue | 64 +++++++++++++------ pages/my-code/my-code.vue | 14 ++++ pages/privacy-aolicy/privacy-aolicy.vue | 13 ++++ pages/service-agreement/service-agreement.vue | 13 ++++ store/modules/user/actions.js | 1 + store/modules/user/mutations.js | 9 +++ store/modules/user/state.js | 1 + 11 files changed, 220 insertions(+), 28 deletions(-) create mode 100644 components/user-agreement/user-agreement.vue create mode 100644 pages/privacy-aolicy/privacy-aolicy.vue create mode 100644 pages/service-agreement/service-agreement.vue diff --git a/App.vue b/App.vue index 02c7786..e429760 100644 --- a/App.vue +++ b/App.vue @@ -1,13 +1,61 @@ diff --git a/components/user-agreement/user-agreement.vue b/components/user-agreement/user-agreement.vue new file mode 100644 index 0000000..d1f8803 --- /dev/null +++ b/components/user-agreement/user-agreement.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/main.js b/main.js index 484f4dc..c057a91 100644 --- a/main.js +++ b/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'; diff --git a/pages.json b/pages.json index e19261a..6d6d4e8 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": { @@ -63,6 +56,18 @@ "style": { "navigationBarTitleText": "我的行程" } + }, + { + "path": "pages/service-agreement/service-agreement", + "style": { + "navigationBarTitleText": "服务协议" + } + }, + { + "path": "pages/privacy-aolicy/privacy-aolicy", + "style": { + "navigationBarTitleText": "隐私政策" + } } ], "globalStyle": { diff --git a/pages/basic-info/basic-info.vue b/pages/basic-info/basic-info.vue index a9dacc4..76aa106 100644 --- a/pages/basic-info/basic-info.vue +++ b/pages/basic-info/basic-info.vue @@ -2,20 +2,20 @@
- *姓名 - + *姓名 + - *身份证 - + *身份证 + - *联系方式 - + *联系方式 + - *身份 - + *身份 + + - *学号 - + *学号 +
- + +
@@ -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; }, diff --git a/pages/my-code/my-code.vue b/pages/my-code/my-code.vue index aaf6c74..8829c78 100644 --- a/pages/my-code/my-code.vue +++ b/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']), }, }; diff --git a/pages/privacy-aolicy/privacy-aolicy.vue b/pages/privacy-aolicy/privacy-aolicy.vue new file mode 100644 index 0000000..8be5f93 --- /dev/null +++ b/pages/privacy-aolicy/privacy-aolicy.vue @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/pages/service-agreement/service-agreement.vue b/pages/service-agreement/service-agreement.vue new file mode 100644 index 0000000..9742d4e --- /dev/null +++ b/pages/service-agreement/service-agreement.vue @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/store/modules/user/actions.js b/store/modules/user/actions.js index 8f216c2..19dea1b 100644 --- a/store/modules/user/actions.js +++ b/store/modules/user/actions.js @@ -12,6 +12,7 @@ const actions = { .then(data => { commit('setToken', data.token); commit('setUser', data); + resolve(data); }) .catch(err => { diff --git a/store/modules/user/mutations.js b/store/modules/user/mutations.js index ec63bcb..f813762 100644 --- a/store/modules/user/mutations.js +++ b/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; diff --git a/store/modules/user/state.js b/store/modules/user/state.js index 6fe77e4..b669219 100644 --- a/store/modules/user/state.js +++ b/store/modules/user/state.js @@ -2,6 +2,7 @@ const state = { token: '', user: null, healthCode: '', // 健康码 + userInfo: '', // 个人基本信息 }; export default state;