陶杰
2024-12-10 b07889e22f823fac80a66b503671e170668f4ee6
1.供应商子账号
已修改5个文件
已添加4个文件
1018 ■■■■■ 文件已修改
common/authorize.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/supplier-home.vue 130 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/user/supplier-user.vue 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
store/index.js 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sub_pages/supplier/sub-account/sub-account-list.vue 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sub_pages/supplier/sub-account/sub-account-reg.vue 382 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sub_pages/supplier/sub-account/sub-account-switch-list.vue 165 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/authorize.js
对比新文件
@@ -0,0 +1,18 @@
import storage from '../plugins/storage.js'
function hasPermission(permission) {
    // 判断是否是子账号,如果是子账号菜单需要验证权限
    const appMenu=storage.getItem('appMenu');
    // 获取当前登录人信息
    const currentInfo=this.$store.state.currentInfo
    const isSubSupplier=currentInfo.isSubSupplier
    if(isSubSupplier){
      const menu = appMenu.find(element => element.permissionUq === permission);
      return  menu?.subaccountAccessFlag===1?true : false;
    }else{
      // 主账号用所有权限
      return true;
    }
  }
export default hasPermission
main.js
@@ -19,6 +19,9 @@
Vue.mixin(mixinsCommon)
import hasPermission from './common/authorize.js'
Vue.prototype.$hasPermission = hasPermission;
// main.js
import uView from 'uview-ui'
Vue.use(uView)
pages.json
@@ -223,6 +223,26 @@
                        "enablePullDownRefresh": true
                    }
                }
                ,{
                    "path": "sub-account/sub-account-list",
                    "style": {
                        "navigationBarTitleText": "子账号列表",
                        "enablePullDownRefresh": true
                    }
                }
                ,{
                    "path": "sub-account/sub-account-reg",
                    "style": {
                        "navigationBarTitleText": "子账号注册",
                        "enablePullDownRefresh": true
                    }
                },{
                    "path": "sub-account/sub-account-switch-list",
                    "style": {
                        "navigationBarTitleText": "子账号切换",
                        "enablePullDownRefresh": true
                    }
                }
                // #ifdef PUB_SUPPLIER
                , {
                    "path": "supplier-info/supplier-info",
pages/home/supplier-home.vue
@@ -20,8 +20,7 @@
                    ||(currentInfo.supplierDTO&&currentInfo.supplierDTO.cover)
                    ||(currentInfo.partnerDTO&&currentInfo.partnerDTO.cover)
                    || currentInfo.picture
                    " :src="
                    (currentInfo.customerDTO&&currentInfo.customerDTO.cover)
                " :src="(currentInfo.customerDTO && currentInfo.customerDTO.cover)
                    ||(currentInfo.supplierDTO&&currentInfo.supplierDTO.cover)
                    ||(currentInfo.partnerDTO&&currentInfo.partnerDTO.cover)
                    || currentInfo.picture
@@ -38,7 +37,7 @@
                <image class="user-icon" v-if="currentInfo.picture" :src="currentInfo.picture" mode="aspectFit"></image> -->
                <view class="name">
                    <view class="t1">
                    <view class="t1 flex" style="align-items: center; justify-content: space-between;">
                        <!-- {{ (!!currentInfo.supplierDTO?(currentInfo.supplierDTO.name):"") || currentInfo.nickName || currentInfo.loginName || '-'}} -->
                        <span v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.name">
                            {{ currentInfo.partnerDTO.name }}
@@ -62,6 +61,12 @@
                        <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>
                    <view class="t2">{{currentInfo.tel || '暂无电话'}}</view>
                    <view class="t2" v-if="currentInfo.partnerDTO && currentInfo.partnerDTO.id">
@@ -73,7 +78,12 @@
        </view>
        <view class="item-container" :class="[selftype?selftype:'']">
        <view class="item-container" :class="[selftype ? selftype : '']"
            v-if="
                (selftype === 'supplier' && $hasPermission('supplier:workbench:mine:profit'))
            ||  (selftype === 'partner' && $hasPermission('partner:workbench:mine:profit'))
            ">
            <view class="title">我的收益</view>
            <view class="flex tj-container" v-if="selftype==='partner'">
                <view class="tj-each">
@@ -116,7 +126,8 @@
                </view>
            </view>
            <view class="flex tj-container">
                <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=today',true)">
                <view class="tj-each"
                    @click="selftype == 'supplier' && goto('/pages/order/order-delivery?range=today', true)">
                    <view class="num">
                        {{tj.orderCountToday||0}}单
                    </view>
@@ -124,7 +135,8 @@
                        今日订单数
                    </view>
                </view>
                <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=yesterday',true)">
                <view class="tj-each"
                    @click="selftype == 'supplier' && goto('/pages/order/order-delivery?range=yesterday', true)">
                    <view class="num">
                        {{tj.orderCountYesterday||0}}单
                    </view>
@@ -132,7 +144,8 @@
                        昨日订单数
                    </view>
                </view>
                <view class="tj-each" @click="selftype=='supplier'&&goto('/pages/order/order-delivery?range=month',true)">
                <view class="tj-each"
                    @click="selftype == 'supplier' && goto('/pages/order/order-delivery?range=month', true)">
                    <view class="num">
                        {{tj.orderCountMonth||0}}单
                    </view>
@@ -142,7 +155,8 @@
                </view>
            </view>
        </view>
        <view class="item-container flex m-t-12" style="padding: 34rpx 44rpx;" v-if="selftype=='supplier'">
        <view class="item-container flex m-t-12" style="padding: 34rpx 44rpx;"
            v-if="(selftype == 'supplier' && $hasPermission('supplier:workbench:after:sale'))">
            <view class="rate-view flex1" style="max-width: 140rpx;">
                <view class="title">售后率</view>
                <view class="title" style="color: red;">{{((tj.salesRate||0)*100).toFixed(2)}}%</view>
@@ -158,87 +172,115 @@
                <view class="title">{{tj.deliverTotal||0}}扎</view>
            </view>
        </view>
        <view class="m-t-12" @click="getNoticeMore">
        <view v-if="
                (selftype === 'supplier' && $hasPermission('supplier:workbench:notice') )
            ||  (selftype === 'partner' && $hasPermission('partner:workbench:notice'))
            "
            class="m-t-12" @click="getNoticeMore">
            <uni-notice-bar class="notice-bar" color="#333" background-color="#fff" show-get-more show-icon
                :scrollable="scrollable" :text="currentNotice.title||'暂无公告'" :key="currentNotice.id" />
            <span v-if="!currentNotice||!currentNotice.id">&nbsp;</span>
        </view>
        <view class="item-container">
        <view class="item-container  m-t-12"
            v-if="
            (selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions') )
            ||  (selftype === 'partner' && $hasPermission('partner:workbench:common:functions'))
            ">
            <view class="title">常用功能</view>
            <view class="flex order-icons m-t-12">
                <view class="nav row margin-tb" v-if="selftype==='partner'"
            <view class="flex order-icons m-t-12 function-container ">
                <view class="nav row margin-tb function-item "
                v-if="(selftype === 'partner' && $hasPermission('partner:workbench:common:functions:order:management'))"
                    @click="goto('/sub_pages/partner/order-manage/order-manage',true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon ddgl"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/23/23a7ad86e00c4ba28cd962dc4910433cuser-icon-ddgl.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/23/23a7ad86e00c4ba28cd962dc4910433cuser-icon-ddgl.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc tg">订单管理</view>
                </view>
                <view class="nav row margin-tb" v-if="selftype==='supplier'"
                <view class="nav row margin-tb function-item "
                    v-if="(selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions:order:statistics'))"
                    @click="goto('/sub_pages/supplier/order-manage/order-manage',true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon ddgl"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/23/23a7ad86e00c4ba28cd962dc4910433cuser-icon-ddgl.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/23/23a7ad86e00c4ba28cd962dc4910433cuser-icon-ddgl.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc tg">订单统计</view>
                </view>
                <!-- <view class="nav row margin-tb"
                <view
                    v-if="(selftype==='partner' && $hasPermission('partner:workbench:common:functions:bill:settlement'))"
                    class="nav row margin-tb function-item "
                    @click="goto('/sub_pages/supplier/order-settlement/order-settlement',true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon zdjs"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/7b/7b7ed1488fd64f6fa9bc6b557f141f37user-icon-zdjs.png" mode="scaleToFill" />
                    </view>
                    <view class="order-desc tg">账单结算</view>
                </view> -->
                <view class="nav row margin-tb" @click="toFlowManage" v-if="selftype==='supplier'">
                </view>
                <view class="nav row margin-tb function-item " @click="toFlowManage"
                    v-if="selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions:product:management')">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon spgl"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/47/478e007ad07a43ea9f40a962d83cedb4user-icon-spgl.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/47/478e007ad07a43ea9f40a962d83cedb4user-icon-spgl.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc cqw">商品管理</view>
                </view>
                <view class="nav row margin-tb" v-if="selftype==='partner'"
                <view class="nav row margin-tb function-item "
                v-if="(selftype === 'partner' && $hasPermission('partner:workbench:common:functions:markup:configuration'))"
                    @click="goto('/sub_pages/partner/markup-config/markup-config',true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon jjpz"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/93/93356ec339074b49b04c1a3a37146f22user-icon-jjpz.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/93/93356ec339074b49b04c1a3a37146f22user-icon-jjpz.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc tg">加价配置</view>
                </view>
                <view class="nav row margin-tb" @click="goto('/pages/order/order-sale/order-sale',true)">
                <view class="nav row margin-tb function-item "
                    v-if="(selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions:after:sale:claim')) ||
                    (selftype === 'partner' && $hasPermission('partner:workbench:common:functions:after:sale:claim') )"
                    @click="goto('/pages/order/order-sale/order-sale', true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon shlp"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/47/47b54c52e4c2430c8f9e91645fbf9ebduser-icon-shlp.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/47/47b54c52e4c2430c8f9e91645fbf9ebduser-icon-shlp.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc syst">售后理赔</view>
                </view>
    
                <!-- <view class="nav row margin-tb" @click="printDeliveryOrder">
                <!-- <view class="nav row margin-tb function-item " @click="printDeliveryOrder">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon kkjl"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/22/22db478554ec436a8c7e6e89c346767duser-icon-kkjl.png" mode="scaleToFill" />
                    </view>
                    <view class="order-desc wbsp">测试蓝牙</view>
                </view> -->
            </view>
            <view class="flex order-icons m-t-12">
                <view class="nav row margin-tb" v-if="selftype==='supplier'" @click="goto('/sub_pages/supplier/wallet/my-wallet',true)">
            <!-- </view>
            <view class="flex order-icons m-t-12"> -->
                <view class="nav row margin-tb function-item "
                    v-if="(selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions:my:wallet'))" @click="goto('/sub_pages/supplier/wallet/my-wallet', true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon shlp"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/8d/8d72f2df8a4348ac90bfbfb553a9cc71qianbao.png" mode="scaleToFill" />
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/8d/8d72f2df8a4348ac90bfbfb553a9cc71qianbao.png"
                            mode="scaleToFill" />
                    </view>
                    <view class="order-desc syst">我的钱包</view>
                </view>
                <view class="nav row margin-tb">
                    
                </view>
                <view class="nav row margin-tb">
                    
                <view class="nav row margin-tb function-item "
                    v-if="(selftype === 'supplier' && $hasPermission('supplier:workbench:common:functions:sub:account'))"
                    @click="goto('/sub_pages/supplier/sub-account/sub-account-list', true)">
                    <view class="img-c">
                        <image class="icon margin-bottom order-icon shlp"
                            src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/56/56d1a93862a4470e9b4481b970fd6fc9子账号管理.png"
                            mode="scaleToFill" />
                </view>
                <view class="nav row margin-tb">
                    <view class="order-desc syst">子账号</view>
                </view>
                <!-- <view class="nav row margin-tb function-item "></view> -->
            </view>
        </view>
@@ -361,6 +403,11 @@
        },
        methods: {
        switchSubAccount() {
            uni.navigateTo({
                url: '/sub_pages/supplier/sub-account/sub-account-switch-list'
            })
        },
            printDeliveryOrder(item) {
                //蓝牙打印
                var that = this;
@@ -566,5 +613,20 @@
    @import "./home.scss";
</style>
<style lang="scss" scoped>
<style lang="css" scoped>
.function-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-start;
}
.function-item {
  min-width: 25%;
  max-width: 25%;
  text-align: center;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 10px;
}
</style>
pages/user/supplier-user.vue
@@ -103,7 +103,13 @@
                    <!-- getUserProfile -->
                    {{ '点击登陆/注册' }}
                </view>
                <image class="icon-setting" @click="toInfo" src="../../static/common/icon-setting.png" mode="aspectFit">
                <image class="icon-setting"
                    v-if="
                        (selftype==='supplier' && $hasPermission('supplier:mine:setting'))
                        || (selftype==='partner' && $hasPermission('partner:mine:setting') )
                        || (selftype==='customer')
                    "
                    @click="toInfo" src="../../static/common/icon-setting.png" mode="aspectFit">
                </image>
            </view>
            <!-- #ifdef PUB_CUSTOMER -->
@@ -323,14 +329,16 @@
                    <uni-icons type="right"></uni-icons>
                </view>
            </view> -->
            <view class="user-util m-t-12 flex" v-if="selftype==='partner'||!selftype"
            <view class="user-util m-t-12 flex"
                v-if="(selftype==='partner' && $hasPermission('partner:mine:personal:info') )||!selftype"
                @click="goto('/sub_pages/partner/partner-info/partner-info-personal',true)">
                <view class="title">个人资料</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='partner'"
            <view class="user-util m-t-12 flex"
                v-if="selftype==='partner' &&  $hasPermission('partner:mine:partner:info') "
                @click="goto('/sub_pages/partner/partner-info/partner-info',true)">
                <view class="title">合伙人信息</view>
                <view class="right-icon">
@@ -339,7 +347,9 @@
            </view>
            <!-- #ifdef PUB_PARTNER -->
            <view class="user-util m-t-12 flex"
                v-if="selftype==='partner'&&currentInfo.partnerDTO&&currentInfo.partnerDTO.id&&currentInfo.partnerDTO.status=='P'"
                v-if="
                    selftype==='partner'&& $hasPermission('partner:mine:reg:qrcode')
                    &&currentInfo.partnerDTO&&currentInfo.partnerDTO.id&&currentInfo.partnerDTO.status=='P'"
                @click="goto('/sub_pages/partner/partner-info/partner-code',true)">
                <view class="title">推广的注册二维码</view>
                <view class="right-icon">
@@ -365,14 +375,19 @@
            </view>
            <!-- #endif -->
            <view class="user-util m-t-12 flex"
                v-if="selftype==='supplier'&&currentInfo&&currentInfo.id&&currentInfo.supplierDTO&&currentInfo.supplierDTO.status==='P'"
                v-if="
                (selftype==='supplier'&&currentInfo&&currentInfo.id&&currentInfo.supplierDTO&&currentInfo.supplierDTO.status==='P'
                    && $hasPermission('supplier:mine:edit:info')
                )
                "
                @click="goto('/sub_pages/supplier/supplier-info/supplier-info-update',true)">
                <view class="title">信息维护</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='supplier'"
            <view class="user-util m-t-12 flex"
                v-if=" (selftype==='supplier' && $hasPermission('supplier:mine:shop:info') )"
                @click="goto('/sub_pages/supplier/supplier-info/supplier-info',true)">
                <view class="title">店铺信息</view>
                <view class="right-icon">
@@ -388,7 +403,10 @@
            </view> -->
            <view class="user-util m-t-12 flex"
             v-if="selftype==='supplier'||selftype==='partner'"
             v-if="
                (selftype==='supplier' && $hasPermission('supplier:mine:edit:password') )
                || (selftype==='partner' && $hasPermission('partner:mine:edit:password'))
             "
             @click="goto('/pages/user/user-pwd/user-pwd',true)">
                <view class="title">修改密码</view>
                <view class="right-icon">
@@ -402,7 +420,10 @@
                    <uni-icons type="right"></uni-icons>
                </view>
            </view> -->
            <view class="user-util m-t-12 flex" v-if="currentInfo&&currentInfo.id &&(selftype==='supplier'||selftype==='partner') "
            <view class="user-util m-t-12 flex" v-if="
                currentInfo&&currentInfo.id &&
                ((selftype==='supplier' &&  $hasPermission('supplier:mine:bind:wechat') )
                ||(selftype==='partner') &&  $hasPermission('partner:mine:bind:wechat') ) "
                @click="goto('/pages/user/user-bind-wx/user-bind-wx',true)">
                <view class="title">绑定当前微信</view>
                <view class="right-icon">
@@ -418,7 +439,9 @@
            <!-- v-if="selftype==='customer'" -->
            <view class="user-util m-t-12 flex"
              v-if="selftype==='supplier'||selftype==='partner'"
              v-if="
                  (selftype==='supplier' && $hasPermission('supplier:mine:logout')) ||
                (selftype==='partner' &&  $hasPermission('partner:mine:logout')) "
             @click="clearlogout">
                <view class="title">退出登录</view>
                <view class="right-icon">
store/index.js
@@ -19,6 +19,7 @@
        leftWinActive: '/pages/component/view/view',
        activeOpen: '',
        menu: [],
        appMenu: [],
        univerifyErrorMsg: '',
        currentInfo: {}, //个人用户信息
        cache_address: {},
@@ -61,7 +62,9 @@
            state.hasLogin = false
            state.openid = null
            state.currentInfo = {}
            state.appMenu=[]
            storage.removeItem('token')
            storage.removeItem('appMenu');
            message.showToast('退出登录成功')
        },
@@ -196,6 +199,7 @@
        }) {
            //把权限获取到
            // console.log('getCurrentInfo,getCurrentInfo')
            const currentInfo = await http.request('get', '/api/current/user', {})
            if (currentInfo && currentInfo.code == 0) {
                // state.cMenu = cMenu
@@ -212,6 +216,80 @@
                //这种情况就是要跳转到登录页面
            }
        },
        getSwitchSubAccount: async function({commit,state},payload) {
            //把权限获取到
            // console.log('getCurrentInfo,getCurrentInfo')
            const currentInfo = await http.request('get', '/api/supplierSub/getSwitchById', {
                params: {
                    id:payload.id
                }
            })
            if (currentInfo && currentInfo.code == 0) {
                state.currentInfo = currentInfo.data || {}
                state.type = currentInfo.data.type || ''
                state.spacecode = currentInfo.data.spacecode || ''
                commit("updateLogin", true)
            } else {
                commit("updateLogin", false)
                //这种情况就是要跳转到登录页面
            }
            return currentInfo;
        },
        getAppMenu: async function({
            commit,
            state
        }) {
            //把权限获取到
            const menu = await http.request('get', '/api/app/menu/permission/menu', {})
            storage.setItem('appMenu', []);
            if (menu && menu.code == 0) {
                const appMenu = menu.data || []
                storage.setItem('appMenu', appMenu);
                // commit("updateLogin", true)
            } else {
                // commit("updateLogin", false)
                //这种情况就是要跳转到登录页面
            }
        },
        getAppMenuSupplier: async function({
            commit,
            state
        }) {
            //把权限获取到
            const menu = await http.request('get', '/api/app/menu/supplier/permission/menu', {})
            storage.setItem('appMenu', []);
            if (menu && menu.code == 0) {
                const appMenu = menu.data || []
                storage.setItem('appMenu', appMenu);
            } else {
            }
        },
        getAppMenuPartner: async function({
            commit,
            state
        }) {
            //把权限获取到
            const menu = await http.request('get', '/api/app/menu/partner/permission/menu', {})
            storage.setItem('appMenu', []);
            if (menu && menu.code == 0) {
                const appMenu = menu.data || []
                storage.setItem('appMenu', appMenu);
            } else {
            }
        },
        loginwx: async function({
            dispatch,
            commit,
@@ -302,6 +380,8 @@
                    storage.setItem('token', resp.data.access_token)
                    commit("updateLogin", true)
                    await dispatch('getCurrentInfo')
                    // 获取所有权限菜单
                    await dispatch('getAppMenuPartner')
                    uni.reLaunch({
                        url: '/pages/home/supplier-home'
                    })
@@ -367,6 +447,8 @@
                    storage.setItem('token', resp.data.access_token)
                    commit("updateLogin", true)
                    await dispatch('getCurrentInfo')
                    // 获取所有供应商权限菜单
                    await dispatch('getAppMenuSupplier')
                    console.log('login,reLaunch')
                    // #ifdef APP
sub_pages/supplier/sub-account/sub-account-list.vue
对比新文件
@@ -0,0 +1,177 @@
<template>
    <view class="u-page">
      <view class="u-demo-block-2">
        <u-cell-group>
          <u-cell v-for="(item, index) in list" :key="index"
        >
            <view slot="icon" class="f10">
              <u-icon name="account"></u-icon>
            </view>
            <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>
            </view>
          </u-cell>
        </u-cell-group>
        <u-button type="primary" text="新增" customStyle="margin-top: 50px; width:100%;" @click="handleAdd"></u-button>
      </view>
    </view>
</template>
  <script>
  export default {
    data() {
      return {
          listApi:'/api/supplierSub/sub/all',
      };
    },
    onLoad(options) {},
    onShow() {
      this.getList();
    },
    async onPullDownRefresh() {
      this.getList();
    },
    methods: {
        handleEdit(item) {
            uni.navigateTo({
                url: `/sub_pages/supplier/sub-account/sub-account-reg?id=${item.id}`
            })
        },
        async handleDel(item) {
            await this.$message.confirm('确定要删除吗?')
            const {
                code
            } = await this.$http.request('post', `/api/supplierSub/delete/${item.id}`, {
                data: {
                }
            })
            if (code == 0) {
                uni.$u.toast('删除成功');
                this.getList();
            } else {
            }
        },
        handleAdd() {
            uni.navigateTo({
                url: '/sub_pages/supplier/sub-account/sub-account-reg'
            })
        },
    //   getList(refresh = false) {
    //     // /api/supplier/delivery
    //     if (this.currentInfo.id && (this.currentInfo.id !== this.cacheUserId || refresh)) {
    //       this.cacheUserId = this.currentInfo.id;
    //       let that = this;
    //       setTimeout(() => {
    //         //其他统计
    //         // #ifdef PUB_SUPPLIER
    //         this.$http.request('get', '/v2/wallet/supplier', {}).then(res => {
    //           if (res.code === 0) {
    //             that.wallet = res.data || {};
    //           }
    //         });
    //         // #endif
    //       }, 200);
    //     }
    //   }
    }
  };
  </script>
  <style lang="scss">
  .u-page {
    font-size: 14px;
    .image-icon {
      width: 30rpx;
      height: 30rpx;
    }
    .u-button--plain.data-v-3bf2dba7 {
      background-color: #00BCD4 !important;
    }
    .u-button--plain.u-button--primary.data-v-3bf2dba7 {
      color: #FFFFFF;
    }
    .u-button--primary.data-v-3bf2dba7 {
      color: #fff;
      border-color: #00BCD4 !important;
      border-width: 1px;
      border-style: solid;
      border-radius: 10rpx;
      width: 200rpx;
    }
    .u-demo-block {
      padding: 10rpx;
      background-color: #FFFFFF;
      border-radius: 50rpx;
      background-color: #00AF68;
      margin: 20rpx;
      .tixian {
        margin-top: 30rpx;
        margin-bottom: 30rpx;
      }
    }
    .u-demo-block-2 {
      margin: 30rpx;
      padding: 10rpx;
      background-color: #FFFFFF;
      border-radius: 10rpx;
    }
    .title {
      text-align: center;
      font-size: 30rpx;
      color: #909399;
      margin: 10rpx;
    }
    .grid-text-white {
      color: white;
    }
    .grid-text {
      font-size: 14px;
      color: #909399;
      padding: 10rpx 0 20rpx 0rpx;
      /* #ifndef APP-PLUS */
      box-sizing: border-box;
      /* #endif */
    }
    .statis_val {
      font-size: 16px;
      color: black;
      // font-weight: bold;
    }
    .margin-10 {
      margin: 10rpx;
    }
    .cell-title{
        font-size: 12px;
    }
    .cell-lable{
        font-size: 10px;
        color: gray;
    }
    .cell-value{
        display: flex;
        justify-content: space-between;
        width: 50px;
    }
  }
  </style>
sub_pages/supplier/sub-account/sub-account-reg.vue
对比新文件
@@ -0,0 +1,382 @@
<template>
    <view class="u-page">
        <view class="u-demo-block">
            <view class="u-demo-block__content">
                <!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
                <u--form labelPosition="left" :rules="rules" :model="userInfo" ref="subAccountForm"
                    :labelWidth="labelWidth">
                    <u-form-item required label="子账号名称" prop="name" borderBottom>
                        <u--input v-model="userInfo.name" border="none" placeholder="请输入子账号名称" clearable></u--input>
                    </u-form-item>
                    <u-form-item required label="联系人" prop="contact" borderBottom>
                        <u--input v-model="userInfo.contact" border="none" placeholder="请输入联系人" clearable></u--input>
                    </u-form-item>
                    <u-form-item required label="手机" prop="phone" borderBottom>
                        <u--input type="number" v-model="userInfo.phone" border="none" placeholder="请输入手机号码" clearable></u--input>
                    </u-form-item>
                    <u-form-item required label="验证码" prop="smsCode" borderBottom>
                        <u--input type="number" v-model="userInfo.smsCode" border="none" placeholder="请填写验证码" clearable></u--input>
                        <u-button slot="right" @tap="getCode" :text="tips" type="success" size="mini"
                            :disabled="disabled1"></u-button>
                    </u-form-item>
                    <u-form-item required label="密码" prop="password" borderBottom>
                        <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-form-item>
                </u--form>
                <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
                <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
            </view>
        </view>
    </view>
</template>
<script>
export default {
    data() {
        return {
            labelWidth: '180',
            tips: '获取验证码',
            disabled1: false,// 校验是否禁用
            timer: null, // 倒计时计时器
            count:60,
            // #ifdef PUB_SUPPLIER
            apitype: 'supplier',
            // #endif
            // #ifdef PUB_PARTNER
            apitype: 'partner',
            // #endif
            // #ifdef PUB_CUSTOMER
            apitype: 'customer',
            // #endif
            userInfo: {
                id: '',
                name: '',
                contact: '',
                phone: '',
                smsCode: '',
                password: '',
                isEnabled: true,
            },
            rules: {
                'name': [{
                    type: 'string',
                    required: true,
                    message: '请输入子账号名称',
                    trigger: ['blur', 'change']
                }
                    // , {
                    //     validator: (rule, value, callback) => {
                    //         return uni.$u.test.chinese(value);
                    //     },
                    //     message: "姓名必须为中文",
                    //     trigger: ["change", "blur"],
                    // }
                ],
                'contact': {
                    type: 'string',
                    required: true,
                    message: '请输入联系人',
                    trigger: ['blur', 'change']
                },
                'phone': [{
                    type: 'string',
                    required: true,
                    message: '请输入电话号码',
                    trigger: ['blur', 'change']
                }, {
                    pattern: /^1[3-9]\d{9}$/,
                    message: '请输入有效的手机号码',
                    trigger: ['blur', 'change'],
                },
                ],
                'smsCode': {
                    type: 'string',
                    required: true,
                    message: '请输入验证码',
                    trigger: ['blur', 'change']
                },
                'password': [{
                    type: 'string',
                    required: true,
                    message: '请输入密码',
                    trigger: ['blur', 'change']
                },
                {
                    validator: (rule, value, callback) => {
                        if (!value) {
                            callback(new Error('请输入密码'));
                        } else if (value.length < 8 || value.length > 20) {
                            callback(new Error('密码长度需为 8 到 20 位'));
                        } else {
                            callback(); // 校验通过
                        }
                    },
                    trigger: ['blur', 'change']
                },
                ]
            },
        }
    },
    onReady() {
        // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则
        this.$refs.subAccountForm.setRules(this.rules)
    },
    onUnload() {
        // 组件销毁时清除计时器
        if (this.timer) {
            clearInterval(this.timer);
        }
    },
    onLoad(options) {
        this.userInfo.id = options.id || ''
        if(this.userInfo.id){
            this.getSubAccount()
            // 修改topbar标题
            uni.setNavigationBarTitle({
                title: '子账号修改'
            });
        }
    },
    onShow() {
      this.getList();
    },
    methods: {
        async getSubAccount(){
            const {
                code,data
            } = await this.$http.request('get', '/api/supplierSub/getById', {
                params: {
                    id:this.userInfo.id
                }
            })
            if (code == 0) {
                this.userInfo = {
                    ...data
                }
                this.userInfo.password=''
            } else {
            }
        },
        validatePhone(phone) {
            const phoneRegex = /^[1][3-9]\d{9}$/; // 简单的中国大陆手机号正则
            return phoneRegex.test(phone);
        },
        async getCode() {
            // 校验手机号格式
            if (!this.validatePhone(this.userInfo.phone)) {
                uni.showToast({
                    title: '请输入有效的手机号码',
                    icon: 'none'
                });
                return;
            }
            if (this.disabled1) return; // 防止重复点击
            const {
                code
            } = await this.$http.request('post', '/api/sms/send/code', {
                data: {
                    tel: this.userInfo.phone,
                    userType: this.apitype.toLowerCase()
                }
            })
            if (code == 0) {
                uni.$u.toast('验证码已发送');
                this.startCountdown(); // 开始倒计时
            } else {
            }
        },
        startCountdown() {
            this.disabled1 = true; // 禁用按钮
            this.tips = `${this.count}秒后重试`; // 设置按钮文本
            this.timer = setInterval(() => {
                if (this.count > 1) {
                    this.count--;
                    this.tips = `${this.count}秒后重试`;
                } else {
                    this.resetCountdown(); // 倒计时结束,重置状态
                }
            }, 1000);
        },
        resetCountdown() {
            clearInterval(this.timer); // 清除计时器
            this.timer = null;
            this.count = 60; // 重置秒数
            this.tips = '获取验证码'; // 重置按钮文本
            this.disabled1 = false; // 启用按钮
        },
        submit() {
            // 如果有错误,会在catch中返回报错信息数组,校验通过则在then中返回true
                this.$refs.subAccountForm.validate().then(async res => {
                    uni.$u.toast('校验通过')
                    const {
                    code
                } = await this.$http.request('post', '/api/supplierSub/addOrUpdate', {
                    data: {
                        ... this.userInfo
                    }
                })
                if (code == 0) {
                    uni.$u.toast('新增子账号成功');
                    uni.navigateTo({
                        url: '/sub_pages/supplier/sub-account/sub-account-list'
                    })
                } else {
                    uni.$u.toast('新增子账号失败')
                }
            }).catch(errors => {
                uni.$u.toast('请填写完整信息')
            })
        },
        reset() {
            this.$refs.subAccountForm.resetFields()
            this.$refs.subAccountForm.clearValidate()
            this.userInfo={
                id: '',
                name: '',
                contact: '',
                phone: '',
                smsCode: '',
                password: '',
                isEnabled: true,
            }
        },
    },
}
</script>
<style lang="scss">
.u-page {
    background-color: #f7f8fa;
    fonst-size: 14px;
    padding: 15px 15px 40px 15px;
    .u-demo-block {
        flex: 1;
        margin-bottom: 23px
    }
}
.u-page2 {
    background-color: #f7f8fa;
    padding: 15px 15px 40px 15px;
    .u-demo-block {
        flex: 1;
        margin-bottom: 23px
    }
    .u-demo-block__title {
        font-size: 14px;
        color: #8f9ca2;
        margin-bottom: 8px;
        display: flex;
        flex-direction: row
    }
    .u-demo-block__content {
        display: flex;
        flex-direction: column
    }
    .image-icon {
        width: 30rpx;
        height: 30rpx;
    }
    .u-button--plain.data-v-3bf2dba7 {
        background-color: #00BCD4 !important;
    }
    .u-button--plain.u-button--primary.data-v-3bf2dba7 {
        color: #FFFFFF;
    }
    .u-button--primary.data-v-3bf2dba7 {
        color: #fff;
        border-color: #00BCD4 !important;
        border-width: 1px;
        border-style: solid;
        border-radius: 10rpx;
        width: 200rpx;
    }
    .u-demo-block {
        padding: 10rpx;
        background-color: #FFFFFF;
        border-radius: 50rpx;
        background-color: #00AF68;
        margin: 20rpx;
        .tixian {
            margin-top: 30rpx;
            margin-bottom: 30rpx;
        }
    }
    .u-demo-block-2 {
        margin: 30rpx;
        padding: 10rpx;
        background-color: #FFFFFF;
        border-radius: 10rpx;
    }
    .title {
        text-align: center;
        font-size: 30rpx;
        color: #909399;
        margin: 10rpx;
    }
    .grid-text-white {
        color: white;
    }
    .grid-text {
        font-size: 14px;
        color: #909399;
        padding: 10rpx 0 20rpx 0rpx;
        /* #ifndef APP-PLUS */
        box-sizing: border-box;
        /* #endif */
    }
    .statis_val {
        font-size: 16px;
        color: black;
        // font-weight: bold;
    }
    .margin-10 {
        margin: 10rpx;
    }
}
</style>
sub_pages/supplier/sub-account/sub-account-switch-list.vue
对比新文件
@@ -0,0 +1,165 @@
<template>
    <view class="u-page">
        <view class="u-demo-block-2">
            <u-radio-group v-model="curSubAccount" placement="column">
                <u-cell-group>
                    <u-cell v-for="(item, index) in list" :key="index" @click="handleSwitchSubAccount(item)">
                        <view slot="icon" class="f10">
                            <!-- <image src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/56/56d1a93862a4470e9b4481b970fd6fc9子账号管理.png" class="image-icon"></image> -->
                            <u-radio  :key="index"
                                :name="item.id" @change="handleSwitchSubAccount(item)"
                                >
                                <u-icon name="account"></u-icon>
                            </u-radio>
                        </view>
                        <view slot="title" class="cell-title">{{ item.name }} {{ item.contact }} {{ item.phone }}</view>
                        <!-- <view slot="label" class="cell-lable">{{ item.name2 }} {{ item.tel }}</view> -->
                        <view slot="value" class="cell-value">
                        </view>
                    </u-cell>
                </u-cell-group>
            </u-radio-group>
        </view>
    </view>
</template>
<script>
export default {
    data() {
        return {
            curSubAccount:'',
            listApi:'/api/supplierSub/sub/all',
        };
    },
    onLoad(options) {
        this.getCurrentSubAccount()
    },
    onShow() {
        this.getList();
    },
    async onPullDownRefresh() {
        this.getList();
    },
    methods: {
        getCurrentSubAccount(){
            const currentInfo = this.$store.state.currentInfo
            this.curSubAccount=currentInfo?.supplierSub?.id
        },
        async handleSwitchSubAccount(item) {
            let res=await this.$store.dispatch('getSwitchSubAccount',item);
            if (res && res.code == 0) {
                const data=res.data
                if(data&&data.supplierSub&&data.supplierSub.id){
                    this.curSubAccount=data?.supplierSub?.id
                    uni.$u.toast('切换成功!');
                }
                uni.navigateBack({ delta: 1 })
            } else {
                uni.$u.toast('切换失败!');
            }
        },
    }
};
</script>
<style lang="scss">
.u-page {
    font-size: 14px;
    .image-icon {
        width: 30rpx;
        height: 30rpx;
    }
    .u-button--plain.data-v-3bf2dba7 {
        background-color: #00BCD4 !important;
    }
    .u-button--plain.u-button--primary.data-v-3bf2dba7 {
        color: #FFFFFF;
    }
    .u-button--primary.data-v-3bf2dba7 {
        color: #fff;
        border-color: #00BCD4 !important;
        border-width: 1px;
        border-style: solid;
        border-radius: 10rpx;
        width: 200rpx;
    }
    .u-demo-block {
        padding: 10rpx;
        background-color: #FFFFFF;
        border-radius: 50rpx;
        background-color: #00AF68;
        margin: 20rpx;
        .tixian {
            margin-top: 30rpx;
            margin-bottom: 30rpx;
        }
    }
    .u-demo-block-2 {
        margin: 30rpx;
        padding: 10rpx;
        background-color: #FFFFFF;
        border-radius: 10rpx;
    }
    .title {
        text-align: center;
        font-size: 30rpx;
        color: #909399;
        margin: 10rpx;
    }
    .grid-text-white {
        color: white;
    }
    .grid-text {
        font-size: 14px;
        color: #909399;
        padding: 10rpx 0 20rpx 0rpx;
        /* #ifndef APP-PLUS */
        box-sizing: border-box;
        /* #endif */
    }
    .statis_val {
        font-size: 16px;
        color: black;
        // font-weight: bold;
    }
    .margin-10 {
        margin: 10rpx;
    }
    .cell-title {
        font-size: 12px;
    }
    .cell-lable {
        font-size: 10px;
        color: gray;
    }
    .cell-value {
        display: flex;
        justify-content: space-between;
        width: 50px;
    }
}
</style>