storeBelieveInLight 1 年之前
父節點
當前提交
e4e1bb701f

+ 45 - 33
components/editor.vue

@@ -2,10 +2,7 @@
2 2
   <view class="container">
3 3
     <view class="page-body">
4 4
       <view class="wrapper">
5
-        <view
6
-          class="toolbar"
7
-          @tap="format"
8
-        >
5
+        <view class="toolbar" @tap="format">
9 6
           <view
10 7
             :class="formats.bold ? 'ql-active' : ''"
11 8
             class="iconfont icon-zitijiacu"
@@ -18,7 +15,7 @@
18 15
             data-name="italic"
19 16
           >
20 17
           </view>
21
-           <view class="iconfont icon-charutupian" @tap="insertImage"></view>
18
+          <view class="iconfont icon-charutupian" @tap="insertImage"></view>
22 19
           <view
23 20
             :class="formats.underline ? 'ql-active' : ''"
24 21
             class="iconfont icon-zitixiahuaxian"
@@ -134,7 +131,7 @@
134 131
             data-value="+1"
135 132
           ></view>
136 133
           <view class="iconfont icon-fengexian" @tap="insertDivider"></view>
137
-         
134
+
138 135
           <view
139 136
             :class="formats.header === 1 ? 'ql-active' : ''"
140 137
             class="iconfont icon-format-header-1"
@@ -185,63 +182,75 @@ export default {
185 182
       type: String,
186 183
       default: "",
187 184
     },
188
-	placeholder:{
189
-		type:String,
190
-		default:"请输入商品详情信息..."
191
-	},
192
-	readOnly:{
193
-		type:Boolean,
194
-		default:false
195
-	
196
-	}
185
+    placeholder: {
186
+      type: String,
187
+      default: "请输入商品详情信息...",
188
+    },
189
+    readOnly: {
190
+      type: Boolean,
191
+      default: false,
192
+    },
197 193
   },
198 194
   data() {
199 195
     return {
200 196
       richText: "",
201 197
       formats: {},
198
+      editorCtx: null,
199
+      // 新增:记录光标位置
200
+      cursorPosition: 0,
201
+      // 新增:记录当前选中的文本
202
+      selectedText: "",
202 203
     };
203 204
   },
