From 112e2bd2764dd96e1b81439a01882769100b92c1 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期五, 13 十二月 2024 11:04:00 +0800
Subject: [PATCH] 1.子账号相关修改
---
sub_pages/supplier/sub-account/sub-account-list.vue | 4
sub_pages/supplier/sub-account/sub-account-switch-list.vue | 16 +++-
pages/home/supplier-home.vue | 52 ++++++++++++----
sub_pages/supplier/sub-account/sub-account-reg.vue | 35 +++++++++++
pages/user/supplier-user.vue | 55 +++++++++++++++---
store/index.js | 3
6 files changed, 133 insertions(+), 32 deletions(-)
diff --git a/pages/home/supplier-home.vue b/pages/home/supplier-home.vue
index f7c9542..48f8ceb 100644
--- a/pages/home/supplier-home.vue
+++ b/pages/home/supplier-home.vue
@@ -37,10 +37,13 @@
<image class="user-icon" v-if="currentInfo.picture" :src="currentInfo.picture" mode="aspectFit"></image> -->
<view class="name">
- <view class="t1 flex" style="align-items: center; justify-content: space-between;">
+ <view class="t1 flex" style="align-items: center; justify-content: start;">
<!-- {{ (!!currentInfo.supplierDTO?(currentInfo.supplierDTO.name):"") || currentInfo.nickName || currentInfo.loginName || '-'}} -->
<span v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.name">
{{ currentInfo.partnerDTO.name }}
+ </span>
+ <span v-else-if="currentInfo.supplierSub && currentInfo.supplierSub.name">
+ {{ currentInfo.supplierSub.name }}
</span>
<span v-else-if="currentInfo.supplierDTO && currentInfo.supplierDTO.name">
{{ currentInfo.supplierDTO.name }}
@@ -61,14 +64,22 @@
<span v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.status !== 'P'">
({{ currentInfo.partnerDTO ? currentInfo.partnerDTO.statusStr : '' }})</span>
<span v-if="!currentInfo.partnerDTO && currentInfo.type === 'partner'">(信息待完善)</span>
-
- <u--image v-if="selftype === 'supplier' && currentInfo.switchFlag "
- src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/fa/fa6585cd52d54156b5d64fa59af58180switch.png"
- width="10px" height="10px" style="margin-left: 10px; margin-right: 10px;"
- @click="switchSubAccount"></u--image>
- <u--text v-if="selftype === 'supplier' && currentInfo.switchFlag " style="color: black;" text="切换账号" @click="switchSubAccount"></u--text>
+ <view v-if="selftype === 'supplier' && currentInfo.switchFlag " style="margin-left: 10px; display: flex; justify-content: start; align-items: center;">
+ <u--image v-if="selftype === 'supplier' && currentInfo.switchFlag "
+ src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/96/96f6ea502bac4360bf35399e86e463efswitch2.png"
+ width="10px" height="10px" style="margin-left: 20px; margin-right: 20px;"
+ @click="switchSubAccount"></u--image>
+ <!-- <u--text v-if="selftype === 'supplier' && currentInfo.switchFlag " style="color: black;" text="切换账号" @click="switchSubAccount"></u--text> -->
+ <view v-if="selftype === 'supplier' && currentInfo.switchFlag " @click="switchSubAccount" style="font-size: 10px; ">切换账号</view>
+ </view>
</view>
- <view class="t2">{{ currentInfo.tel || '暂无电话' }}</view>
+ <view class="t2 flex " style="align-items: center; justify-content: start;" >
+ <view>{{ currentInfo.supplierSub.phone || currentInfo.tel || '暂无电话' }}</view>
+ <view v-if="selftype === 'supplier'">
+ <view v-if="currentInfo.isSubSupplier" class="account_sub m-l-a m-r-0" >子账号</view>
+ <view v-else class="account_sub m-l-a m-r-0" >主账号</view>
+ </view>
+ </view>
<view class="t2" v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.id">
ID: {{ currentInfo.partnerDTO.id }}
</view>
@@ -338,12 +349,13 @@
},
async onPullDownRefresh() {
// 需要判断当前是否是子账号,如果是子账号则需要刷新账号切换的信息
- const currentInfo = this.$store.state.currentInfo
- if(currentInfo&¤tInfo.supplierSub&¤tInfo.supplierSub.id){
- await this.$store.dispatch('getSwitchSubAccount',currentInfo.supplierSub)
- }else{
- await this.$store.dispatch('getCurrentInfo')
- }
+ // const currentInfo = this.$store.state.currentInfo
+ // if(currentInfo&¤tInfo.supplierSub&¤tInfo.supplierSub.id){
+ // await this.$store.dispatch('getSwitchSubAccount',currentInfo.supplierSub)
+ // }else{
+ // await this.$store.dispatch('getCurrentInfo')
+ // }
+ await this.$store.dispatch('getCurrentInfo')
await this.getTj(true)
uni.stopPullDownRefresh()
},
@@ -635,4 +647,16 @@
box-sizing: border-box;
margin-bottom: 10px;
}
+.account_sub {
+ width: 80rpx;
+ height: 24rpx;
+ border-radius: 30rpx;
+ border: 2rpx solid #23A9F2;
+ font-size: 18rpx;
+ color: white;
+ line-height: 20rpx;
+ text-align: center;
+ background-color: #23A9F2;
+ margin-left: 10px !important;
+}
</style>
\ No newline at end of file
diff --git a/pages/user/supplier-user.vue b/pages/user/supplier-user.vue
index 3aea900..319d298 100644
--- a/pages/user/supplier-user.vue
+++ b/pages/user/supplier-user.vue
@@ -34,12 +34,16 @@
mode="scaleToFill"></image>
<view class="name" v-if="currentInfo.id">
- <view class="t1">
+ <view class="t1 flex" style="align-items: center; justify-content: start;">
+ <!-- <view class="t1"> -->
<!-- {{
(!!currentInfo.partnerDTO ? (currentInfo.partnerDTO.name) : "") || (!!currentInfo.supplierDTO ? (currentInfo.supplierDTO.name) : "") || (!!currentInfo.customerDTO ? (currentInfo.customerDTO.name) : "") || currentInfo.nickName || currentInfo.loginName || '-'
}} -->
<span v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.name">
{{ currentInfo.partnerDTO.name }}
+ </span>
+ <span v-else-if="currentInfo.supplierSub && currentInfo.supplierSub.name">
+ {{ currentInfo.supplierSub.name }}
</span>
<span v-else-if="currentInfo.supplierDTO && currentInfo.supplierDTO.name">
{{ currentInfo.supplierDTO.name }}
@@ -98,8 +102,22 @@
</span>
<!-- #endif -->
+ <view v-if="selftype === 'supplier' && currentInfo.switchFlag " style="margin-left: 10px; display: flex; justify-content: start; align-items: center;">
+ <u--image v-if="selftype === 'supplier' && currentInfo.switchFlag "
+ src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/96/96f6ea502bac4360bf35399e86e463efswitch2.png"
+ width="10px" height="10px" style="margin-left: 20px; margin-right: 20px;"
+ @click="switchSubAccount"></u--image>
+ <!-- <u--text v-if="selftype === 'supplier' && currentInfo.switchFlag " style="color: black;" text="切换账号" @click="switchSubAccount"></u--text> -->
+ <view v-if="selftype === 'supplier' && currentInfo.switchFlag " @click="switchSubAccount" style="font-size: 10px; ">切换账号</view>
+ </view>
</view>
- <view class="t2">{{ currentInfo.tel || '暂无电话' }}</view>
+ <view class="t2 flex " style="align-items: center; justify-content: start;" >
+ <view>{{ currentInfo.supplierSub.phone || currentInfo.tel || '暂无电话' }}</view>
+ <view v-if="selftype === 'supplier'">
+ <view v-if="currentInfo.isSubSupplier" class="account_sub m-l-a m-r-0" >子账号</view>
+ <view v-else class="account_sub m-l-a m-r-0" >主账号</view>
+ </view>
+ </view>
</view>
<view class="name" v-if="!currentInfo.id" open-type="getUserInfo" @click.stop="toCustomerLogin"
style="font-size: 48rpx;margin-top: 16rpx;">
@@ -647,15 +665,21 @@
async onPullDownRefresh() {
// 需要判断当前是否是子账号,如果是子账号则需要刷新账号切换的信息
- const currentInfo = this.$store.state.currentInfo
- if (currentInfo && currentInfo.supplierSub && currentInfo.supplierSub.id) {
- await this.$store.dispatch('getSwitchSubAccount', currentInfo.supplierSub)
- } else {
- await this.$store.dispatch('getCurrentInfo')
- }
+ // const currentInfo = this.$store.state.currentInfo
+ // if (currentInfo && currentInfo.supplierSub && currentInfo.supplierSub.id) {
+ // await this.$store.dispatch('getSwitchSubAccount', currentInfo.supplierSub)
+ // } else {
+ // await this.$store.dispatch('getCurrentInfo')
+ // }
+ await this.$store.dispatch('getCurrentInfo')
uni.stopPullDownRefresh()
},
methods: {
+ switchSubAccount() {
+ uni.navigateTo({
+ url: '/sub_pages/supplier/sub-account/sub-account-switch-list'
+ })
+ },
async bindPartnerUser(userId, name) {
// await this.$message.confirm(`确定要绑定${name}合伙人吗?`)
//调用接口绑定
@@ -822,4 +846,17 @@
@import "./user-customer.scss";
</style>
<!-- #endif -->
-<style lang="scss" scoped></style>
\ No newline at end of file
+<style lang="scss" scoped>
+.account_sub {
+ width: 80rpx;
+ height: 24rpx;
+ border-radius: 30rpx;
+ border: 2rpx solid #23A9F2;
+ font-size: 18rpx;
+ color: white;
+ line-height: 20rpx;
+ text-align: center;
+ background-color: #23A9F2;
+ margin-left: 10px !important;
+}
+</style>
\ No newline at end of file
diff --git a/store/index.js b/store/index.js
index 16b907a..146839b 100644
--- a/store/index.js
+++ b/store/index.js
@@ -223,7 +223,8 @@
const currentInfo = await http.request('get', '/api/supplierSub/getSwitchById', {
params: {
- id:payload.id
+ id:payload.id,
+ type:payload.type
}
})
if (currentInfo && currentInfo.code == 0) {
diff --git a/sub_pages/supplier/sub-account/sub-account-list.vue b/sub_pages/supplier/sub-account/sub-account-list.vue
index 0cc5cf2..979e4aa 100644
--- a/sub_pages/supplier/sub-account/sub-account-list.vue
+++ b/sub_pages/supplier/sub-account/sub-account-list.vue
@@ -10,8 +10,8 @@
<view slot="title" class="cell-title">{{ item.name }}</view>
<view slot="label" class="cell-lable">{{ item.contact }} {{ item.phone }}</view>
<view slot="value" class="cell-value" >
- <u-icon name="edit-pen" @click="handleEdit(item)"></u-icon>
- <u-icon name="trash" @click="handleDel(item)"></u-icon>
+ <u-icon name="edit-pen" @click="handleEdit(item)" size="40"></u-icon>
+ <u-icon name="trash" @click="handleDel(item)" size="40"></u-icon>
</view>
</u-cell>
</u-cell-group>
diff --git a/sub_pages/supplier/sub-account/sub-account-reg.vue b/sub_pages/supplier/sub-account/sub-account-reg.vue
index 7b4d524..39d3bef 100644
--- a/sub_pages/supplier/sub-account/sub-account-reg.vue
+++ b/sub_pages/supplier/sub-account/sub-account-reg.vue
@@ -28,7 +28,7 @@
<u--input type="password" v-model="userInfo.password" border="none" placeholder="请输入密码" clearable></u--input>
</u-form-item>
<u-form-item required label="账号状态" prop="isEnabled" borderBottom>
- <u-switch v-model="userInfo.isEnabled" size="50"></u-switch>
+ <u-switch v-model="userInfo.isEnabled" size="50" @change="handleSwitchchange"></u-switch>
</u-form-item>
</u--form>
<u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
@@ -269,6 +269,39 @@
},
+ async handleSwitchchange(e){
+ if(this.userInfo.id){
+ // 账号的启用,禁用
+ const {
+ code,data
+ } = await this.$http.request('get', '/api/supplierSub/page/isEnable', {
+ params: {
+ id:this.userInfo.id
+ }
+ })
+ if (code == 0) {
+ uni.$u.toast('状态修改成功!');
+ } else {
+ this.userInfo.isEnabled=!e
+ uni.$u.toast('状态修改失败!');
+ }
+ // 还是需要将状态信息重新获取下
+ // const {code2,data2} =await this.getSubAccountById()
+ // if(code2==0){
+ // this.userInfo.isEnabled=data2.isEnabled
+ // }
+ }
+ },
+
+ async getSubAccountById(){
+ return await this.$http.request('get', '/api/supplierSub/getById', {
+ params: {
+ id:this.userInfo.id
+ }
+ })
+
+ },
+
},
}
</script>
diff --git a/sub_pages/supplier/sub-account/sub-account-switch-list.vue b/sub_pages/supplier/sub-account/sub-account-switch-list.vue
index 1b7bba3..e21c2c1 100644
--- a/sub_pages/supplier/sub-account/sub-account-switch-list.vue
+++ b/sub_pages/supplier/sub-account/sub-account-switch-list.vue
@@ -32,14 +32,15 @@
data() {
return {
curSubAccount:'',
- listApi:'/api/supplierSub/sub/all',
+ listApi:'/api/supplierAccount/all',
};
},
onLoad(options) {
- this.getCurrentSubAccount()
+ // this.getCurrentSubAccount()
},
- onShow() {
- this.getList();
+ async onShow() {
+ await this.getList();
+ this.getCurrentSubAccount()
},
async onPullDownRefresh() {
this.getList();
@@ -48,7 +49,12 @@
getCurrentSubAccount(){
const currentInfo = this.$store.state.currentInfo
- this.curSubAccount=currentInfo?.supplierSub?.id
+ if(this.currentInfo.supplierSub){
+ this.curSubAccount=currentInfo?.supplierSub?.id
+ }else{
+ this.curSubAccount=this.list[0].id
+ }
+
},
async handleSwitchSubAccount(item) {
--
Gitblit v1.9.3