项目初始化
This commit is contained in:
115
pages/worker/workerList/components/layout.vue
Normal file
115
pages/worker/workerList/components/layout.vue
Normal file
@@ -0,0 +1,115 @@
|
||||
<!-- 虚拟列表演示(不使用内置列表)(vue) -->
|
||||
<!-- 写法较简单,在页面中对当前需要渲染的虚拟列表数据进行for循环,在vue3中兼容性良好 -->
|
||||
<!-- 在各平台兼容性请查阅https://z-paging.zxlee.cn/module/virtual-list.html -->
|
||||
<template>
|
||||
<view class="content">
|
||||
<!-- 如果页面中的cell高度是固定不变的,则不需要设置cell-height-mode,如果页面中高度是动态改变的,则设置cell-height-mode="dynamic" -->
|
||||
<!-- 原先的v-model修改为@virtualListChange="virtualListChange"并赋值处理后的虚拟列表 -->
|
||||
<z-paging ref="paging" use-virtual-list :force-close-inner-list="true" :paging-style="{ paddingTop: 0 + 'px', paddingBottom: paddingBottom + 'rpx' }" cell-height-mode="dynamic" @scroll="scroll" @virtualListChange="virtualListChange" @query="queryList">
|
||||
<!-- 需要固定在顶部不滚动的view放在slot="top"的view中,如果需要跟着滚动,则不要设置slot="top" -->
|
||||
<template #top>
|
||||
<su-navbar :title="title" statusBar></su-navbar>
|
||||
</template>
|
||||
|
||||
<!-- :id="`zp-id-${item.zp_index}`"和:key="item.zp_index" 必须写,必须写!!!! -->
|
||||
<!-- 这里for循环的index不是数组中真实的index了,请使用item.zp_index获取真实的index -->
|
||||
<worker-list :virtualList="virtualList"></worker-list>
|
||||
|
||||
<template #bottom>
|
||||
<view class="bottom-box">
|
||||
<view class="btn" @click="addWorker">添加</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</z-paging>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import WorkerList from '@/pages/worker/workerList/components/workerList.vue';
|
||||
import ClerkApi from '@/sheep/api/worker/clerk';
|
||||
export default {
|
||||
components: {
|
||||
WorkerList,
|
||||
},
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 虚拟列表数组,通过@virtualListChange监听获得最新数组
|
||||
virtualList: [],
|
||||
scrollTop: 0,
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
height: 0,
|
||||
|
||||
current: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initNav(e) {
|
||||
this.height = e.height;
|
||||
this.paddingTop = this.height;
|
||||
},
|
||||
scroll(e) {
|
||||
this.scrollTop = e.detail.scrollTop;
|
||||
},
|
||||
// 监听虚拟列表数组改变并赋值给virtualList进行重新渲染
|
||||
virtualListChange(vList) {
|
||||
this.virtualList = vList;
|
||||
},
|
||||
queryList(pageNo, pageSize) {
|
||||
// 组件加载时会自动触发此方法,因此默认页面加载时会自动触发,无需手动调用
|
||||
// 这里的pageNo和pageSize会自动计算好,直接传给服务器即可
|
||||
// 模拟请求服务器获取分页数据,请替换成自己的网络请求
|
||||
const params = {
|
||||
pageNo: pageNo,
|
||||
pageSize: pageSize,
|
||||
}
|
||||
ClerkApi.getClerkApplyPage(params).then(res => {
|
||||
// 将请求的结果数组传递给z-paging
|
||||
this.$refs.paging.complete(res.data.list);
|
||||
}).catch(res => {
|
||||
// 如果请求失败写this.$refs.paging.complete(false);
|
||||
// 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
|
||||
// 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
|
||||
this.$refs.paging.complete(false);
|
||||
})
|
||||
},
|
||||
addWorker() {
|
||||
this.$u.route({
|
||||
url: 'pages/clerk/apply/index',
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bottom-box {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 7px 15px;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 6px 0 #ccc;
|
||||
|
||||
.btn {
|
||||
background-color: var(--ui-BG-Main);
|
||||
padding: 10px;
|
||||
border-radius: 40px;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
208
pages/worker/workerList/components/workerList.vue
Normal file
208
pages/worker/workerList/components/workerList.vue
Normal file
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<view class="worker-box">
|
||||
|
||||
<view :id="`zp-id-${item.zp_index}`" :key="item.zp_index" v-for="(item,index) in virtualList" class="worker-card">
|
||||
|
||||
<view class="main-box">
|
||||
<view class="avatar-box">
|
||||
<u-avatar mode="square" size="120" :src="item.avatar"></u-avatar>
|
||||
<view class="online-box" v-if="item.onlineStatus">在线</view>
|
||||
<view class="online-box" v-else>离线</view>
|
||||
</view>
|
||||
|
||||
<view class="right-box">
|
||||
<view class="nickname-box">
|
||||
<view class="nickname">
|
||||
<text class="name">{{item.nickname}}</text>
|
||||
<view class="man-box" v-if="item.sex == 0">
|
||||
<u-icon name="man"></u-icon>
|
||||
<text>{{item.age}}</text>
|
||||
</view>
|
||||
<view class="woman-box" v-if="item.sex == 1">
|
||||
<u-icon name="woman"></u-icon>
|
||||
<text>{{item.age}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="status" v-if="item.status == 0">待审核</view>
|
||||
<view class="status" v-if="item.status == 1">已审核</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-box">
|
||||
<view class="btn" @click="editApply(item)">编辑资料</view>
|
||||
<view class="btn" @click="levelList(item)">技能管理</view>
|
||||
<view class="btn" @click="setOnline(item)">在线状态</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
components: {
|
||||
|
||||
},
|
||||
props: {
|
||||
virtualList: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
editApply(e) {
|
||||
this.$u.route({
|
||||
url: 'pages/clerk/apply/edit',
|
||||
params: {
|
||||
id: e.id,
|
||||
}
|
||||
});
|
||||
},
|
||||
levelList(e) {
|
||||
this.$u.route({
|
||||
url: 'pages/worker/levelList/index',
|
||||
params: {
|
||||
id: e.id,
|
||||
}
|
||||
});
|
||||
},
|
||||
setOnline(e) {
|
||||
this.$u.route({
|
||||
url: 'pages/worker/workerList/set',
|
||||
params: {
|
||||
id: e.id,
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.worker-box {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.worker-card {
|
||||
padding: 10px;
|
||||
margin-top: 10px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
border-radius: 10px;
|
||||
|
||||
.main-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.avatar-box {
|
||||
position: relative;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
|
||||
.online-box {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
background-color: var(--ui-BG-Main);
|
||||
font-size: 11px;
|
||||
padding: 1px 0;
|
||||
border-bottom-left-radius: 5px;
|
||||
border-bottom-right-radius: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.right-box {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
margin-left: 10px;
|
||||
|
||||
.nickname-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nickname {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.name {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
margin-right: 5px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 300rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.man-box {
|
||||
background: linear-gradient(90deg,#2b99ca,#87b5e7);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 40px;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
.woman-box {
|
||||
background: linear-gradient(90deg,#c33239,#de8189);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 40px;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
color: var(--ui-BG-Main);
|
||||
}
|
||||
|
||||
.btn-box {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
.btn {
|
||||
background-color: var(--ui-BG-Main);
|
||||
color: #fff;
|
||||
border-radius: 40px;
|
||||
font-size: 22rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 10rpx 20rpx;
|
||||
margin-left: 5px;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
40
pages/worker/workerList/index.vue
Normal file
40
pages/worker/workerList/index.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<view class="page-app theme-light main-green font-1">
|
||||
<layout title="达人列表"></layout>
|
||||
|
||||
<s-menu-tools />
|
||||
<s-auth-modal />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import layout from '@/pages/worker/workerList/components/layout.vue';
|
||||
export default {
|
||||
components: {
|
||||
layout,
|
||||
},
|
||||
props: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-app {
|
||||
background-color: #fafafa;
|
||||
padding-bottom: 140rpx;
|
||||
height: calc(100vh);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
</style>
|
148
pages/worker/workerList/set.vue
Normal file
148
pages/worker/workerList/set.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<view class="page-app theme-light main-green font-1">
|
||||
<su-navbar title="在线状态" statusBar></su-navbar>
|
||||
<view class="form-card">
|
||||
<view class="form-item">
|
||||
<view class="label">接单时间段</view>
|
||||
<view class="input">
|
||||
<u-input input-align="right" placeholder="例如:8:00 - 21:00" v-model="form.onlineTime"></u-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<view class="label">当前在线状态</view>
|
||||
<view class="input">
|
||||
<u-switch size="46" v-model="form.onlineStatus"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<view class="label">盲盒订单提醒</view>
|
||||
<view class="input">
|
||||
<u-switch size="46" v-model="form.blindStatus"></u-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-box">
|
||||
<view class="btn" @click="saveApply">保存</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<s-menu-tools />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import sheep from '@/sheep';
|
||||
import ClerkApi from '@/sheep/api/worker/clerk';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
form: {
|
||||
id: 0,
|
||||
onlineTime: '',
|
||||
onlineStatus: false,
|
||||
blindStatus: false,
|
||||
},
|
||||
list: [
|
||||
[
|
||||
{
|
||||
value: '8',
|
||||
label: '8:00'
|
||||
},
|
||||
{
|
||||
value: '9',
|
||||
label: '9:00'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
value: '8',
|
||||
label: '8:00'
|
||||
},
|
||||
{
|
||||
value: '9',
|
||||
label: '9:00'
|
||||
}
|
||||
],
|
||||
|
||||
],
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.form.id = options.id;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
ClerkApi.getClerkApply(this.form.id).then((res) => {
|
||||
this.form = res.data;
|
||||
});
|
||||
},
|
||||
confirm(e) {
|
||||
if(e[0].value >= e[1].value){
|
||||
sheep.$helper.toast('开始时间不能大于结束时间');
|
||||
return;
|
||||
}
|
||||
this.form.onlineTime = e[0].label+' - '+e[1].label;
|
||||
},
|
||||
timeSet() {
|
||||
this.show = true;
|
||||
},
|
||||
saveApply() {
|
||||
if(!this.form.onlineTime){
|
||||
sheep.$helper.toast('请输入接单时间段');
|
||||
return;
|
||||
}
|
||||
ClerkApi.updateOnlineStatus(this.form).then((res) => {
|
||||
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-app {
|
||||
background-color: #fafafa;
|
||||
padding-bottom: 140rpx;
|
||||
height: calc(100vh);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
.form-card {
|
||||
background-color: #fff;
|
||||
margin: 10px;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
|
||||
.form-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 15px;
|
||||
|
||||
.label {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-box {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 40px;
|
||||
|
||||
.btn {
|
||||
background-color: var(--ui-BG-Main);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
min-width: 75%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 40px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
Reference in New Issue
Block a user