204 205
   watch: {
205
-    value:{
206
-      handler(val){
207
-         this.richText = val
206
+    value: {
207
+      handler(val,old) {
208
+         this.richText = val;
208 209
          console.log(val)
209
-         if(val){
210
-          this.$nextTick(()=>{
211
-            // this.onEditorReady()
212
-          })
213
-         }
210
+        // this.setHTMLContent();
214 211
       },
215
-      deep:true,
216 212
     },
217 213
   },
218
-  mounted(){
219
-     this.richText = this.value;
220
-    //  this.onEditorReady()
214
+  mounted() {
215
+    this.richText = this.value;
216
+    if (this.richText) {
217
+      this.setHTMLContent();
218
+    }
221 219
   },
222 220
   methods: {
221
+    setHTMLContent(data) {
222
+      if (this.editorCtx) {
223
+        this.editorCtx.setContents({
224
+          html:data|| this.richText,
225
+        });
226
+      }
227
+    },
223 228
     readOnlyChange() {
224 229
       this.readOnly = !this.readOnly;
225 230
     },
226
-    onEditorReady() {
231
+    async onEditorReady() {
227 232
       // 富文本节点渲染完成
233
+      await this.$nextTick();
228 234
       const query = uni.createSelectorQuery().in(this);
229 235
       query
230 236
         .select("#editor")
231 237
         .context((res) => {
232 238
           this.editorCtx = res.context;
233
-          if (this.value) {
234
-            this.editorCtx.setContents({
235
-              html: this.value,
236
-            });
239
+          console.log(this.richText, "this.richTextthis.richText");
240
+          if (this.richText) {
241
+            this.setHTMLContent();
237 242
           }
238 243
         })
239
-        .exec(this);
244
+        .exec();
240 245
     },
241 246
     // 失去焦点时,获取富文本的内容
242 247
     getCtx(e) {
243 248
       this.richText = e.detail.html;
244 249
       this.$emit("input", e.detail.html);
250
+      // 记录光标位置
251
+      // this.cursorPosition = this.editorCtx.getSelection().index;
252
+      // 记录当前选中的文本
253
+      // this.selectedText = this.editorCtx.getSelectedText();
245 254
     },
246 255
     undo() {
247 256
       this.editorCtx.undo();
@@ -256,6 +265,9 @@ export default {
256 265
       this.editorCtx.format(name, value);
257 266
     },
258 267
     onStatusChange(e) {
268
+      console.log(e, "onStatusChange");
269
+      e.preventDefault();
270
+      e.stopPropagation();
259 271
       const formats = e.detail;
260 272
       this.formats = formats;
261 273
     },

+ 2 - 0
index.html

@@ -2,6 +2,8 @@
2 2
 <html lang="en">
3 3
   <head>
4 4
     <meta charset="UTF-8" />
5
+    <script src="/static/quill.min.js"></script>
6
+   <script src="/static/image-resize-3.0.1.min.js"></script>
5 7
     <script>
6 8
       var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
7 9
         CSS.supports('top: constant(a)'))

+ 2 - 1
shop/commodity/components/orderList/orderListCard.vue

@@ -169,7 +169,8 @@ export default {
169 169
     formatPropsValue(data, type) {
170 170
 		if(type=="user_phone"){
171 171
 			if(!data[type]) return "暂无用户手机号码"
172
-			return MaskRules.mobile(data[type])
172
+			// return MaskRules.mobile(data[type])
173
+			return data[type]
173 174
 		}else if(type == "status") {
174 175
 			return getOrderListStatus(data[type])
175 176
 		}else {

+ 299 - 177
shop/components/cascade-picker.vue

@@ -1,77 +1,114 @@
1 1
 <template name="cascade-picker">
2
-  <view class="aui-picker" v-if="SHOW" :class="{'aui-picker-in': FADE==1,'aui-picker-out': FADE==0}">
2
+  <view
3
+    class="aui-picker"
4
+    v-if="SHOW"
5
+    :class="{ 'aui-picker-in': FADE == 1, 'aui-picker-out': FADE == 0 }"
6
+  >
3 7
     <view class="aui-mask" @click.stop="close"></view>
4 8
     <view class="aui-picker-main">
5 9
       <view class="aui-picker-header">
6 10
         <view class="aui-picker-header-icon" @click.stop="close">取消</view>
7 11
         <view class="aui-picker-title" v-if="title">{{ title }}</view>
8
-        <view class="aui-picker-header-icon aui-picker-confirm" @click.stop="_confirm">确认</view>
12
+        <view
13
+          class="aui-picker-header-icon aui-picker-confirm"
14
+          @click.stop="_confirm"
15
+          >确认</view
16
+        >
9 17
       </view>
10 18
       <view class="aui-picker-nav">
11
-        <view class="aui-picker-navitem"
12
-              v-if="nav.length>0"
13
-              v-for="(item, index) in nav"
14
-              :key="index"
15
-              :data-index="index"
16
-              :class="[index==navCurrentIndex ? 'active' : '', 'aui-picker-navitem-'+index]"
17
-              :style="{margin: nav.length>2 ? '0 25rpx 0 0' : '0 45rpx 0 0'}"
18
-              @click.stop="_changeNav($event)"
19
-        >{{ item.name }}
19
+        <view
20
+          class="aui-picker-navitem"
21
+          v-if="nav.length > 0"
22
+          v-for="(item, index) in nav"
23
+          :key="index"
24
+          :data-index="index"
25
+          :class="[
26
+            index == navCurrentIndex ? 'active' : '',
27
+            'aui-picker-navitem-' + index,
28
+          ]"
29
+          :style="{ margin: nav.length > 2 ? '0 25rpx 0 0' : '0 45rpx 0 0' }"
30
+          @click.stop="_changeNav($event)"
31
+          >{{ item.name }}
20 32
         </view>
21
-        <view class="aui-picker-navitem"
22
-              :key="nav.length"
23
-              :data-index="nav.length"
24
-              :class="[nav.length==navCurrentIndex ? 'active' : '', 'aui-picker-navitem-'+nav.length]"
25
-              :style="{margin: nav.length>2 ? '0 25rpx 0 0' : '0 45rpx 0 0'}"
26
-              @click.stop="_changeNav($event)">请选择
33
+        <view
34
+          class="aui-picker-navitem"
35
+          :key="nav.length"
36
+          :data-index="nav.length"
37
+          :class="[
38
+            nav.length == navCurrentIndex ? 'active' : '',
39
+            'aui-picker-navitem-' + nav.length,
40
+          ]"
41
+          :style="{ margin: nav.length > 2 ? '0 25rpx 0 0' : '0 45rpx 0 0' }"
42
+          @click.stop="_changeNav($event)"
43
+          >请选择
27 44
         </view>
28
-        <view class="aui-picker-navborder" :style="{left: navBorderLeft+'px'}"></view>
45
+        <view
46
+          class="aui-picker-navborder"
47
+          :style="{ left: navBorderLeft + 'px' }"
48
+        ></view>
29 49
       </view>
30 50
       <view class="aui-picker-content">
31 51
         <view class="aui-picker-lists">
32
-          <view class="aui-picker-list"
33
-                v-for="(list, index) in queryItems.length + 1"
34
-                :key="index"
35
-                :data-index="index"
36
-                :class="[index==navCurrentIndex ? 'active' : '']"
52
+          <view
53
+            class="aui-picker-list"
54
+            v-for="(list, index) in queryItems.length + 1"
55
+            :key="index"
56
+            :data-index="index"
57
+            :class="[index == navCurrentIndex ? 'active' : '']"
37 58
           >
38 59
             <view class="aui-picker-list-warp" v-if="index == 0">
39
-              <view class="aui-picker-item"
40
-                    v-for="(item, key) in items"
41
-                    v-if="item.pid=='0'"
42
-                    :key="key"
43
-                    :data-pindex="index"
44
-                    :data-index="key"
45
-                    :data-id="item.id"
46
-                    :data-pid="item.pid"
47
-                    :data-name="item.name"
48
-                    :data-type="item.type"
49
-                    :class="{'active': result.length>index && result[index].id==item.id}"
50
-                    :style="{'background': touchConfig.index==key && touchConfig.pindex==index ? touchConfig.style.background : ''}"
51
-                    @click.stop="_chooseItem($event)"
52
-                    @touchstart="_btnTouchStart($event)"
53
-                    @touchmove="_btnTouchEnd($event)"
54
-                    @touchend="_btnTouchEnd($event)"
55
-              >{{ item.name }}
60
+              <view
61
+                class="aui-picker-item"
62
+                v-for="(item, key) in items"
63
+                v-if="item.pid == '0'"
64
+                :key="key"
65
+                :data-pindex="index"
66
+                :data-index="key"
67
+                :data-id="item.id"
68
+                :data-pid="item.pid"
69
+                :data-name="item.name"
70
+                :data-type="item.type"
71
+                :class="{
72
+                  active: result.length > index && result[index].id == item.id,
73
+                }"
74
+                :style="{
75
+                  background:
76
+                    touchConfig.index == key && touchConfig.pindex == index
77
+                      ? touchConfig.style.background
78
+                      : '',
79
+                }"
80
+                @click.stop="_chooseItem($event)"
81
+                @touchstart="_btnTouchStart($event)"
82
+                @touchmove="_btnTouchEnd($event)"
83
+                @touchend="_btnTouchEnd($event)"
84
+                >{{ item.name }}
56 85
               </view>
57 86
             </view>
58 87
             <view class="aui-picker-list-warp" v-else>
59
-              <view class="aui-picker-item"
60
-                    v-for="(item, key) in queryItems[index-1]"
61
-                    :key="key"
62
-                    :data-pindex="index"
63
-                    :data-index="key"
64
-                    :data-id="item.id"
65
-                    :data-pid="item.pid"
66
-                    :data-name="item.name"
67
-                    :data-type="item.type"
68
-                    :class="{'active': result.length>index && result[index].id==item.id}"
69
-                    :style="{'background': touchConfig.index==key && touchConfig.pindex==index ? touchConfig.style.background : ''}"
70
-                    @click.stop="_chooseItem($event)"
71
-                    @touchstart="_btnTouchStart($event)"
72
-                    @touchmove="_btnTouchEnd($event)"
73
-                    @touchend="_btnTouchEnd($event)"
74
-              >{{ item.name }}
88
+              <view
89
+                class="aui-picker-item"
90
+                v-for="(item, key) in queryItems[index - 1]"
91
+                :key="key"
92
+                :data-pindex="index"
93
+                :data-index="key"
94
+                :data-id="item.id"
95
+                :data-pid="item.pid"
96
+                :data-name="item.name"
97
+                :data-type="item.type"
98
+                :class="{
99
+                  active: result.length > index && result[index].id == item.id,
100
+                }"
101
+                :style="{
102
+                  background:
103
+                    touchConfig.index == key && touchConfig.pindex == index
104
+                      ? touchConfig.style.background
105
+                      : '',
106
+                }"
107
+                @click.stop="_chooseItem($event)"
108
+                @touchstart="_btnTouchStart($event)"
109
+                @touchmove="_btnTouchEnd($event)"
110
+                @touchend="_btnTouchEnd($event)"
111
+                >{{ item.name }}
75 112
               </view>
76 113
             </view>
77 114
           </view>
@@ -83,24 +120,32 @@
83 120
 
84 121
 <script>
85 122
 export default {
86
-  name: 'cascade-picker',
123
+  name: "cascade-picker",
87 124
   props: {
88
-    title: { //标题
125
+    title: {
126
+      //标题
89 127
       type: String,
90
-      default: ''
128
+      default: "",
91 129
     },
92
-    layer: { //控制几级联动,默认无限级(跟随数据有无下级)
130
+    layer: {
131
+      //控制几级联动,默认无限级(跟随数据有无下级)
93 132
       type: Number,
94
-      default: null
133
+      default: null,
95 134
     },
96
-    data: { //数据 如:[{id: '', name: '', children: [{id: '', name: ''}]}]
135
+    data: {
136
+      //数据 如:[{id: '', name: '', children: [{id: '', name: ''}]}]
97 137
       type: Array,
98 138
       default() {
99 139
         return [
100 140
           // [{id: '', name: '', children: [{id: '', name: ''}]}]
101
-        ]
102
-      }
103
-    }
141
+        ];
142
+      },
143
+    },
144
+    value: {
145
+      // 新增初始选中值
146
+      type: Array,
147
+      default: () => [],
148
+    },
104 149
   },
105 150
   data() {
106 151
     return {
@@ -116,27 +161,27 @@ export default {
116 161
         index: -1,
117 162
         pindex: -1,
118 163
         style: {
119
-          color: '#214579',
120
-          background: '#EFEFEF'
121
-        }
164
+          color: "#214579",
165
+          background: "#EFEFEF",
166
+        },
122 167
       },
123
-      selectedData: [] // 用于回显数据的属性
124
-    }
168
+      selectedData: [], // 用于回显数据的属性
169
+    };
125 170
   },
126 171
   watch: {
127 172
     data() {
128 173
       const _this = this;
129 174
       const data = _this.data;
130
-      _this.items = _this._flatten(data, '0')
131
-      console.log(_this.items,"_this.items")
132
-    }
175
+      _this.items = _this._flatten(data, "0");
176
+      console.log(_this.items, "_this.items");
177
+    },
133 178
   },
134 179
   methods: {
135 180
     // 打开
136 181
     open() {
137 182
       const _this = this;
138 183
       _this.reset(); //打开时重置picker
139
-    //   _this._restoreSelectedData()
184
+      //   _this._restoreSelectedData()
140 185
       return new Promise(function (resolve, reject) {
141 186
         _this.SHOW = true;
142 187
         _this.FADE = 1;
@@ -153,7 +198,7 @@ export default {
153 198
           _this.FADE = -1;
154 199
           clearTimeout(_hidetimer);
155 200
           resolve();
156
-        }, 100)
201
+        }, 100);
157 202
       });
