后台接口对接

This commit is contained in:
donqi 2022-05-23 17:38:52 +08:00
parent ecb9010f5a
commit 139b0d59fd
7 changed files with 219 additions and 154 deletions

View File

@ -1,5 +1,6 @@
export default { export default {
deptId: 101, deptId: 101,
from: 'server',
initPageNum: 1, initPageNum: 1,
initPageSize: 5 initPageSize: 5
} }

View File

@ -7,10 +7,15 @@ export default {
uni.addInterceptor('request', { uni.addInterceptor('request', {
invoke(args) { invoke(args) {
// request 触发前拼接 url // request 触发前拼接 url
// args.url = 'https://www.opsoul.com' + args.url; args.url = 'https://www.opsoul.com' + args.url;
args.url = 'http://127.0.0.1:80' + args.url; // args.url = 'http://127.0.0.1:80' + args.url;
if (args.data) { if (args.data) {
args.data.deptId = globalData.deptId; 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("停止触发"); // console.log("停止触发");
// return false; // return false;
@ -64,14 +69,8 @@ export default {
} }
}) })
}, },
async login() { async login() {
// 从缓存中获取登录信息 let userInfo = await wx.getUserProfile({
let userInfo = uni.getStorageSync('userProfile');
if (userInfo) {
return true;
}
userInfo = await wx.getUserProfile({
desc: '用于小程序登录' desc: '用于小程序登录'
}); });
console.log("从微信获取基本用户信息:" + userInfo); console.log("从微信获取基本用户信息:" + userInfo);
@ -95,7 +94,7 @@ export default {
let registerRes = await this.registerUser({ let registerRes = await this.registerUser({
openId: openId, openId: openId,
name: userInfo.userInfo.nickName, name: userInfo.userInfo.nickName,
customerLogoUrl: userInfo.userInfo.avatarUrl, workerLogoUrl: userInfo.userInfo.avatarUrl,
status: 0 status: 0
}); });
if (registerRes.code === 0) { if (registerRes.code === 0) {
@ -111,9 +110,9 @@ export default {
} }
} }
console.log("通过后台服务获取用户信息:" + userInfo); console.log("通过后台服务获取用户信息:" + userInfo);
if (!userInfo || userInfo.customerId == null || userInfo.customerId == undefined) { if (!userInfo || userInfo.workerId == null || userInfo.workerId == undefined) {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'none',
title: '微信用户信息获取失败,请退出小程序重试' title: '微信用户信息获取失败,请退出小程序重试'
}) })
return false; return false;
@ -124,7 +123,7 @@ export default {
}, },
async registerUser(params = {}) { async registerUser(params = {}) {
let res = await uni.request({ let res = await uni.request({
url: '/wx/addUser', url: '/wx/addWorker',
method: 'POST', method: 'POST',
data: params data: params
}) })
@ -132,7 +131,7 @@ export default {
}, },
async qryUserInfo(openId) { async qryUserInfo(openId) {
let res = await uni.request({ let res = await uni.request({
url: '/wx/getUserInfo', url: '/wx/getWorkerInfo',
method: 'POST', method: 'POST',
data: { data: {
openId: openId openId: openId

View File

@ -5,7 +5,7 @@
<view class="flex justify-between padding-bottom align-center solid-bottom"> <view class="flex justify-between padding-bottom align-center solid-bottom">
<view class="flex justify-start align-center"> <view class="flex justify-start align-center">
<view class="cu-avatar round" <view class="cu-avatar round"
:style="'width: 120rpx; height: 120rpx; background-image:url(' + curUserInfo.customerLogoUrl + ');'"></view> :style="'width: 120rpx; height: 120rpx; background-image:url(' + curUserInfo.workerLogoUrl + ');'"></view>
<view class="margin-lr-sm"> <view class="margin-lr-sm">
<view class="text-xl margin-bottom-xs">{{curUserInfo.name}}</view> <view class="text-xl margin-bottom-xs">{{curUserInfo.name}}</view>
<!-- <view class="padding-xs text-sm"> <!-- <view class="padding-xs text-sm">
@ -99,17 +99,17 @@
@click="chooseEntryType('serv')">服务商</view> @click="chooseEntryType('serv')">服务商</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 强制要求用户授权登录的弹窗 --> <!-- 强制要求用户授权登录的弹窗 -->
<view class="cu-modal" :class="isAuthWxLoginModal?'show':''"> <view class="cu-modal" :class="isAuthWxLoginModal?'show':''">
<view class="cu-dialog"> <view class="cu-dialog">
<view class="padding-xl"> <view class="padding-xl">
需先授权微信登录才可正常使用功能 需先授权微信登录才可正常使用功能
</view> </view>
<view class="cu-bar bg-white"> <view class="cu-bar bg-white">
<view class="action margin-0 flex-sub text-main-color solid-left" @tap="authWxLogin">确认授权</view> <view class="action margin-0 flex-sub text-main-color solid-left" @tap="authWxLogin">确认授权</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
@ -125,40 +125,40 @@
title: '需求大厅', title: '需求大厅',
name: '查看详情', name: '查看详情',
color: 'blue', color: 'blue',
cuIcon: 'list', cuIcon: 'list',
pageUrl: '' pageUrl: ''
}, { }, {
id: 2, id: 2,
title: '我的订单', title: '我的订单',
name: '查看详情', name: '查看详情',
color: 'orange', color: 'orange',
cuIcon: 'text', cuIcon: 'text',
pageUrl: '/pages/order-manage/order-manage' pageUrl: '/pages/order-manage/order-manage'
}, { }, {
id: 3, id: 3,
title: '叮咚学院', title: '叮咚学院',
name: '查看详情', name: '查看详情',
color: 'cyan', color: 'cyan',
cuIcon: 'emoji', cuIcon: 'emoji',
pageUrl: '' pageUrl: ''
}, { }, {
id: 4, id: 4,
title: '邀请师傅', title: '邀请师傅',
name: '查看详情', name: '查看详情',
color: 'pink', color: 'pink',
cuIcon: 'profile', cuIcon: 'profile',
pageUrl: '' pageUrl: ''
}, { }, {
id: 5, id: 5,
title: '区域代理', title: '区域代理',
name: '查看详情', name: '查看详情',
color: 'olive', color: 'olive',
cuIcon: 'group', cuIcon: 'group',
pageUrl: '/pages/area-proxy/my-team' pageUrl: '/pages/area-proxy/my-team'
}], }],
curUserInfo: {}, curUserInfo: {},
myInfo: {}, myInfo: {},
isShowSteer: false, isShowSteer: false,
isAuthWxLoginModal: false isAuthWxLoginModal: false
} }
}, },
@ -166,24 +166,24 @@
this.loadData(); this.loadData();
}, },
methods: { methods: {
async loadData() { async loadData() {
this.curUserInfo = this.$request.getCurUserInfo(); this.curUserInfo = this.$request.getCurUserInfo();
console.log(this.curUserInfo) console.log(this.curUserInfo)
this.isAuthWxLoginModal = this.curUserInfo ? false : true; this.isAuthWxLoginModal = this.curUserInfo ? false : true;
if (!this.isAuthWxLoginModal) { if (!this.isAuthWxLoginModal) {
this.myInfo = await this.$api.data('myInfo'); this.myInfo = await this.$api.data('myInfo');
this.isShowSteer = !this.myInfo.entryType; this.isShowSteer = !this.myInfo.entryType;
let newServModules = this.servModules.concat(); let newServModules = this.servModules.concat();
if (this.myInfo.hasCheckedRule) { if (this.myInfo.hasCheckedRule) {
newServModules[0].pageUrl = '/pages/demand-center/accept-demand-center'; newServModules[0].pageUrl = '/pages/demand-center/accept-demand-center';
} else { } else {
let paramObj = { let paramObj = {
hasCheckedRule: this.myInfo.hasCheckedRule, hasCheckedRule: this.myInfo.hasCheckedRule,
navigate: true navigate: true
} }
newServModules[0].pageUrl = '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)); newServModules[0].pageUrl = '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj));
} }
this.servModules = newServModules; this.servModules = newServModules;
} }
}, },
chooseEntryType(typeCode) { chooseEntryType(typeCode) {
@ -191,22 +191,22 @@
}, },
hideModal(e) { hideModal(e) {
this.isShowSteer = false this.isShowSteer = false
}, },
showMasterRule() { showMasterRule() {
let paramObj = { let paramObj = {
hasCheckedRule: this.myInfo.hasCheckedRule, hasCheckedRule: this.myInfo.hasCheckedRule,
navigate: false navigate: false
} }
uni.navigateTo({ uni.navigateTo({
url: '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj)) url: '/pages/demand-center/rule?paramObj=' + encodeURIComponent(JSON.stringify(paramObj))
}) })
}, },
authWxLogin() { authWxLogin() {
this.$request.login().then(res => { this.$request.login().then(res => {
if (res) { if (res) {
this.loadData(); this.loadData();
} }
}) })
} }
}, },
} }
@ -242,12 +242,12 @@
.nav-list>navigator:nth-child(even) { .nav-list>navigator:nth-child(even) {
margin-left: 30rpx; margin-left: 30rpx;
}
.right-tag {
background-color: rgba(0, 0, 0, 0.3);
position: relative;
right: -30rpx;
border-radius: 40rpx 0 0 40rpx;
} }
</style>
.right-tag {
background-color: rgba(0, 0, 0, 0.3);
position: relative;
right: -30rpx;
border-radius: 40rpx 0 0 40rpx;
}
</style>

