From 139b0d59fdf9792e251747059ac8f559104b7466 Mon Sep 17 00:00:00 2001 From: donqi Date: Mon, 23 May 2022 17:38:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/globalData.js | 1 + common/js/request.js | 29 ++++---- pages/index/index-home.vue | 122 +++++++++++++++---------------- pages/index/msg-dialog.vue | 38 +++++----- pages/index/my-home.vue | 116 ++++++++++++++--------------- pages/my/account-security.vue | 14 +++- pages/my/modal/phone-vertify.vue | 53 ++++++++++++++ 7 files changed, 219 insertions(+), 154 deletions(-) create mode 100644 pages/my/modal/phone-vertify.vue diff --git a/common/js/globalData.js b/common/js/globalData.js index 96de592..c380f0f 100644 --- a/common/js/globalData.js +++ b/common/js/globalData.js @@ -1,5 +1,6 @@ export default { deptId: 101, + from: 'server', initPageNum: 1, initPageSize: 5 } \ No newline at end of file diff --git a/common/js/request.js b/common/js/request.js index 5acbee0..f8d20cf 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -7,10 +7,15 @@ export default { uni.addInterceptor('request', { invoke(args) { // request 触发前拼接 url - // args.url = 'https://www.opsoul.com' + args.url; - args.url = 'http://127.0.0.1:80' + args.url; + args.url = 'https://www.opsoul.com' + args.url; + // args.url = 'http://127.0.0.1:80' + args.url; if (args.data) { args.data.deptId = globalData.deptId; + args.data.from = globalData.from; + } + if (args.header) { + args.header.deptId = globalData.deptId; + args.header.from = globalData.from; } // console.log("停止触发"); // return false; @@ -64,14 +69,8 @@ export default { } }) }, - async login() { - // 从缓存中获取登录信息 - let userInfo = uni.getStorageSync('userProfile'); - if (userInfo) { - return true; - } - - userInfo = await wx.getUserProfile({ + async login() { + let userInfo = await wx.getUserProfile({ desc: '用于小程序登录' }); console.log("从微信获取基本用户信息:" + userInfo); @@ -95,7 +94,7 @@ export default { let registerRes = await this.registerUser({ openId: openId, name: userInfo.userInfo.nickName, - customerLogoUrl: userInfo.userInfo.avatarUrl, + workerLogoUrl: userInfo.userInfo.avatarUrl, status: 0 }); if (registerRes.code === 0) { @@ -111,9 +110,9 @@ export default { } } console.log("通过后台服务获取用户信息:" + userInfo); - if (!userInfo || userInfo.customerId == null || userInfo.customerId == undefined) { + if (!userInfo || userInfo.workerId == null || userInfo.workerId == undefined) { uni.showToast({ - icon: 'error', + icon: 'none', title: '微信用户信息获取失败,请退出小程序重试' }) return false; @@ -124,7 +123,7 @@ export default { }, async registerUser(params = {}) { let res = await uni.request({ - url: '/wx/addUser', + url: '/wx/addWorker', method: 'POST', data: params }) @@ -132,7 +131,7 @@ export default { }, async qryUserInfo(openId) { let res = await uni.request({ - url: '/wx/getUserInfo', + url: '/wx/getWorkerInfo', method: 'POST', data: { openId: openId diff --git a/pages/index/index-home.vue b/pages/index/index-home.vue index 3874137..3dc7add 100644 --- a/pages/index/index-home.vue +++ b/pages/index/index-home.vue @@ -5,7 +5,7 @@ + :style="'width: 120rpx; height: 120rpx; background-image:url(' + curUserInfo.workerLogoUrl + ');'"> {{curUserInfo.name}} - - - - 需先授权微信登录才可正常使用功能 - - - 确认授权 - - + + + + + + 需先授权微信登录才可正常使用功能 + + + 确认授权 + + @@ -125,40 +125,40 @@ title: '需求大厅', name: '查看详情', color: 'blue', - cuIcon: 'list', + cuIcon: 'list', pageUrl: '' }, { id: 2, title: '我的订单', name: '查看详情', color: 'orange', - cuIcon: 'text', + cuIcon: 'text', pageUrl: '/pages/order-manage/order-manage' }, { id: 3, title: '叮咚学院', name: '查看详情', color: 'cyan', - cuIcon: 'emoji', + cuIcon: 'emoji', pageUrl: '' }, { id: 4, title: '邀请师傅', name: '查看详情', color: 'pink', - cuIcon: 'profile', + cuIcon: 'profile', pageUrl: '' }, { id: 5, title: '区域代理', name: '查看详情', color: 'olive', - cuIcon: 'group', + cuIcon: 'group', pageUrl: '/pages/area-proxy/my-team' - }], + }], curUserInfo: {}, myInfo: {}, - isShowSteer: false, + isShowSteer: false, isAuthWxLoginModal: false } }, @@ -166,24 +166,24 @@ this.loadData(); }, methods: { - async loadData() { - this.curUserInfo = this.$request.getCurUserInfo(); - console.log(this.curUserInfo) - this.isAuthWxLoginModal = this.curUserInfo ? false : true; - if (!this.isAuthWxLoginModal) { - this.myInfo = await this.$api.data('myInfo'); - this.isShowSteer = !this.myInfo.entryType; - let newServModules = this.servModules.concat(); - if (this.myInfo.hasCheckedRule) { - newServModules[0].pageUrl = '/pages/demand-center/accept-demand-center'; - } else { - let paramObj = { - hasCheckedRule: this.myInfo.hasCheckedRule, - navigate: true - } - newServModules[0].pageUrl = '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)); - } - this.servModules = newServModules; + async loadData() { + this.curUserInfo = this.$request.getCurUserInfo(); + console.log(this.curUserInfo) + this.isAuthWxLoginModal = this.curUserInfo ? false : true; + if (!this.isAuthWxLoginModal) { + this.myInfo = await this.$api.data('myInfo'); + this.isShowSteer = !this.myInfo.entryType; + let newServModules = this.servModules.concat(); + if (this.myInfo.hasCheckedRule) { + newServModules[0].pageUrl = '/pages/demand-center/accept-demand-center'; + } else { + let paramObj = { + hasCheckedRule: this.myInfo.hasCheckedRule, + navigate: true + } + newServModules[0].pageUrl = '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)); + } + this.servModules = newServModules; } }, chooseEntryType(typeCode) { @@ -191,22 +191,22 @@ }, hideModal(e) { this.isShowSteer = false - }, - showMasterRule() { - let paramObj = { - hasCheckedRule: this.myInfo.hasCheckedRule, - navigate: false - } - uni.navigateTo({ - url: '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)) - }) - }, - authWxLogin() { - this.$request.login().then(res => { - if (res) { - this.loadData(); - } - }) + }, + showMasterRule() { + let paramObj = { + hasCheckedRule: this.myInfo.hasCheckedRule, + navigate: false + } + uni.navigateTo({ + url: '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)) + }) + }, + authWxLogin() { + this.$request.login().then(res => { + if (res) { + this.loadData(); + } + }) } }, } @@ -242,12 +242,12 @@ .nav-list>navigator:nth-child(even) { margin-left: 30rpx; - } - - .right-tag { - background-color: rgba(0, 0, 0, 0.3); - position: relative; - right: -30rpx; - border-radius: 40rpx 0 0 40rpx; } - + + .right-tag { + background-color: rgba(0, 0, 0, 0.3); + position: relative; + right: -30rpx; + border-radius: 40rpx 0 0 40rpx; + } + diff --git a/pages/index/msg-dialog.vue b/pages/index/msg-dialog.vue index 41b6dd9..8364205 100644 --- a/pages/index/msg-dialog.vue +++ b/pages/index/msg-dialog.vue @@ -7,18 +7,18 @@ + v-if="item.sendUserId === curUserInfo.workerId"> {{item.msg}} - + {{item.time}} - + @@ -113,21 +113,21 @@ this.showEmoji = true; this.InputBottom = this.InputBottom === 0 ? 300 : this.InputBottom; }, - sendMsg(type) { - if (type === 'text' && this.inputContent != '') { - this.showLoading = true; - let content = this.inputContent; - this.inputContent = ''; - // TODO:模拟调用后台服务发送消息 - setTimeout(() => { - this.chatMsgList.push({ - sendUserId: this.curUserInfo.customerId, - recvUserId: this.personToChat.customerId, - msg: content, - time: new Date() - }) - this.showLoading = false; - }, 0) + sendMsg(type) { + if (type === 'text' && this.inputContent != '') { + this.showLoading = true; + let content = this.inputContent; + this.inputContent = ''; + // TODO:模拟调用后台服务发送消息 + setTimeout(() => { + this.chatMsgList.push({ + sendUserId: this.curUserInfo.workerId, + recvUserId: this.personToChat.workerId, + msg: content, + time: new Date() + }) + this.showLoading = false; + }, 0) } } }, @@ -164,4 +164,4 @@ display: inline-block; margin-right: 6rpx; } - + diff --git a/pages/index/my-home.vue b/pages/index/my-home.vue index 1aa2193..f6b43c7 100644 --- a/pages/index/my-home.vue +++ b/pages/index/my-home.vue @@ -3,7 +3,7 @@ + :style="'width: 150rpx; height: 150rpx; background-image:url(' + curUserInfo.workerLogoUrl + ');'"> {{curUserInfo.name}} @@ -41,14 +41,14 @@ - - - - - {{item.name}} - - - + + + + + {{item.name}} + + + @@ -62,49 +62,49 @@ return { pageContentTop: this.CustomBar, curUserInfo: {}, - myInfo: {}, - menuList: [{ - name: '提现', - icon: 'moneybag', - pageUrl: '/pages/my/withdraw' - }, { - name: '交易明细', - icon: 'form', - pageUrl: '/pages/my/my-money-bag' - }, { - name: '服务明细', - icon: 'calendar' - }, { - name: '师傅入驻', - icon: 'profile', - pageUrl: '/pages/my/master-occupancy' - }, { - name: '商品管理', - icon: 'goods', - pageUrl: '/pages/my/goods-manage' - }, { - name: '个人信息', - icon: 'lock', - pageUrl: '/pages/my/personal-info' - }, { - name: '法律声明', - icon: 'read' - }, { - name: '店铺认证', - icon: 'taoxiaopu' - }, { - name: '签约协议', - icon: 'punch' - }, { - name: '反馈到平台', - icon: 'comment' - }, { - name: '开放平台', - icon: 'community' - }, { - name: '师傅缴费', - icon: 'sponsor', - pageUrl: '/pages/my/pay-deposit' + myInfo: {}, + menuList: [{ + name: '提现', + icon: 'moneybag', + pageUrl: '/pages/my/withdraw' + }, { + name: '交易明细', + icon: 'form', + pageUrl: '/pages/my/my-money-bag' + }, { + name: '服务明细', + icon: 'calendar' + }, { + name: '师傅入驻', + icon: 'profile', + pageUrl: '/pages/my/master-occupancy' + }, { + name: '商品管理', + icon: 'goods', + pageUrl: '/pages/my/goods-manage' + }, { + name: '个人信息', + icon: 'lock', + pageUrl: '/pages/my/personal-info' + }, { + name: '法律声明', + icon: 'read' + }, { + name: '店铺认证', + icon: 'taoxiaopu' + }, { + name: '签约协议', + icon: 'punch' + }, { + name: '反馈到平台', + icon: 'comment' + }, { + name: '开放平台', + icon: 'community' + }, { + name: '师傅缴费', + icon: 'sponsor', + pageUrl: '/pages/my/pay-deposit' }] } }, @@ -115,11 +115,11 @@ async loadData() { this.curUserInfo = this.$request.getCurUserInfo(); this.myInfo = await this.$api.data('myInfo'); - }, - clickMenuItem(menu) { - uni.navigateTo({ - url: menu.pageUrl - }) + }, + clickMenuItem(menu) { + uni.navigateTo({ + url: menu.pageUrl + }) } }, } @@ -139,4 +139,4 @@ z-index: -1; padding-top: 100rpx; } - + diff --git a/pages/my/account-security.vue b/pages/my/account-security.vue index f4ca7bc..5ade512 100644 --- a/pages/my/account-security.vue +++ b/pages/my/account-security.vue @@ -5,17 +5,23 @@ 返回 帐号安全 - + 绑定手机 {{curUserInfo.phone}} + + +