接口对接

This commit is contained in:
donqi 2022-06-01 18:18:33 +08:00
parent 701d63672d
commit 11184cc189
5 changed files with 307 additions and 74 deletions

View File

@ -4,20 +4,27 @@ export default {
address: 'https://www.opsoul.com',
// 异步接口拦截
addInterceptor() {
let _this = this;
uni.addInterceptor('request', {
invoke(args) {
let userInfo = _this.getCurUserInfo();
// 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://10.45.111.215:80' + args.url;
if (args.data) {
args.data.deptId = globalData.deptId;
args.data.from = globalData.from;
args.url = 'http://10.45.137.214:80' + args.url;
if (!args.data) {
args.data = {}
}
if (args.header) {
args.header.deptId = globalData.deptId;
args.header.from = globalData.from;
args.data.deptId = globalData.deptId;
args.data.from = globalData.from;
if (!args.data.workerId) {
args.data.workerId = userInfo.workerId;
}
if (!args.header) {
args.header = {}
}
args.header.deptId = globalData.deptId;
args.header.from = globalData.from;
// console.log("停止触发");
// return false;
},
@ -280,5 +287,29 @@ export default {
data: params
})
return res[1].data;
},
async addTeam(params = {}) {
let res = await uni.request({
url: '/worker/team/addTeam',
method: 'POST',
data: params
})
return res[1].data;
},
async getTeamPage(params = {}) {
let res = await uni.request({
url: '/worker/team/getTeamList',
method: 'POST',
data: params
})
return res[1].data;
},
async updateWorker(params = {}) {
let res = await uni.request({
url: '/worker/update',
method: 'POST',
data: params
})
return res[1].data;
}
}

View File

@ -0,0 +1,44 @@
<template>
<view>
<view class="margin-bottom-lg">
<view v-if="hasMoreData" class="text-center bg-main-color light padding-tb-sm">
<text class="margin-right-xs">查看更多</text>
<text class="text-bold cuIcon-unfold"></text>
</view>
<view class="cu-load" :class="loadMoreStatus"></view>
</view>
</view>
</template>
<script>
export default {
name: 'load-status-bar',
data() {
return {
loadMoreStatus: '',
hasMoreData: true
}
},
methods: {
showLoading() {
this.loadMoreStatus = 'loading bg-main-color light';
this.hasMoreData = false;
},
showLoadMore() {
this.loadMoreStatus = '';
this.hasMoreData = true;
},
showLoadOver() {
this.loadMoreStatus = 'over bg-grey';
this.hasMoreData = false;
},
showLoadErr() {
this.loadMoreStatus = 'erro bg-red';
this.hasMoreData = false;
}
},
}
</script>
<style>
</style>

View File

@ -0,0 +1,65 @@
<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 text-left">
<view class="margin-top-sm">
<text>团队成员师傅ID</text>
<input class="radius-input margin-top-sm" type="text" v-model="workerId"></input>
</view>
<view class="margin-top-sm">
<text>成员师傅备注</text>
<input class="radius-input margin-top-sm" type="text" v-model="workerName"></input>
</view>
</view>
<view class="cu-bar bg-white solid-top">
<view class="action margin-0 flex-sub text-black" @tap="hideModal">取消</view>
<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal"
@click="confirm">邀请</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'invite-master',
emits: ['confirm'],
data() {
return {
isShow: false,
workerId: '',
workerName: ''
}
},
methods: {
showModal(e) {
this.isShow = true
},
hideModal(e) {
this.isShow = false;
this.resetData();
},
resetData() {
this.workerId = '',
this.workerName = ''
},
confirm() {
this.$emit('confirm', {
leaderId: this.$request.getCurUserInfo().workerId,
workerId: this.workerId,
workerName: this.workerName
});
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,74 @@
<template>
<!-- 设置扣点模态框 -->
<view class="cu-modal" :class="isShow?'show':''">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">设置扣点</view>
<view class="action" @tap="hideModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="padding-xl">
<view>设置区域代理扣点可按百分比扣取或金额扣取的方式建议二选一进行申请</view>
<view class="flex justify-center align-center margin-top-sm">
<text>扣点</text>
<input class="radius-input" type="digit" placeholder="请输入订单扣取的比例" v-model="rate"></input>
<text>%</text>
</view>
<view class="flex justify-center align-center margin-top-sm">
<text>金额</text>
<input class="radius-input" type="digit" placeholder="请输入按单扣取的金额" v-model="amount"></input>
<text></text>
</view>
</view>
<view class="cu-bar bg-white">
<view class="action margin-0 flex-sub text-black" @tap="hideModal">取消</view>
<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal"
@click="confirm">提交申请</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'set-take-rate',
emits: ['confirm'],
props: {
leaderTeamRate: {
type: String,
default: ""
},
leaderTeamMoney: {
type: String,
default: ""
}
},
data() {
return {
isShow: false,
rate: '',
amount: ''
}
},
methods: {
showModal(e) {
this.isShow = true;
this.rate = this.leaderTeamRate ? this.leaderTeamRate : '';
this.amount = this.leaderTeamMoney ? this.leaderTeamMoney : '';
},
hideModal(e) {
this.isShow = false;
},
confirm() {
this.$emit('confirm', {
leaderTeamRate: this.rate,
leaderTeamMoney: this.amount
});
}
}
}
</script>
<style>
</style>

View File

@ -6,18 +6,18 @@
<block slot="content">我的团队</block>
</cu-custom>
<!-- 团队成员 -->
<view class="margin-bottom-with-bar">
<view>
<view class="bg-white padding bottom-border" v-for="(member, index) in members">
<view class="flex justify-between">
<view class="flex justify-start align-center" style="width: 40%;">
<view class="cu-avatar round"
:style="'background-image:url(' + member.avatarUrl + ');min-width: 64rpx'"></view>
:style="'background-image:url(' + member.workerLogoUrl + ');min-width: 64rpx'"></view>
<view class="text-lg margin-left-sm">{{member.name}}</view>
</view>
<view class="flex justify-end align-center">
<view v-if="Boolean(member.showEditInput)" :key="member.id"
<view v-if="Boolean(member.showEditInput)" :key="member.workerId"
class="flex justify-end align-center margin-lr-sm">
<input class="radius-input" type="text" :value="member.noteName" placeholder="姓名备注"></input>
<input class="radius-input" type="text" :value="member.workerName" placeholder="姓名备注"></input>
<view class="text-lg margin-left-sm">
<text class="cuIcon-roundcheckfill text-main-color" :data-index="index"
@click="editNoteName"></text>
@ -25,66 +25,50 @@
@click="hideEditInput"></text>
</view>
</view>
<view v-else class="flex justify-end margin-lr-sm" :key="member.id">
<text>{{member.noteName}}</text>
<view v-else class="flex justify-end margin-lr-sm" :key="member.workerId">
<text>{{member.workerName}}</text>
<text class="text-lg" :data-index="index" @click="showEditInput"><text
class="cuIcon-edit margin-left-xs"></text></text>
</view>
<view class="text-xxl text-main-color" :data-phone="member.phoneNum" @click="makePhoneCall">
<view class="text-xxl text-main-color" :data-phone="member.phone" @click="makePhoneCall">
<view class="cuIcon-phone"></view>
</view>
</view>
</view>
</view>
</view>
<load-status-bar class="margin-bottom-with-bar" ref="loadStatusBar"></load-status-bar>
<!-- 底部操作栏 -->
<view class="cu-bar bg-white tabbar border shop fixed-bottom-bar">
<view class="left-grid text-center" @click="showTakeRateSetModal">
<view class="left-grid text-center" data-modal="takeRateSet" @click="showModalByRef('setTakeRateModal')">
<view>设置扣点</view>
<view>(扣点<text class="text-red">{{myTeamInfo.takeRate}}%</text>)</view>
<view v-if="curUserInfo.leaderTeamRate">(扣点<text class="text-red">{{curUserInfo.leaderTeamRate}}%</text>)</view>
</view>
<view class="bg-main-color submit" @click="">邀请团队</view>
<view class="bg-main-color submit" @click="showModalByRef('inviteMasterModal')">邀请团队</view>
</view>
<!-- 设置扣点模态框 -->
<view class="cu-modal" :class="isShowTakeRateSet?'show':''">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">设置扣点</view>
<view class="action" @tap="hideModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="padding-xl">
<view>设置区域代理扣点可按百分比扣取或金额扣取的方式建议二选一进行申请</view>
<view class="flex justify-center align-center margin-top-sm">
<text>扣点</text>
<input class="radius-input" type="digit" placeholder="请输入订单扣取的比例"></input>
<text>%</text>
</view>
<view class="flex justify-center align-center margin-top-sm">
<text>金额</text>
<input class="radius-input" type="digit" placeholder="请输入按单扣取的金额"></input>
<text></text>
</view>
</view>
<view class="cu-bar bg-white">
<view class="action margin-0 flex-sub text-black" @tap="hideModal">取消</view>
<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal"
@click="applySetTakeRate">提交申请</view>
</view>
</view>
</view>
<set-take-rate ref="setTakeRateModal" :leaderTeamRate="curUserInfo.leaderTeamRate" :leaderTeamMoney="curUserInfo.leaderTeamMoney" @confirm="applySetTakeRate"></set-take-rate>
<invite-master ref="inviteMasterModal" @confirm="inviteMaster"></invite-master>
</view>
</template>
<script>
import setTakeRate from '@/pages/area-proxy/modal/set-take-rate.vue';
import inviteMaster from '@/pages/area-proxy/modal/invite-master.vue';
import loadStatusBar from '@/components/custom-bar/load-status-bar.vue';
export default {
components: {
inviteMaster,
setTakeRate,
loadStatusBar
},
data() {
return {
myTeamInfo: {},
members: [],
isShowTakeRateSet: false
pageNum: 0,
pageSize: 0,
curUserInfo: null
}
},
onLoad() {
@ -92,8 +76,35 @@
},
methods: {
async loadData() {
this.myTeamInfo = await this.$api.data('myTeamInfo');
this.members = this.myTeamInfo.members;
// this.myTeamInfo = await this.$api.data('myTeamInfo');
// this.members = this.myTeamInfo.members;
this.curUserInfo = this.$request.getCurUserInfo();
this.loadTeamPage();
},
async reloadData() {
this.pageNum = 0;
this.members = [];
this.loadData();
},
async loadTeamPage(params = {}) {
params.pageNum = this.pageNum;
params.pageSize = this.$globalData.pageSize;
this.$refs.loadStatusBar.showLoading();
try {
let res = await this.$request.getTeamPage(params);
let rowsLength = res.rows.length;
if (rowsLength > 0) {
this.members = this.members.concat(res.rows);
this.pageNum++;
if (rowsLength === this.pageSize) {
this.$refs.loadStatusBar.showLoadMore();
}
}
this.$refs.loadStatusBar.showLoadOver();
} catch (e) {
console.error(e)
this.$refs.loadStatusBar.showLoadErr();
}
},
showEditInput(e) {
let curIndex = e.currentTarget.dataset.index;
@ -118,21 +129,29 @@
phoneNumber: phoneNum
})
},
showTakeRateSetModal(e) {
this.showModal(e);
showModalByRef(refName) {
this.$refs[refName].showModal();
},
showModal(e) {
this.isShowTakeRateSet = true
async applySetTakeRate(params) {
let res = await this.$request.updateWorker(params);
if (res.code === 0) {
uni.showToast({
title: '保存成功',
icon: 'success',
mask: true
})
}
},
hideModal(e) {
this.isShowTakeRateSet = false
},
applySetTakeRate() {
uni.showToast({
title: '保存成功',
icon: 'success',
mask: true
})
async inviteMaster(params) {
let res = await this.$request.addTeam(params);
if (res.code === 0) {
uni.showToast({
title: '邀请成功',
icon: 'success',
mask: true
})
this.reloadData();
}
}
},
}