158 203
     },
159 204
     //重置
@@ -170,10 +215,15 @@ export default {
170 215
       const _this = this;
171 216
       const index = Number(e.currentTarget.dataset.index);
172 217
       _this.navCurrentIndex = index;
173
-      const _el = uni.createSelectorQuery().in(this).select(".aui-picker-navitem-" + index);
174
-      _el.boundingClientRect(data => {
175
-        _this.navBorderLeft = data.left + 10;
176
-      }).exec();
218
+      const _el = uni
219
+        .createSelectorQuery()
220
+        .in(this)
221
+        .select(".aui-picker-navitem-" + index);
222
+      _el
223
+        .boundingClientRect((data) => {
224
+          _this.navBorderLeft = data.left + 10;
225
+        })
226
+        .exec();
177 227
     },
178 228
     //数据选择
179 229
     _chooseItem(e) {
@@ -183,54 +233,93 @@ export default {
183 233
       const pid = e.currentTarget.dataset.pid;
184 234
       const type = e.currentTarget.dataset.type;
185 235
       const _arr = [];
186
-      _this.result[_this.navCurrentIndex] = {id: id, name: name, pid: pid, type: type};
236
+      // _this.result[_this.navCurrentIndex] = {
237
+      //   id: id,
238
+      //   name: name,
239
+      //   pid: pid,
240
+      //   type: type,
241
+      // };
242
+      const item = {
243
+        id: e.currentTarget.dataset.id,
244
+        name: e.currentTarget.dataset.name,
245
+        pid: e.currentTarget.dataset.pid,
246
+        type: e.currentTarget.dataset.type,
247
+      };
248
+      // 清除后续层级数据
249
+      _this.result = _this.result.slice(0, _this.navCurrentIndex + 1);
250
+      _this.result[_this.navCurrentIndex] = item;
251
+      _this.queryItems = _this.queryItems.slice(0, _this.navCurrentIndex);
252
+      _this.nav = _this.nav.slice(0, _this.navCurrentIndex);
187 253
       if (
188
-        (!_this._isDefine(_this.layer) && _this._isDefine(_this._deepQuery(_this.data, id).children))
189
-        ||
190
-        (_this.navCurrentIndex < (Number(_this.layer) - 1) && _this._isDefine(_this._deepQuery(_this.data, id).children))
191
-      ) { //有下级数据
192
-        _this._deepQuery(_this.data, id).children.forEach(function (item, index) {
193
-          _arr.push({id: item.id, name: item.name, pid: id, type: item.type});
194
-        });
195
-        if (_this.navCurrentIndex == _this.queryItems.length) { //选择数据
254
+        (!_this._isDefine(_this.layer) &&
255
+          _this._isDefine(_this._deepQuery(_this.data, id).children)) ||
256
+        (_this.navCurrentIndex < Number(_this.layer) - 1 &&
257
+          _this._isDefine(_this._deepQuery(_this.data, id).children))
258
+      ) {
259
+        //有下级数据
260
+        _this
261
+          ._deepQuery(_this.data, id)
262
+          .children.forEach(function (item, index) {
263
+            _arr.push({
264
+              id: item.id,
265
+              name: item.name,
266
+              pid: id,
267
+              type: item.type,
268
+            });
269
+          });
270
+        if (_this.navCurrentIndex == _this.queryItems.length) {
271
+          //选择数据
196 272
           _this.queryItems.push(_arr);
197
-          _this.nav.push({name: name});
198
-        } else { //重新选择数据
273
+          _this.nav.push({ name: name });
274
+        } else {
275
+          //重新选择数据
199 276
           _this.queryItems.splice(_this.navCurrentIndex + 1, 1);
200 277
           _this.nav.splice(_this.navCurrentIndex + 1, 1);
201 278
           _this.queryItems.splice(_this.navCurrentIndex, 1, _arr);
202
-          _this.nav.splice(_this.navCurrentIndex, 1, {name: name});
279
+          _this.nav.splice(_this.navCurrentIndex, 1, { name: name });
203 280
         }
204 281
         _this.navCurrentIndex = _this.navCurrentIndex + 1;
205
-        const _el = uni.createSelectorQuery().in(this).select(".aui-picker-navitem-" + _this.navCurrentIndex);
282
+        const _el = uni
283
+          .createSelectorQuery()
284
+          .in(this)
285
+          .select(".aui-picker-navitem-" + _this.navCurrentIndex);
206 286
         setTimeout(() => {
207
-          _el.boundingClientRect(data => {
208
-            _this.navBorderLeft = data.left + 10;
209
-          }).exec();
210
-        }, 100)
211
-      } else { //无下级数据且最后一级数据的type为1时,则可以确认关闭
212
-    //   console.log(_this.result,type,"typetypetypetypetype",e.currentTarget.dataset)
287
+          _el
288
+            .boundingClientRect((data) => {
289
+              _this.navBorderLeft = data.left + 10;
290
+            })
291
+            .exec();
292
+        }, 100);
293
+      } else {
294
+        //无下级数据且最后一级数据的type为1时,则可以确认关闭
295
+        //   console.log(_this.result,type,"typetypetypetypetype",e.currentTarget.dataset)
213 296
         _this._confirm();
214 297
       }
215 298
     },