View File

@ -7,18 +7,18 @@
</cu-custom> </cu-custom>
<view class="cu-chat" @click="downPanelBlur" style="min-height: 70vh;"> <view class="cu-chat" @click="downPanelBlur" style="min-height: 70vh;">
<view class="cu-item self" v-for="(item,index) in chatMsgList" <view class="cu-item self" v-for="(item,index) in chatMsgList"
v-if="item.sendUserId === curUserInfo.customerId"> v-if="item.sendUserId === curUserInfo.workerId">
<view class="main"> <view class="main">
<view class="content bg-main-color shadow"> <view class="content bg-main-color shadow">
<text>{{item.msg}}</text> <text>{{item.msg}}</text>
</view> </view>
</view> </view>
<view class="cu-avatar radius" :style="'background-image:url(' + curUserInfo.customerLogoUrl + ');'"> <view class="cu-avatar radius" :style="'background-image:url(' + curUserInfo.workerLogoUrl + ');'">
</view> </view>
<view class="date">{{item.time}}</view> <view class="date">{{item.time}}</view>
</view> </view>
<view class="cu-item" v-else> <view class="cu-item" v-else>
<view class="cu-avatar radius" :style="'background-image:url(' + personToChat.customerLogoUrl + ');'"> <view class="cu-avatar radius" :style="'background-image:url(' + personToChat.workerLogoUrl + ');'">
</view> </view>
<view class="main"> <view class="main">
<view class="content shadow"> <view class="content shadow">
@ -113,21 +113,21 @@
this.showEmoji = true; this.showEmoji = true;
this.InputBottom = this.InputBottom === 0 ? 300 : this.InputBottom; this.InputBottom = this.InputBottom === 0 ? 300 : this.InputBottom;
}, },
sendMsg(type) { sendMsg(type) {
if (type === 'text' && this.inputContent != '') { if (type === 'text' && this.inputContent != '') {
this.showLoading = true; this.showLoading = true;
let content = this.inputContent; let content = this.inputContent;
this.inputContent = ''; this.inputContent = '';
// TODO // TODO
setTimeout(() => { setTimeout(() => {
this.chatMsgList.push({ this.chatMsgList.push({
sendUserId: this.curUserInfo.customerId, sendUserId: this.curUserInfo.workerId,
recvUserId: this.personToChat.customerId, recvUserId: this.personToChat.workerId,
msg: content, msg: content,
time: new Date() time: new Date()
}) })
this.showLoading = false; this.showLoading = false;
}, 0) }, 0)
} }
} }
}, },
@ -164,4 +164,4 @@
display: inline-block; display: inline-block;
margin-right: 6rpx; margin-right: 6rpx;
} }
</style> </style>

