249 lines
5.5 KiB
Vue
249 lines
5.5 KiB
Vue
<template>
|
||
<view class="content">
|
||
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption">
|
||
<view class="info">
|
||
<u-search wrap-bg-color="transparent" :hideRight="true" :show-action="true" action-text="取消"
|
||
:animation="true" @focus="hideRight=false" @blur="hideRight=true" @custom="handleCancel"
|
||
placeholder="搜索用户编号" height="64" @search="search" v-model="keyword"></u-search>
|
||
|
||
<view v-if="info.abs_avatar">
|
||
<view class="text-center">
|
||
<u-image class="flex row-center m-t-20" :src="info.abs_avatar" width="160rpx" height="160rpx"
|
||
border-radius="50%"></u-image>
|
||
|
||
<view class="m-t-20 m-b-20 bold">{{info.nickname}}</view>
|
||
|
||
<view class="m-b-20">
|
||
<u-button type="primary" size="medium" class="spec-name-btn" @click="bind"
|
||
hover-class="none">绑定该用户</u-button>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="rule">
|
||
<view class="bold m-20">权限分配</view>
|
||
<view class="menu flex flex-wrap">
|
||
<u-checkbox @change="checkboxChange" v-model="item.checked"
|
||
v-for="(item, index) in info.rule" :key="index" :name="item.id"
|
||
class="item flex-col col-center m-b-20">{{item.name}}</u-checkbox>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="shop-menu">
|
||
<view class="shop-menu-item" v-for="(item, index) in list" :key="index">
|
||
<view class="item">
|
||
<view class="text-right m-r-20 bold" @click="unbind(item.id)">
|
||
解绑
|
||
</view>
|
||
|
||
<view class="flex">
|
||
<u-image :src="item.avatar" width="120rpx" height="120rpx" border-radius="50%"></u-image>
|
||
<view>
|
||
<view class="bold lg m-l-10">{{item.nickname}}</view>
|
||
<view class="lg m-l-10 m-t-10">绑定日期:{{item.bind_time}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</mescroll-uni>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
|
||
import {
|
||
bindList,
|
||
searchSn,
|
||
bindUser,
|
||
unBindUser
|
||
} from '@/api/local_store';
|
||
|
||
export default {
|
||
mixins: [MescrollMixin],
|
||
data() {
|
||
return {
|
||
upOption: {
|
||
noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
|
||
empty: {
|
||
icon: 'https://zjeloong.oss-cn-hangzhou.aliyuncs.com/uniapp/order_null.png',
|
||
tip: '暂无数据~', // 提示
|
||
fixed: false
|
||
}
|
||
},
|
||
info: [],
|
||
list: [],
|
||
keyword: '',
|
||
user: {
|
||
id: 0,
|
||
rule: []
|
||
},
|
||
lstore_id: 0
|
||
}
|
||
},
|
||
onLoad(e) {
|
||
if (e?.lstore_id) {
|
||
this.lstore_id = e.lstore_id
|
||
}
|
||
},
|
||
methods: {
|
||
handleCancel() {
|
||
this.keyword = ''
|
||
this.mescroll.resetUpScroll()
|
||
},
|
||
|
||
async search() {
|
||
const {
|
||
code,
|
||
data
|
||
} = await searchSn({
|
||
keyword: this.keyword
|
||
})
|
||
|
||
if (code == 1) {
|
||
this.info = data
|
||
}
|
||
},
|
||
|
||
refresh() {
|
||
this.mescroll.resetUpScroll()
|
||
},
|
||
|
||
async upCallback(page) {
|
||
let pageNum = page.num; // 页码, 默认从1开始
|
||
let pageSize = page.size; // 页长, 默认每页10条
|
||
|
||
bindList({
|
||
page_size: pageSize,
|
||
page_no: pageNum,
|
||
lstore_id: this.lstore_id
|
||
}).then(({
|
||
data
|
||
}) => {
|
||
let curPageData = data.lists;
|
||
let curPageLen = curPageData.length;
|
||
let hasNext = !!data.more;
|
||
if (page.num == 1) this.list = [];
|
||
this.list = this.list.concat(curPageData);
|
||
this.mescroll.endSuccess(curPageLen, hasNext);
|
||
})
|
||
},
|
||
|
||
bind() {
|
||
if (this.user.rule.length == 0) return this.$toast({
|
||
title: '请为用户分配权限'
|
||
})
|
||
|
||
uni.showModal({
|
||
title: '绑定',
|
||
content: '是否绑定该用户?',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
this.user.id = this.info.id
|
||
bindUser({
|
||
user: this.user,
|
||
lstore_id: this.lstore_id
|
||
}).then((res) => {
|
||
if (res.code == 1) {
|
||
this.$toast({
|
||
title: '绑定成功'
|
||
})
|
||
|
||
this.keyword = ''
|
||
this.info = []
|
||
this.user = {
|
||
id: 0,
|
||
rule: []
|
||
}
|
||
this.mescroll.resetUpScroll()
|
||
}
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
unbind(id) {
|
||
uni.showModal({
|
||
title: '解绑',
|
||
content: '是否解绑该用户?',
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
unBindUser({
|
||
id
|
||
}).then((res) => {
|
||
if (res.code == 1) {
|
||
this.$toast({
|
||
title: '解绑成功'
|
||
})
|
||
this.mescroll.resetUpScroll()
|
||
}
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
checkboxChange(e) {
|
||
if (e.value === false) {
|
||
this.user.rule = this.user.rule.filter(function(item) {
|
||
return item !== e.name
|
||
});
|
||
} else {
|
||
this.user.rule.push(e.name)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.content {
|
||
.info {
|
||
background-color: #fff;
|
||
border-radius: 20rpx;
|
||
width: 100%;
|
||
margin: 20rpx 0;
|
||
padding-bottom: 20rpx;
|
||
}
|
||
|
||
.shop-menu {
|
||
background-color: #F6F6F6;
|
||
border-top-left-radius: 30rpx;
|
||
border-top-right-radius: 30rpx;
|
||
|
||
.shop-menu-item {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
background-color: #ffffff;
|
||
margin-bottom: 20rpx;
|
||
border-radius: 20rpx;
|
||
padding: 40rpx 12rpx;
|
||
|
||
.item {
|
||
width: 100%;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.rule {
|
||
padding: 26rpx 0 0;
|
||
flex-wrap: wrap;
|
||
|
||
.assets-item {
|
||
flex: 1;
|
||
}
|
||
|
||
.item {
|
||
width: 50%;
|
||
}
|
||
|
||
.nav-icon {
|
||
width: 52rpx;
|
||
height: 52rpx;
|
||
}
|
||
}
|
||
</style> |