From 2cdde4c98b75e3edc9b070e01a905a2b75bf987b Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 10 十月 2025 14:54:16 +0800
Subject: [PATCH] 定制商品不能加入购物车
---
pages/userPermissions/userPermissions.vue | 221 ++++++++++++++++++++++++++++---------------------------
1 files changed, 113 insertions(+), 108 deletions(-)
diff --git a/pages/userPermissions/userPermissions.vue b/pages/userPermissions/userPermissions.vue
index 12cf83f..74d9a78 100644
--- a/pages/userPermissions/userPermissions.vue
+++ b/pages/userPermissions/userPermissions.vue
@@ -2,47 +2,53 @@
<view class="container">
<!-- 鏍囬 -->
<view class="header">
- <text class="title">鐢ㄦ埛鍒楄〃</text>
-
+ <text class="title">搴楀憳鍒楄〃</text>
</view>
<view>
- <button class="add-btn" @click="navigateToAdd()">鏂板鐢ㄦ埛</button>
+ <button class="add-btn" @click="navigateToAdd()">鏂板搴楀憳</button>
</view>
<!-- 鎼滅储妗� -->
<view class="search-box">
- <u-search v-model="query.realName" placeholder="鎼滅储濮撳悕" :showAction="false" @change="searchUser()"></u-search>
+ <u-search v-model="query.realName" placeholder="鎼滅储濮撳悕" :showAction="false" @change="searchClerk()"></u-search>
</view>
- <!-- 鐢ㄦ埛鍒楄〃 -->
- <scroll-view scroll-y class="user-list" @scrolltolower="loadMore" v-if="userList.length > 0">
- <view class="user-item" v-for="(user, index) in userList" :key="user.id" >
+ <!-- 搴楀憳鍒楄〃 -->
+ <scroll-view scroll-y class="clerk-list" @scrolltolower="loadMore" v-if="clerkList.length > 0">
+ <view class="clerk-item" v-for="(clerk, index) in clerkList" :key="clerk.id" >
- <view class="user-info">
- <text class="realName">{{ user.realName }}</text>
- <text class="mobile">{{ user.mobile }}</text>
+ <view class="clerk-info">
+ <text class="realName">{{ clerk.realName ? clerk.realName: '鏈缃汉鍚�' }}</text>
+ <text class="mobile">{{ clerk.mobile }}</text>
</view>
<!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
<view class="action-buttons">
- <u-button type="primary" size="mini" @click.stop="navigateToDetail(user.id)" class="edit-btn">淇敼</u-button>
- <u-button type="error" size="mini" @click.stop="deleteUser(user.id)"
- class="delete-btn">鍒犻櫎</u-button>
- </view>
+ <u-button type="primary" size="mini" @click.stop="restPassword(clerk.memberId)" class="edit-btn" :disabled="!checkPermission(clerk)">閲嶇疆瀵嗙爜</u-button>
+ <u-button type="primary" size="mini" @click.stop="navigateToDetail(clerk.id)" class="edit-btn" :disabled="!checkPermission(clerk)">淇敼</u-button>
+ <u-button type="error" size="mini" @click.stop="deleteUser(clerk.id)"
+ class="delete-btn" :disabled="!checkPermission(clerk)">鍒犻櫎</u-button>
+ </view>
</view>
<!-- 鍔犺浇鏇村鎻愮ず -->
- <view class="load-more" v-if="loading">
- <u-loading :show="loading"></u-loading>
+
+ <view class="load-more">
+ <u-loadmore
+ v-if="clerkList.length > 0"
+ :status="loading ? 'loading' : noMore ? 'nomore' : 'loadmore'"
+ :load-text="{
+ loadmore: '涓婃媺鍔犺浇鏇村',
+ loading: '姝e湪鍔犺浇',
+ nomore: '娌℃湁鏇村浜�'
+ }"
+ />
</view>
- <view class="load-more" v-if="noMoreData">
- <text>娌℃湁鏇村鏁版嵁浜�</text>
+ <view style="height:150rpx">
+
</view>
</scroll-view>
- <!-- 绌虹姸鎬� -->
- <view class="empty" v-else>
- <text>鏆傛棤鐢ㄦ埛鏁版嵁</text>
- </view>
+
</view>
</template>
@@ -51,41 +57,32 @@
getPage,
del,
add,
- update
+ update,
+ restPassword,
+ checkClerkPermission
} from "@/api/userPermissions.js"
- import UIcon from '@/uview-components/uview-ui/components/u-icon/u-icon.vue';
- import UButton from '@/uview-components/uview-ui/components/u-button/u-button.vue';
- import UForm from '@/uview-components/uview-ui/components/u-form/u-form.vue';
- import UFormItem from '@/uview-components/uview-ui/components/u-form-item/u-form-item.vue';
- import UInput from '@/uview-components/uview-ui/components/u-input/u-input.vue';
- import USearch from '@/uview-components/uview-ui/components/u-search/u-search.vue';
- import UPopup from '@/uview-components/uview-ui/components/u-popup/u-popup.vue';
- import ULoading from '@/uview-components/uview-ui/components/u-loading/u-loading.vue'
+ import '@/components/uview-components/uview-ui';
-
+ import storage from "@/utils/storage.js"; //缂撳瓨
+ import {
+ getUserInfo
+ } from "@/api/members";
+
export default {
- components: {
- UIcon,
- UButton,
- UForm,
- UFormItem,
- UInput,
- USearch,
- UPopup,
- ULoading
- },
data() {
return {
- userList: [], // 鐢ㄦ埛鍒楄〃鏁版嵁
+ total:0,
+ clerkList: [], // 搴楀憳鍒楄〃鏁版嵁
loading: false, // 鍔犺浇鐘舵��
- noMoreData: false, // 鏄惁娌℃湁鏇村鏁版嵁
+ noMore: false, // 鏄惁娌℃湁鏇村鏁版嵁
query: {
realName: '',
- page: 1,
- pageSize: 10,
- }
-
-
+ pageNumber: 1,
+ pageSize: 15,
+ },
+ isSuper:false,
+ isShopkeeper:false,
+ clerkId:'',//鐧诲綍璐﹀彿id
}
},
onShow() {
@@ -93,8 +90,42 @@
},
onLoad() {
this.getPage()
+ //鑾峰緱搴楀憳鏉冮檺
+ checkClerkPermission().then(res=>{
+ this.isSuper = res.data.data.isSuper;
+ this.isShopkeeper = res.data.data.isShopkeeper;
+ this.clerkId = res.data.data.clerkId;
+ })
+
},
+
methods: {
+ //妫�鏌ユ潈闄�
+ checkPermission(clerk){
+ if(this.isShopkeeper){
+ return true;
+ }
+ if(this.clerkId === clerk.id){
+ return true;
+ }else{
+ if(this.isSuper && !clerk.isSuper){
+ return true;
+ }
+ return false;
+ }
+
+ },
+ restPassword(id){
+ restPassword(id).then(res=>{
+ if(res.statusCode === 200){
+ uni.showToast({
+ title: res.data.msg, // 鎻愮ず鏂囧瓧
+ icon: 'none', // 鍥炬爣绫诲瀷锛坰uccess/loading/none锛�
+ mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛堥槻姝㈣Е鎽哥┛閫忥級
+ });
+ }
+ })
+ },
async getPage() {
//
uni.showLoading({
@@ -103,42 +134,46 @@
getPage(this.query).then(res => {
uni.hideLoading();
if (res.statusCode === 200) {
- const data = res.data.data;
- if (this.query.page === 1) {
- this.userList = data || [];
- } else {
- // 鍚﹀垯杩藉姞鏁版嵁
- this.userList = [...this.userList, ...(data || [])];
-
- }
+ const newData = res.data.data;
+ // 鏇存柊鎬绘暟鎹噺
+ this.total = res.data.total || 0;
+ // 杩藉姞鎴栨浛鎹㈡暟鎹�
+ this.clerkList = this.query.pageNumber === 1 ?
+ newData :
+ [...this.clerkList, ...newData];
+
+ // 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁
+ this.noMore = newData.length < this.query.pageSize ||
+ this.clerkList.length >= this.total;
+
}
})
},
- // 鎼滅储鐢ㄦ埛
- searchUser() {
- this.query.page = 1
- this.noMoreData = false
- this.userList = []
+ // 鎼滅储搴楀憳
+ searchClerk() {
+ this.query.pageNumber = 1
+ this.noMore = false
+ this.clerkList = []
this.getPage()
},
// 鍔犺浇鏇村
loadMore() {
- if (!this.noMoreData) {
- this.query.page++
+ if (!this.noMore) {
+ this.query.pageNumber++
this.getPage()
}
},
- // 璺宠浆鍒版柊澧炵敤鎴�
+ // 璺宠浆鍒版柊澧炲簵鍛�
navigateToAdd() {
uni.navigateTo({
url: `/pages/userPermissions/addStoreMember`
})
},
- // 璺宠浆鍒扮敤鎴疯鎯�
+ // 璺宠浆鍒板簵鍛樿鎯�
navigateToDetail(id) {
uni.navigateTo({
url: `/pages/userPermissions/addStoreMember?id=${id}`
@@ -150,26 +185,14 @@
this.getPage();
}
})
- }
+ },
+
+
}
}
</script>
<style lang="scss" scoped>
- .user-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx;
- border-bottom: 1rpx solid #f5f5f5;
- }
-
- .user-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
-
.action-buttons {
display: flex;
margin-left: 20rpx;
@@ -219,12 +242,12 @@
margin-bottom: 20rpx;
}
- .user-list {
+ .clerk-list {
flex: 1;
overflow: hidden;
}
- .user-item {
+ .clerk-item {
display: flex;
align-items: center;
padding: 20rpx;
@@ -240,7 +263,7 @@
margin-right: 20rpx;
}
- .user-info {
+ .clerk-info {
flex: 1;
display: flex;
flex-direction: column;
@@ -257,30 +280,12 @@
}
}
}
-
.load-more {
- padding: 20rpx;
- text-align: center;
- color: #999;
- font-size: 28rpx;
- }
+ padding: 20rpx 0;
+ text-align: center;
+ color: #999;
+ font-size: 26rpx;
+ background-color: #f7f8fa;
+ }
- .empty {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 40rpx;
-
- image {
- width: 200rpx;
- margin-bottom: 20rpx;
- }
-
- text {
- color: #999;
- font-size: 28rpx;
- }
- }
</style>
\ No newline at end of file
--
Gitblit v1.8.0