From 876282e88375190f8b3787ad095034765f2db1e5 Mon Sep 17 00:00:00 2001 From: yanyan Date: Tue, 30 Jan 2024 12:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 3 +- pages.json | 32 +++++++++-- pages/my/my.vue | 16 ++---- store/user.js | 8 +++ subpkg/address/address.vue | 108 ++++++++++++++++++++++--------------- subpkg/login/login.vue | 3 +- 6 files changed, 111 insertions(+), 59 deletions(-) diff --git a/manifest.json b/manifest.json index 258d91b..ae694fb 100644 --- a/manifest.json +++ b/manifest.json @@ -54,7 +54,8 @@ "setting" : { "urlCheck" : false }, - "usingComponents" : true + "usingComponents" : true, + "requiredPrivateInfos": ["getLocation","onLocationChange","chooseLocation", "chooseAddress"] }, "vueVersion" : "2" } diff --git a/pages.json b/pages.json index 4072099..e23f2ac 100644 --- a/pages.json +++ b/pages.json @@ -17,7 +17,7 @@ "path": "pages/my/my", "style": { "navigationBarTitleText": "全民演练", - "enablePullDownRefresh": false, + "enablePullDownRefresh": true, "navigationStyle": "custom" } }, @@ -25,7 +25,7 @@ "path": "pages/knowledge/knowledge", "style": { "navigationBarTitleText": "全民演练", - "enablePullDownRefresh": false + "enablePullDownRefresh": true } } ], @@ -36,7 +36,7 @@ "style": { "navigationBarTitleText": "场景演练", "navigationBarTextStyle": "black", - "enablePullDownRefresh": false + "enablePullDownRefresh": true } }, { @@ -60,16 +60,40 @@ "style" : { "navigationBarTitleText" : "", - "enablePullDownRefresh" : false + "enablePullDownRefresh" : true } }, { "path" : "medal/medal", "style" : + { + "navigationBarTitleText" : "", + "enablePullDownRefresh" : true + } + }, + { + "path" : "about/about", + "style" : + { + "navigationBarTitleText" : "", + "enablePullDownRefresh" : false + } + }, + { + "path" : "agreement/agreement", + "style" : { "navigationBarTitleText" : "", "enablePullDownRefresh" : false } + }, + { + "path" : "privacy/privacy", + "style" : + { + "navigationBarTitleText" : "", + "enablePullDownRefresh" : true + } }] }], "globalStyle": { diff --git a/pages/my/my.vue b/pages/my/my.vue index b2de105..3509aa1 100644 --- a/pages/my/my.vue +++ b/pages/my/my.vue @@ -140,17 +140,11 @@ }) }, navClickHandler(item) { - //this.about(); - uni.navigateTo({ - url:'/subpkg/addressNew/addressNew' - }) - }, - about() { - uni.showModal({ - title: '关于', - content: '本程序后端使用Ruoyi实现,仅供学习使用,请勿使用于商业用途,如有问题,请联系QQ:123456', - showCancel: false - }) + if(item !== ""){ + uni.navigateTo({ + url: item.pagePath + }) + } } }, components: { diff --git a/store/user.js b/store/user.js index f82e50e..45680cd 100755 --- a/store/user.js +++ b/store/user.js @@ -5,6 +5,7 @@ export default { // 数据 state: () => ({ address: JSON.parse(uni.getStorageSync('address') || '{}'), + userId: uni.getStorageSync('userId') || '', token: uni.getStorageSync('token') || '', // 用户的信息对象 userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}'), @@ -36,9 +37,16 @@ export default { state.token = token this.commit('m_user/saveTokenToStorage') }, + updateUserId(state, userId) { + state.userId = userId + this.commit('m_user/saveUserIdToStorage') + }, saveTokenToStorage(state) { uni.setStorageSync('token', state.token) }, + saveUserIdToStorage(state) { + uni.setStorageSync('userId', state.userId) + }, updateRedirectInfo(state, info) { state.redirectInfo = info console.log(state.redirectInfo) diff --git a/subpkg/address/address.vue b/subpkg/address/address.vue index b605d50..44c7f1b 100644 --- a/subpkg/address/address.vue +++ b/subpkg/address/address.vue @@ -1,52 +1,54 @@ - - @@ -57,17 +59,39 @@ export default { data() { return { - address: {}, - addressList:[{"goods_name":"111"}] + addressList:[] }; }, + onLoad() { + this.initAddress(); + }, methods: { ...mapMutations('m_user', ['updateAddress']), + async initAddress(){ + const { + data: res + } = await uni.$http.post('/small/project/address/listAll',{userId:this.userId}) + if (!res.success) return uni.$showMsg() + this.addressList = res.data; + }, async chooseAddress() { const [err, succ] = await uni.chooseAddress().catch(err => err) if (err === null && succ.errMsg === 'chooseAddress:ok') { - // this.address = succ this.updateAddress(succ) + + const addressObj = { + userId: this.userId, + name: succ.userName, + mobile: succ.telNumber, + address: succ.provinceName + succ.cityName + succ.countyName + succ.detailInfo + } + this.addressList.push(addressObj) + + const { + data: res + } = await uni.$http.post('/small/project/address/add',addressObj) + if (!res.success) return uni.$showMsg() + this.initAddress(); } if (err && (err.errMsg === 'chooseAddress:fail auth deny' || err.errMsg === 'chooseAddress:fail authorize no response')) { @@ -97,7 +121,7 @@ } }, computed: { - ...mapState('m_user', ['address']), + ...mapState('m_user', ['address','userId']), ...mapGetters('m_user', ['addstr']) } } diff --git a/subpkg/login/login.vue b/subpkg/login/login.vue index 810f333..285343c 100644 --- a/subpkg/login/login.vue +++ b/subpkg/login/login.vue @@ -19,7 +19,7 @@ ...mapState('m_user', ['redirectInfo']) }, methods:{ - ...mapMutations('m_user', ['updateUserInfo', 'updateToken', 'updateRedirectInfo']), + ...mapMutations('m_user', ['updateUserInfo', 'updateToken', 'updateUserId', 'updateRedirectInfo']), getUserInfo(e) { console.log(e) @@ -56,6 +56,7 @@ // 直接把 token 保存到 vuex 中 this.updateToken(loginResult.token) + this.updateUserId(loginResult.userId) uni.switchTab({ url: '/pages/index/index' })