View File

@ -3,7 +3,7 @@
<view class="bg-gradual-color padding text-center" <view class="bg-gradual-color padding text-center"
:style="'padding-top: ' + pageContentTop + 'px; padding-bottom: 100rpx;'"> :style="'padding-top: ' + pageContentTop + 'px; padding-bottom: 100rpx;'">
<view class="cu-avatar round" <view class="cu-avatar round"
:style="'width: 150rpx; height: 150rpx; background-image:url(' + curUserInfo.customerLogoUrl + ');'"> :style="'width: 150rpx; height: 150rpx; background-image:url(' + curUserInfo.workerLogoUrl + ');'">
</view> </view>
<view class="text-xl margin-sm">{{curUserInfo.name}}</view> <view class="text-xl margin-sm">{{curUserInfo.name}}</view>
<view class="cu-list grid no-border col-2" style="background-color: inherit;"> <view class="cu-list grid no-border col-2" style="background-color: inherit;">
@ -41,14 +41,14 @@
</view> </view>
</view> </view>
<view class="bg-white"> <view class="bg-white">
<view class="margin-top"> <view class="margin-top">
<view class="flex justify-between align-center solid-bottom padding padding-lr-lg text-lg" v-for="(item, index) in menuList" @click="clickMenuItem(item)"> <view class="flex justify-between align-center solid-bottom padding padding-lr-lg text-lg" v-for="(item, index) in menuList" @click="clickMenuItem(item)">
<view class="flex justify-start align-center"> <view class="flex justify-start align-center">
<view class="margin-right-sm text-main-color text-xl"><view :class="'cuIcon-' + item.icon"></view></view> <view class="margin-right-sm text-main-color text-xl"><view :class="'cuIcon-' + item.icon"></view></view>
<view>{{item.name}}</view> <view>{{item.name}}</view>
</view> </view>
<view class="cuIcon-right"></view> <view class="cuIcon-right"></view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
@ -62,49 +62,49 @@
return { return {
pageContentTop: this.CustomBar, pageContentTop: this.CustomBar,
curUserInfo: {}, curUserInfo: {},
myInfo: {}, myInfo: {},
menuList: [{ menuList: [{
name: '提现', name: '提现',
icon: 'moneybag', icon: 'moneybag',
pageUrl: '/pages/my/withdraw' pageUrl: '/pages/my/withdraw'
}, { }, {
name: '交易明细', name: '交易明细',
icon: 'form', icon: 'form',
pageUrl: '/pages/my/my-money-bag' pageUrl: '/pages/my/my-money-bag'
}, { }, {
name: '服务明细', name: '服务明细',
icon: 'calendar' icon: 'calendar'
}, { }, {
name: '师傅入驻', name: '师傅入驻',
icon: 'profile', icon: 'profile',
pageUrl: '/pages/my/master-occupancy' pageUrl: '/pages/my/master-occupancy'
}, { }, {
name: '商品管理', name: '商品管理',
icon: 'goods', icon: 'goods',
pageUrl: '/pages/my/goods-manage' pageUrl: '/pages/my/goods-manage'
}, { }, {
name: '个人信息', name: '个人信息',
icon: 'lock', icon: 'lock',
pageUrl: '/pages/my/personal-info' pageUrl: '/pages/my/personal-info'
}, { }, {
name: '法律声明', name: '法律声明',
icon: 'read' icon: 'read'
}, { }, {
name: '店铺认证', name: '店铺认证',
icon: 'taoxiaopu' icon: 'taoxiaopu'
}, { }, {
name: '签约协议', name: '签约协议',
icon: 'punch' icon: 'punch'
}, { }, {
name: '反馈到平台', name: '反馈到平台',
icon: 'comment' icon: 'comment'
}, { }, {
name: '开放平台', name: '开放平台',
icon: 'community' icon: 'community'
}, { }, {
name: '师傅缴费', name: '师傅缴费',
icon: 'sponsor', icon: 'sponsor',
pageUrl: '/pages/my/pay-deposit' pageUrl: '/pages/my/pay-deposit'
}] }]
} }
}, },
@ -115,11 +115,11 @@
async loadData() { async loadData() {
this.curUserInfo = this.$request.getCurUserInfo(); this.curUserInfo = this.$request.getCurUserInfo();
this.myInfo = await this.$api.data('myInfo'); this.myInfo = await this.$api.data('myInfo');
}, },
clickMenuItem(menu) { clickMenuItem(menu) {
uni.navigateTo({ uni.navigateTo({
url: menu.pageUrl url: menu.pageUrl
}) })
} }
}, },
} }
@ -139,4 +139,4 @@
z-index: -1; z-index: -1;
padding-top: 100rpx; padding-top: 100rpx;
} }
</style> </style>