299
+    _hasChildren(id) {
300
+      return this._deepQuery(this.data, id)?.children?.length > 0;
301
+    },
216 302
     _confirm() {
217 303
       const _this = this;
218 304
       const lastItem = _this.result[_this.result.length - 1];
219
-      console.log(lastItem)
220
-      console.log(_this.result)
305
+      console.log(lastItem);
306
+      console.log(_this.result);
221 307
       if (lastItem && lastItem.type === 1) {
222 308
         _this.close().then(() => {
223
-            _this.selectedData = [..._this.result]; // 保存选择的数据
224
-          _this.$emit("callback", {status: 0, data: _this.result});
309
+          _this.selectedData = [..._this.result]; // 保存选择的数据
310
+          _this.$emit("callback", { status: 0, data: _this.result });
225 311
         });
226 312
       } else {
227
-        uni.$u.toast('请选择最后一级分类')
313
+        uni.$u.toast("请选择最后一级分类");
228 314
       }
229 315
     },
230 316
     //递归遍历——将树形结构数据转化为数组格式
231 317
     _flatten(tree, pid) {
232
-      return tree.reduce((arr, {id, name, type, children = []}) =>
233
-        arr.concat([{id, name, pid, type}], this._flatten(children, id)), [])
318
+      return tree.reduce(
319
+        (arr, { id, name, type, children = [] }) =>
320
+          arr.concat([{ id, name, pid, type }], this._flatten(children, id)),
321
+        []
322
+      );
234 323
     },
