陶杰
2024-12-13 112e2bd2764dd96e1b81439a01882769100b92c1
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>