View File

@ -5,17 +5,23 @@
<block slot="backText">返回</block> <block slot="backText">返回</block>
<block slot="content">帐号安全</block> <block slot="content">帐号安全</block>
</cu-custom> </cu-custom>
<view class="margin-top-sm bg-white"> <view class="margin-top-sm bg-white" @click="bindNewPhoneNum">
<view class="cu-form-group"> <view class="cu-form-group">
<view class="title">绑定手机</view> <view class="title">绑定手机</view>
<view>{{curUserInfo.phone}}</view> <view>{{curUserInfo.phone}}</view>
</view> </view>
</view> </view>
<phone-vertify ref="phoneBindVertify" @confirm="phoneBindRes"></phone-vertify>
</view> </view>
</template> </template>
<script> <script>
import phoneVertify from '@/pages/my/modal/phone-vertify.vue';
export default { export default {
components: {
phoneVertify
},
data() { data() {
return { return {
curUserInfo: {} curUserInfo: {}
@ -27,6 +33,12 @@
methods: { methods: {
async loadData() { async loadData() {
this.curUserInfo = await this.$request.getCurUserNoCache(); this.curUserInfo = await this.$request.getCurUserNoCache();
},
bindNewPhoneNum() {
this.$refs.phoneBindVertify.showModal();
},
phoneBindRes(e) {
console.log(e)
} }
}, },
} }

View File

@ -0,0 +1,53 @@
<template>
<!-- 模态框 -->
<view class="cu-modal" :class="isShow?'show':''">
<view class="cu-dialog bg-white">
<view class="cu-bar bg-white justify-end solid-bottom">
<view class="content">手机号验证</view>
<view class="action" @click="hideModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="padding-xl flex justify-start">
<input type="number" maxlength="11" class="radius-input flex-twice" v-model="phoneNum">
<button class="cu-btn bg-main-color shadow-blur flex-sub margin-left-sm">发送验证码</button>
</view>
<view class="cu-bar bg-white solid-top">
<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal" @click="confirm">{{confirmMsg}}</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'phone-vertify',
emits: ['confirm'],
props: {
confirmMsg: {
type: String,
default: '确定'
}
},
data() {
return {
isShow: false,
phoneNum: ''
}
},
methods: {
showModal(e) {
this.isShow = true
},
hideModal(e) {
this.isShow = false
},
confirm() {
this.$emit('confirm', this.phoneNum);
}
}
}
</script>
<style>
</style>