From dd1cefc0981b81a35b6f483f9049691928473ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=BF=94=E5=AE=87-=E6=97=85=E7=AE=A1=E5=AE=B6?= <153298343@qq.com> Date: Fri, 13 May 2022 16:40:20 +0800 Subject: [PATCH] up --- App.vue | 8 +-- pages/index/index.vue | 127 +++++++++++++++++++++++++++++++------- pages/map/map.vue | 49 ++++++++++----- pages/mine/index.vue | 64 +++++++++++++++++-- pages/success/success.vue | 34 ++++++++-- pages/visit/book.vue | 7 +++ utils/util.js | 30 +++++++-- 7 files changed, 259 insertions(+), 60 deletions(-) diff --git a/App.vue b/App.vue index bfded51..2d3bd07 100644 --- a/App.vue +++ b/App.vue @@ -1,16 +1,16 @@ + - diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 5d7f471..e528213 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -12,14 +12,14 @@ - + @@ -68,6 +68,17 @@ + + + + + 请授权您的微信头像和昵称 + + + 微信用户一键登录 + + + @@ -75,16 +86,59 @@ export default { data() { return { - topimg: "" + topimg: "", + info: {}, + showAuthorization: false } }, onReady() { this.topimg = this.util.HOST + "/top_bg.png"; }, - onLoad() { + onShow() { + var that = this; + this.loadInfo(function(res) { + if (that.util.isNull(res.headimgurl) || that.util.isNull(res.nickname)) { + that.showAuthorization = true; + } else { + that.showAuthorization = false; + } + }); }, methods: { + closeInfo() { + that.showAuthorization = false; + }, + loadInfo(cb) { + var that = this; + this.util.getOpenidInfo(function(res) { + that.util.getUserInfo(function(r) { + cb(r); + }, true) + }, true); + + }, + getUserProfile() { + var that = this; + this.util.getUserProfile((res) => { + console.log(res) + that.util.request({ + api: '/api/mobile/user/save', + method: 'POST', + data: { + headimgurl: res.avatarUrl, + nickname: res.nickName + }, + utilSuccess: function(r) { + that.loadInfo(function() { + that.showAuthorization = false; + + }) + } + + }) + }) + }, toPage(type) { var url = ""; switch (type) { diff --git a/pages/success/success.vue b/pages/success/success.vue index 625b6c6..5fee8ee 100644 --- a/pages/success/success.vue +++ b/pages/success/success.vue @@ -4,9 +4,9 @@ 您已经预约成功 - + 即将跳转到{{tips}} - 返回首页 + 返回首页 @@ -14,11 +14,37 @@ export default { data() { return { + tips: "参观预约" + } + }, + onLoad(options) { + if (options.from && options.id) { + var url = ""; + if (options.from == "visit") { + this.tips = "参观预约"; + url = "/pages/order/visitorderinfo?id=" + options.id + } else if (options.from == "activity") { + this.tips = "活动预约"; + url = "/pages/order/activityorderinfo?id=" + options.id + } else if (options.from == "park") { + this.tips = "车位预约"; + url = "/pages/order/parkorderinfo?id=" + options.id + } + setTimeout(function() { + uni.navigateTo({ + url: url + }) + }, 5000) } + }, methods: { - + goHome() { + uni.switchTab({ + url: "/pages/index/index" + }) + } } } @@ -29,7 +55,7 @@ display: flex; flex-direction: column; align-items: center; - justify-content: center; + justify-content: center; padding-top: 90px; } diff --git a/pages/visit/book.vue b/pages/visit/book.vue index 2a184c0..050ae4b 100644 --- a/pages/visit/book.vue +++ b/pages/visit/book.vue @@ -276,6 +276,7 @@ currentIndex: 0, listCalendar: [], type: "user", + user: {}, cardList: [{ idx: 1, name: '身份证' @@ -307,6 +308,11 @@ uni.setNavigationBarTitle({ title: (options.from == 'user' ? "个人预约" : "团队预约") }) + var that = this; + that.util.getUserInfo(function(r) { + that.user = r; + that.form.mobile = r.mobile; + }, true) }, methods: { closeInfo() { @@ -392,6 +398,7 @@ method: "POST", data: this.form, utilSuccess: function(res) { + console.log(res) uni.showToast({ icon: "none", title: "下单成功", diff --git a/utils/util.js b/utils/util.js index b5c7685..eafe1e9 100755 --- a/utils/util.js +++ b/utils/util.js @@ -15,7 +15,28 @@ const formatTime = date => { return [year, month, day].map(formatNumber).join('-'); }; -const user_info_key = "userInfo"; +const user_info_key = "userInfo_token"; +const user_key = "userInfo"; + +const getUserInfo = (cb, refresh) => { + cb = cb || function() {} + refresh = refresh || false + if (!refresh) { + let user_info = uni.getStorageSync(user_key) + if (!isNull(user_info)) { + cb(user_info) + return + } + } + request({ + api: '/api/mobile/user/show', + utilSuccess: function(res) { + uni.setStorageSync(user_key, res) + cb(res) + }, + utilFail: function(res) {} + }) +} const getOpenidInfo = (cb, refresh) => { cb = cb || function() {} @@ -65,10 +86,6 @@ const getUserProfile = (cb) => { -const getUserInfoCache = () => { - return uni.getStorageSync(user_info_key) -} - const formatTimeAll = date => { const year = date.getFullYear(); const month = date.getMonth() + 1; @@ -513,5 +530,6 @@ module.exports = { Base64: Base64, orderStatusDic: orderStatusDic, auditStatusDic: auditStatusDic, - getUserProfile: getUserProfile + getUserProfile: getUserProfile, + getUserInfo: getUserInfo };