From 00a96d6881dd10ae7d3c4f5437bfceaabe677723 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 14 十一月 2024 10:55:29 +0800
Subject: [PATCH] bug修复

---
 miniprogram_npm/tdesign-miniprogram/radio/radio.js |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/miniprogram_npm/tdesign-miniprogram/radio/radio.js b/miniprogram_npm/tdesign-miniprogram/radio/radio.js
index 38f9c0a..eb63752 100644
--- a/miniprogram_npm/tdesign-miniprogram/radio/radio.js
+++ b/miniprogram_npm/tdesign-miniprogram/radio/radio.js
@@ -35,13 +35,7 @@
         };
         this.lifetimes = {
             attached() {
-                this.initStatus();
-            },
-            ready() {
-                var _a, _b, _c, _d;
-                this.setData({
-                    _placement: (_d = (_a = this.data.placement) !== null && _a !== void 0 ? _a : (_c = (_b = this.$parent) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.placement) !== null && _d !== void 0 ? _d : 'left',
-                });
+                this.init();
             },
         };
         this.properties = Object.assign(Object.assign({}, Props), { borderless: {
@@ -62,38 +56,44 @@
             optionLinked: false,
             iconVal: [],
             _placement: '',
+            _disabled: false,
+        };
+        this.observers = {
+            disabled(v) {
+                this.setData({ _disabled: v });
+            },
         };
         this.methods = {
             handleTap(e) {
-                if (this.data.disabled)
-                    return;
+                const { _disabled, readonly, contentDisabled } = this.data;
                 const { target } = e.currentTarget.dataset;
-                if (target === 'text' && this.data.contentDisabled)
+                if (_disabled || readonly || (target === 'text' && contentDisabled))
                     return;
                 this.doChange();
             },
             doChange() {
-                const { value, checked } = this.data;
+                const { value, checked, allowUncheck } = this.data;
                 if (this.$parent) {
-                    this.$parent.updateValue(value);
+                    this.$parent.updateValue(checked && allowUncheck ? null : value);
                 }
                 else {
-                    this._trigger('change', { checked: !checked });
+                    this._trigger('change', { checked: checked && allowUncheck ? false : !checked });
                 }
             },
-            initStatus() {
-                var _a, _b;
+            init() {
+                var _a, _b, _c, _d, _e, _f;
                 const { icon } = this.data;
                 const isIdArr = Array.isArray(((_a = this.$parent) === null || _a === void 0 ? void 0 : _a.icon) || icon);
                 this.setData({
                     customIcon: isIdArr,
                     slotIcon: icon === 'slot',
                     iconVal: isIdArr ? ((_b = this.$parent) === null || _b === void 0 ? void 0 : _b.icon) || icon : [],
+                    _placement: (_f = (_c = this.data.placement) !== null && _c !== void 0 ? _c : (_e = (_d = this.$parent) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.placement) !== null && _f !== void 0 ? _f : 'left',
                 });
             },
             setDisabled(disabled) {
                 this.setData({
-                    disabled: this.data.disabled || disabled,
+                    _disabled: this.data.disabled || disabled,
                 });
             },
         };

--
Gitblit v1.9.3