235 324
     //根据id查询对应的数据(如查询id=10100对应的对象)
236 325
     _deepQuery(tree, id) {
@@ -258,7 +347,16 @@ export default {
258 347
      @example: aui.isDefine("变量");
259 348
      */
260 349
     _isDefine(str) {
261
-      if (str == null || str == "" || str == "undefined" || str == undefined || str == "null" || str == "(null)" || str == 'NULL' || typeof (str) == 'undefined') {
350
+      if (
351
+        str == null ||
352
+        str == "" ||
353
+        str == "undefined" ||
354
+        str == undefined ||
355
+        str == "null" ||
356
+        str == "(null)" ||
357
+        str == "NULL" ||
358
+        typeof str == "undefined"
359
+      ) {
262 360
         return false;
263 361
       } else {
264 362
         str = str + "";
@@ -283,47 +381,72 @@ export default {
283 381
       _this.touchConfig.index = -1;
284 382
       _this.touchConfig.pindex = -1;
285 383
     },
286
-     // 恢复选择的数据
384
+    // 恢复选择的数据
287 385
     _restoreSelectedData() {
288 386
       const _this = this;
289
-      console.log(_this.selectedData, "selectedData")
290
-      if (_this.selectedData.length > 0) {
291
-        _this.result = [..._this.selectedData];
292
-        _this.queryItems = [];
293
-        _this.nav = [];
294
-        _this.navCurrentIndex = 0;
295
-        _this.selectedData.forEach((item, index) => {
296
-          _this.result[index] = item;
297
-          if (index > 0) {
298
-            const parent = _this._deepQuery(_this.data, item.pid);
299
-            if (parent && parent.children) {
300
-              _this.queryItems[index - 1] = parent.children.map(child => ({
301
-                id: child.id,
302
-                name: child.name,
303
-                pid: child.pid,
304
-                type: child.type
305
-              }));
306
-              _this.nav[index - 1] = {name: parent.name};
307
-            }
308
-          }
309
-        });
310
-        _this.navCurrentIndex = _this.selectedData.length - 1;
311
-        const lastItem = _this.selectedData[_this.selectedData.length - 1];
312
-        if (lastItem) {
313
-          const _el = uni.createSelectorQuery().in(_this).select(".aui-picker-navitem-" + _this.navCurrentIndex);
314
-        setTimeout(() => {
315
-              _el.boundingClientRect(data => {
316
-            // _this.navBorderLeft = data?.left + 10;
317
-            console.log(data, "data")
318
-          }).exec();
319
-        },50)
320
-            _this.$emit("callback", {status: 1, data: _this.result});
321
-        }
387
+      if (_this.selectedData.length === 0) return;
388
+
389
+      // 验证数据有效性
390
+      const isValid = _this.selectedData.every((item) =>
391
+        _this._deepQuery(_this.data, item.id)
392
+      );
393
+      if (!isValid) {
394
+        uni.showToast({ title: "无效的初始数据", icon: "none" });
395
+        return;
322 396
       }
323
-    
397
+
398
+      _this.reset();
399
+      _this.result = [..._this.selectedData];
400
+
401
+      // 构建各级数据
402
+      _this.selectedData.forEach((item, index) => {
403
+        if (index === 0) return;
404
+
405
+        const parent = _this._deepQuery(_this.data, item.pid);
406
+        if (parent && parent.children) {
407
+          _this.queryItems[index - 1] = parent.children.map((child) => ({
408
+            id: child.id,
409
+            name: child.name,
410
+            pid: child.pid,
411
+            type: child.type,
412
+          }));
413
+          _this.nav[index - 1] = { name: parent.name };
414
+        }
415
+      });
416
+
417
+      _this.navCurrentIndex = _this.selectedData.length - 1;
418
+
419
+      // 计算导航栏位置
420
+      setTimeout(() => {
421
+        const _el = uni
422
+          .createSelectorQuery()
423
+          .in(_this)
424
+          .select(`.aui-picker-navitem-${_this.navCurrentIndex}`);
425
+        _el
426
+          .boundingClientRect((data) => {
427
+            _this.navBorderLeft = data.left + 10;
428
+          })
429
+          .exec();
430
+      }, 100);
431
+
432
+      // 更新选中状态
433
+      _this.$nextTick(() => {
434
+        _this._updateSelectedStyle();
435
+      });
324 436
     },
325
-  }
326
-}
437
+    // 更新选中样式
438
+    _updateSelectedStyle() {
439
+      const _this = this;
440
+      _this.result.forEach((item, index) => {
441
+        const list = index === 0 ? _this.items : _this.queryItems[index - 1];
442
+        const targetItem = list.find((i) => i.id === item.id);
443
+        if (targetItem) {
444
+          targetItem.active = true;
445
+        }
446
+      });
447
+    },
448
+  },
449
+};
327 450
 </script>
328 451
 
329 452
 <style lang="scss" scoped>
@@ -346,7 +469,7 @@ $custom-content-color: #1f7cff;
346 469
 .aui-mask {
347 470
   width: 100%;
348 471
   height: 100%;
349
-  background: rgba(0, 0, 0, .3);
472
+  background: rgba(0, 0, 0, 0.3);
350 473
   position: absolute;
351 474
   left: 0;
352 475
   top: 0;
@@ -354,23 +477,23 @@ $custom-content-color: #1f7cff;
354 477
 }
355 478
 
356 479
 .aui-picker.aui-picker-in {
357
-  -moz-animation: aui-fade-in .1s ease-out forwards;
358
-  -ms-animation: aui-fade-in .1s ease-out forwards;
359
-  -webkit-animation: aui-fade-in .1s ease-out forwards;
360
-  animation: aui-fade-in .1s ease-out forwards;
480
+  -moz-animation: aui-fade-in 0.1s ease-out forwards;
481
+  -ms-animation: aui-fade-in 0.1s ease-out forwards;
482
+  -webkit-animation: aui-fade-in 0.1s ease-out forwards;
483
+  animation: aui-fade-in 0.1s ease-out forwards;
361 484
 }
362 485
 
363 486
 .aui-picker.aui-picker-out {
364
-  -moz-animation: aui-fade-out .1s ease-out forwards;
365
-  -ms-animation: aui-fade-out .1s ease-out forwards;
366
-  -webkit-animation: aui-fade-out .1s ease-out forwards;
367
-  animation: aui-fade-out .1s ease-out forwards;
487
+  -moz-animation: aui-fade-out 0.1s ease-out forwards;
488
+  -ms-animation: aui-fade-out 0.1s ease-out forwards;
489
+  -webkit-animation: aui-fade-out 0.1s ease-out forwards;
490
+  animation: aui-fade-out 0.1s ease-out forwards;
368 491
 }
369 492
 
370 493
 .aui-picker-main {
371 494
   width: 100vw;
372 495
   height: 50vh;
373
-  background: #FFF;
496
+  background: #fff;
374 497
   position: absolute;
375 498
   left: 0rpx;
376 499
   bottom: 0;
@@ -378,17 +501,17 @@ $custom-content-color: #1f7cff;
378 501
 }
379 502
 
380 503
 .aui-picker.aui-picker-in .aui-picker-main {
381
-  -moz-animation: aui-slide-up-screen .2s ease-out forwards;
382
-  -ms-animation: aui-slide-up-screen .2s ease-out forwards;
383
-  -webkit-animation: aui-slide-up-screen .2s ease-out forwards;
384
-  animation: aui-slide-up-screen .2s ease-out forwards;
504
+  -moz-animation: aui-slide-up-screen 0.2s ease-out forwards;
505
+  -ms-animation: aui-slide-up-screen 0.2s ease-out forwards;
506
+  -webkit-animation: aui-slide-up-screen 0.2s ease-out forwards;
507
+  animation: aui-slide-up-screen 0.2s ease-out forwards;
385 508
 }
386 509
 
387 510
 .aui-picker.aui-picker-out .aui-picker-main {
388
-  -moz-animation: aui-slide-down-screen .2s ease-out forwards;
389
-  -ms-animation: aui-slide-down-screen .2s ease-out forwards;
390
-  -webkit-animation: aui-slide-down-screen .2s ease-out forwards;
391
-  animation: aui-slide-down-screen .2s ease-out forwards;
511
+  -moz-animation: aui-slide-down-screen 0.2s ease-out forwards;
512
+  -ms-animation: aui-slide-down-screen 0.2s ease-out forwards;
513
+  -webkit-animation: aui-slide-down-screen 0.2s ease-out forwards;
514
+  animation: aui-slide-down-screen 0.2s ease-out forwards;
392 515
 }
393 516
 
394 517
 .aui-picker-header {
@@ -417,14 +540,14 @@ $custom-content-color: #1f7cff;
417 540
 }
418 541
 
419 542
 .aui-picker-header::after {
420
-  content: '';
543
+  content: "";
421 544
   width: 100%;
422
-  height:2rpx;
423
-  background: rgba(100, 100, 100, .3);
424
-  -moz-transform: scaleY(.3);
425
-  -ms-transform: scaleY(.3);
426
-  -webkit-transform: scaleY(.3);
427
-  transform: scaleY(.3);
545
+  height: 2rpx;
546
+  background: rgba(100, 100, 100, 0.3);
547
+  -moz-transform: scaleY(0.3);
548
+  -ms-transform: scaleY(0.3);
549
+  -webkit-transform: scaleY(0.3);
550
+  transform: scaleY(0.3);
428 551
   position: absolute;
429 552
   left: 0;
430 553
   bottom: 0;
@@ -466,14 +589,14 @@ $custom-content-color: #1f7cff;
466 589
 }
467 590
 
468 591
 .aui-picker-nav::after {
469
-  content: '';
592
+  content: "";
470 593
   width: 100%;
471 594
   height: 2rpx;
472
-  background: rgba(100, 100, 100, .3);
473
-  -moz-transform: scaleY(.3);
474
-  -ms-transform: scaleY(.3);
475
-  -webkit-transform: scaleY(.3);
476
-  transform: scaleY(.3);
595
+  background: rgba(100, 100, 100, 0.3);
596
+  -moz-transform: scaleY(0.3);
597
+  -ms-transform: scaleY(0.3);
598
+  -webkit-transform: scaleY(0.3);
599
+  transform: scaleY(0.3);
477 600
   position: absolute;
478 601
   left: 0;
479 602
   bottom: 0;
@@ -501,7 +624,7 @@ $custom-content-color: #1f7cff;
501 624
   height: 6rpx;
502 625
   background: $custom-content-color;
503 626
   border-radius: 10rpx;
504
-  transition: left .15s;
627
+  transition: left 0.15s;
505 628
   position: absolute;
506 629
   left: 60rpx;
507 630
   bottom: 0;
@@ -551,12 +674,11 @@ $custom-content-color: #1f7cff;
551 674
 }
552 675
 
553 676
 .aui-picker-item.active::after {
554
-  content: '✔';
677
+  content: "✔";
555 678
   font-size: 25rpx;
556 679
   color: $custom-content-color;
557 680
   position: absolute;
558 681
   top: 0rpx;
559 682
   right: 20rpx;
560 683
 }
561
-
562 684
 </style>

+ 82 - 16
shop/productManagementModule/addProduct.vue

@@ -44,7 +44,15 @@
44 44
         <!-- 平台商品分类 -->
45 45
         <view class="form-item-box">
46 46
           <view class="form-box-txt">平台商品分类</view>
47
-          <view
47
+          <uni-data-picker
48
+           v-model="pingtaifeilei.id"
49
+            placeholder="请选择平台商品分类"
50
+           :localdata="pingtaiData" popup-title="平台商品分类" 
51
+           @change="handleChangePintai"
52
+           @nodeclick="handleNodeClickPintai"
53
+          >
54
+          </uni-data-picker>
55
+          <!-- <view
48 56
             class="form-box--arae"
49 57
             @click="handleClickpingtai"
50 58
             :class="[pingtaifeilei.name == '' ? 'classification' : '']"
@@ -56,7 +64,7 @@
56 64
             size="26"
57 65
             class="icon-boxx"
58 66
             color="#333"
59
-          ></uni-icons>
67
+          ></uni-icons> -->
60 68
         </view>
61 69
         <!-- 商品名称 -->
62 70
         <view class="form-item-box">
@@ -328,7 +336,11 @@
328 336
       <!-- 商品详情 -->
329 337
       <view class="business-box pb15">
330 338
         <view class="business-box-txt">商品详情 </view>
331
-        <customEditor :value="formData.content" @input="changeTextHandle" />
339
+        <customEditor
340
+          :value="formData.content"
341
+          ref="customEditorRefs"
342
+          @input="changeTextHandle"
343
+        />
332 344
       </view>
333 345
     </view>
334 346
     <view class="btn-list">
@@ -347,6 +359,7 @@
347 359
       :title="cascadepintaiPicker.title"
348 360
       :layer="cascadepintaiPicker.layer"
349 361
       :data="cascadepintaiPicker.data"
362
+      :value="cascadepintaiPicker.selectedValue"
350 363
       @callback="pickerCallbackpintai"
351 364
     />
352 365
   </view>
@@ -357,7 +370,7 @@
357 370
 import headersVue from "../components/headers/headers.vue";
358 371
 import uploadVue from "./components/upload.vue";
359 372
 import cascadePicker from "../components/cascade-picker.vue";
360
-import { reNameKeys } from "@/utils/index";
373
+import { reNameKeys,reTextKeys } from "@/utils/index";
361 374
 import customEditor from "@/components/editor.vue";
362 375
 import {
363 376
   getGoodsClass,
@@ -384,8 +397,9 @@ export default {
384 397
     return {
385 398
       base_commission: "", //商户分润比例
386 399
       cascadeData: [], //商户商品分类
387
-      pingtaifeiData: [], //平台商品分类:
400
+      pingtaiData: [], //平台商品分类:
388 401
       priceDefault: "0.00",
402
+
389 403
       cascadePicker: {
390 404
         title: "选择商户商品分类",
391 405
         layer: null,
@@ -395,6 +409,7 @@ export default {
395 409
         title: "选择平台商品分类",
396 410
         layer: null,
397 411
         data: [],
412
+        selectedValue: [],
398 413
       },
399 414
       classification: {
400 415
         //商户商品分类
@@ -404,7 +419,7 @@ export default {
404 419
       pingtaifeilei: {
405 420
         //平台商品分类:
406 421
         name: "",
407
-        id: "",
422
+        id: 0,
408 423
       },
409 424
       extensionStatus: "0", //是否单独设置:0默认设置 1单独设置
410 425
       specialMerchant: "",
@@ -501,7 +516,12 @@ export default {
501 516
           this.formData.extension_type = String(data.extension_type);
502 517
           this.formData.cate_id = data.cate_id;
503 518
           this.formData.store_info = data.store_info;
504
-          this.formData.content = data.content;
519
+          this.formData.content = data.content || "";
520
+
521
+          this.$nextTick(() => {
522
+            this.$refs.customEditorRefs.setHTMLContent(this.formData.content);
523
+          });
524
+
505 525
           this.attrValueForm.extension_one = attrValue.extension_one;
506 526
           this.attrValueForm.cost = attrValue.cost;
507 527
           this.priceDefault = attrValue.price;
@@ -510,14 +530,8 @@ export default {
510 530
           this.attrValueForm.bar_code = attrValue.bar_code;
511 531
           this.attrValueForm.weight = attrValue.weight;
512 532
           this.attrValueForm.volume = attrValue.volume;
513
-          console.log(this.fengMianImage, "this.fengMianImage999");
514
-          console.log(this.pingtaiData, "this.fengMianImage999his.pingtaiData");
515
-          let dataArr = this.convertToFlatArray(this.pingtaiData);
516 533
           console.log(this.fengMianImage, "this.fengMianImage99945454545");
517
-          const findObj =
518
-            dataArr.find((item) => item.value == data.cate_id) || {};
519
-          this.pingtaifeilei.name = findObj.label || "";
520
-          this.pingtaifeilei.id = findObj.value || data.cate_id || "";
534
+          this.pingtaifeilei.id = data.cate_id || 0;
521 535
           console.log(this.base_commission, "this.base_commission");
522 536
           this.getCalcAfterPrice({
523 537
             extension_one: attrValue.extension_one,
@@ -635,7 +649,9 @@ export default {
635 649
         const res = await getGoodsClassCategory();
636 650
         if (res.data.status == 200) {
637 651
           const data = res.data.data || [];
638
-          this.pingtaiData = reNameKeys(data);
652
+          // this.pingtaiData = reNameKeys(data);
653
+          this.pingtaiData = reTextKeys(data)
654
+          console.log(this.pingtaiData)
639 655
         }
640 656
       } catch (error) {}
641 657
     },
@@ -683,7 +699,13 @@ export default {
683 699
       const { data } = e;
684 700
       const lastItem = data[data.length - 1];
685 701
       this.selectData = data || [];
686
-      console.log(lastItem, "pickerCallback99999pintai");
702
+      this.cascadepintaiPicker.selectedValue = data;
703
+      console.log(
704
+        lastItem,
705
+        "pickerCallback99999pintai",
706
+        this.cascadepintaiPicker
707
+      );
708
+
687 709
       this.pingtaifeilei = lastItem || {};
688 710
     },
689 711
     bindTextAreaBlur(e) {
@@ -991,6 +1013,18 @@ export default {
991 1013
       const regex = /^\d+(\.\d{1,2})?$/;
992 1014
       return regex.test(input);
993 1015
     },
1016
+    // /平台分类
1017
+    handleChangePintai({detail}){
1018
+      let data = detail.value || []
1019
+       const lastItem = data[data.length - 1];
1020
+      console.log(detail, "handleChangePintai平台分类");
1021
+      this.cascadepintaiPicker.id = lastItem.value
1022
+      this.cascadepintaiPicker.name = lastItem.text
1023
+
1024
+    },
1025
+    handleNodeClickPintai(data){
1026
+      console.log(data, "handleNodeClickPintai平台分类");
1027
+    }
994 1028
   },
995 1029
   computed: {
996 1030
     shangpingleixing() {
@@ -1374,4 +1408,36 @@ page {
1374 1408
   padding-bottom: 15rpx;
1375 1409
   color: #ff6010;
1376 1410
 }
1411
+/deep/.uni-data-tree-dialog{
1412
+  .dialog-caption{
1413
+    padding:15rpx 0;
1414
+      border-bottom: 2rpx solid #f8f8f8;
1415
+      background: #c5d6ee;
1416
+    .title-area{
1417
+    font-size: 30rpx;
1418
+    font-weight: 700;
1419
+    color:#666;
1420
+    }
1421
+  }
1422
+  .uni-data-pickerview{
1423
+    .selected-area{
1424
+      .selected-item{
1425
+        padding: 20rpx 0;
1426
+        font-size: 28rpx;
1427
+         font-weight: 700;
1428
+        &.selected-item-active{
1429
+          color: #1f7cff;
1430
+          
1431
+        }
1432
+      }
1433
+    }
1434
+
1435
+  }
1436
+  .uni-scroll-view-content{
1437
+    .item{
1438
+      font-size: 28rpx;
1439
+      border-bottom: 2rpx solid #f8f8f8;
1440
+    }
1441
+  }
1442
+}
1377 1443
 </style>

File diff suppressed because it is too large
+ 1236 - 0
static/image-resize-3.0.1.min.js


File diff suppressed because it is too large
+ 8 - 0
static/quill.min.js


+ 16 - 0
utils/index.js

@@ -181,4 +181,20 @@ export function reNameKeys(data=[]) {
181 181
     }
182 182
     return newItem;
183 183
   });
184
+}
185
+
186
+
187
+export function reTextKeys(data = []) {
188
+	return data.map(item => {
189
+		const newItem = {
190
+			text: item.label,
191
+			value: item.value,
192
+			type: item.children ? 0 : 1,
193
+			selected: item.selected || false,
194
+		};
195
+		if (item.children && Array.isArray(item.children)) {
196
+			newItem.children = reTextKeys(item.children);
197
+		}
198
+		return newItem;
199
+	});
184 200
 }