@10yun/cv-mobile-ui 0.5.20 → 0.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/package.json +1 -1
  2. package/plugins/jumps.js +57 -12
  3. package/plugins/lbs.js +17 -8
  4. package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
  5. package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
  6. package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
  7. package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
  8. package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
  9. package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
  10. package/uni-ui/lib/uni-card/uni-card.vue +124 -1
  11. package/uni-ui/lib/uni-col/uni-col.vue +1 -1
  12. package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
  13. package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
  14. package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
  15. package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
  16. package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
  17. package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
  18. package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
  19. package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
  20. package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
  21. package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
  22. package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
  23. package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
  24. package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
  25. package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
  26. package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
  27. package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
  28. package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
  29. package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
  30. package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
  31. package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
  32. package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
  33. package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
  34. package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
  35. package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
  36. package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
  37. package/uni-ui/lib/uni-group/uni-group.vue +85 -1
  38. package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
  39. package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
  40. package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
  41. package/uni-ui/lib/uni-list/uni-list.vue +81 -1
  42. package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
  43. package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
  44. package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
  45. package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
  46. package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
  47. package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
  48. package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
  49. package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
  50. package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
  51. package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
  52. package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
  53. package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
  54. package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
  55. package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
  56. package/uni-ui/lib/uni-row/uni-row.vue +1 -1
  57. package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
  58. package/uni-ui/lib/uni-section/uni-section.vue +109 -1
  59. package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
  60. package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
  61. package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
  62. package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
  63. package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
  64. package/uni-ui/lib/uni-table/uni-table.vue +297 -1
  65. package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
  66. package/uni-ui/lib/uni-td/uni-td.vue +78 -1
  67. package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
  68. package/uni-ui/lib/uni-th/uni-th.vue +224 -1
  69. package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
  70. package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
  71. package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10yun/cv-mobile-ui",
3
- "version": "0.5.20",
3
+ "version": "0.5.22",
4
4
  "description": "十云cvjs移动端ui,适用uniapp",
5
5
  "author": "10yun",
6
6
  "license": "Apache-2.0",
package/plugins/jumps.js CHANGED
@@ -36,9 +36,10 @@ class JumpsClass {
36
36
  this.page_my = options.page_my || '';
37
37
  this.page_home = options.page_home || '';
38
38
  this.page_login = options.page_login;
39
+ this.page_xieyi = options.page_xieyi;
39
40
  this.storeHandle = options.storeHandle;
40
41
  }
41
- jumpsPage(url, urlPm, time) {
42
+ jumpsPage = (url, urlPm, time) => {
42
43
  url = url || '';
43
44
  let jumpUrl = doJumpUrl(url);
44
45
  if (jumpUrl == '') {
@@ -64,8 +65,9 @@ class JumpsClass {
64
65
  }
65
66
  });
66
67
  }, time);
67
- }
68
- jumpsAuth(jumpUrl, urlPm, time) {
68
+ };
69
+
70
+ jumpsAuth = (jumpUrl, urlPm, time) => {
69
71
  jumpUrl = jumpUrl || '';
70
72
  if (jumpUrl == '') {
71
73
  uni.showToast({
@@ -82,8 +84,8 @@ class JumpsClass {
82
84
  this.jumpsPage(jumpUrl, urlPm, time);
83
85
  }
84
86
  }
85
- }
86
- jumpsLogin() {
87
+ };
88
+ jumpsLogin = () => {
87
89
  uni.showModal({
88
90
  content: '您还未登录,请前往登录',
89
91
  showCancel: false,
@@ -95,24 +97,67 @@ class JumpsClass {
95
97
  }
96
98
  }
97
99
  });
98
- }
100
+ };
99
101
  // 跳转到用户页
100
- jumpsMy(time) {
102
+ jumpsMy = (time) => {
101
103
  this.jumpsPage(this.page_my, time);
102
- }
104
+ };
103
105
  // 跳转到主页
104
- jumpsHome(time) {
106
+ jumpsHome = (time) => {
105
107
  this.jumpsPage(this.page_home, time);
106
- }
108
+ };
109
+ /**
110
+ * 跳转协议
111
+ * @param {*} name
112
+ */
113
+ jumpsXieyi = (name) => {
114
+ this.jumpsPage(this.page_xieyi, {
115
+ // 'no': 'XY003',
116
+ title: name
117
+ });
118
+ };
107
119
  // 上一个页面
108
- jumpsPre() {
120
+ jumpsPre = () => {
109
121
  let pages = getCurrentPages();
110
122
  let prePage = pages[pages.length - 2];
111
123
  // #ifdef H5
112
124
  return prePage;
113
125
  // #endif
114
126
  return prePage.$vm;
115
- }
127
+ };
128
+ /**
129
+ * 返回页面
130
+ * @param {*} name
131
+ */
132
+ jumpsBack = (jumpUrl, time) => {
133
+ time = time || 1000;
134
+ let pages = getCurrentPages(); //页面栈
135
+ let prePage = pages[pages.length - 2]; //上一页
136
+ prePage.$vm.reFresh = Math.random(); //触发上一页监听器
137
+ setTimeout(() => {
138
+ uni.navigateBack(); //返回上一页
139
+ }, time);
140
+ };
116
141
  }
142
+ export const useBindPlugin = (bindInstance, options) => {
143
+ const jumpsObj = new JumpsClass(options);
144
+
145
+ bindInstance.cv__jumpPage = jumpsObj.jumpsPage;
146
+ bindInstance.cv__jumpAuth = jumpsObj.jumpsAuth;
147
+ bindInstance.cv__jumpHome = jumpsObj.jumpsHome;
148
+ bindInstance.cv__jumpMy = jumpsObj.jumpsMy;
149
+ bindInstance.cv__jumpLogin = jumpsObj.jumpsLogin;
150
+ bindInstance.cv__jumpXieyi = jumpsObj.jumpsXieyi;
151
+ bindInstance.cv__jumpPre = jumpsObj.jumpsPre;
152
+ bindInstance.cv__jumpBack = jumpsObj.jumpsBack;
117
153
 
154
+ uni.cv__jumpPage = jumpsObj.jumpsPage;
155
+ uni.cv__jumpAuth = jumpsObj.jumpsAuth;
156
+ uni.cv__jumpHome = jumpsObj.jumpsHome;
157
+ uni.cv__jumpMy = jumpsObj.jumpsMy;
158
+ uni.cv__jumpLogin = jumpsObj.jumpsLogin;
159
+ uni.cv__jumpXieyi = jumpsObj.jumpsXieyi;
160
+ uni.cv__jumpPre = jumpsObj.jumpsPre;
161
+ uni.cv__jumpBack = jumpsObj.jumpsBack;
162
+ };
118
163
  export default JumpsClass;
package/plugins/lbs.js CHANGED
@@ -132,9 +132,10 @@ class LbsClass {
132
132
  *
133
133
  * @return {Object}
134
134
  */
135
- getLocation(ip = '') {
135
+ getLocation = (ip = '') => {
136
+ const _self = this;
136
137
  return new Promise((resolve, reject) => {
137
- if (!this._KEY_) {
138
+ if (!_self._KEY_) {
138
139
  reject('请先设置Key');
139
140
  console.error('请先设置Key');
140
141
  return false;
@@ -143,9 +144,9 @@ class LbsClass {
143
144
  if (ip) {
144
145
  formData.ip = ip;
145
146
  }
146
- formData.key = this._KEY_;
147
+ formData.key = _self._KEY_;
147
148
 
148
- if (this._TYPE_ == 'qq') {
149
+ if (_self._TYPE_ == 'qq') {
149
150
  formData.output = 'json';
150
151
  uni.request({
151
152
  url: '/tx_apis_map' + '/ws/location/v1/ip/',
@@ -173,7 +174,7 @@ class LbsClass {
173
174
  reject(error);
174
175
  }
175
176
  });
176
- } else if (this._TYPE_ == 'amap') {
177
+ } else if (_self._TYPE_ == 'amap') {
177
178
  formData.output = 'JSON';
178
179
  /* 高德地图 */
179
180
  uni.request({
@@ -222,13 +223,13 @@ class LbsClass {
222
223
  });
223
224
  }
224
225
  });
225
- }
226
+ };
226
227
  /**
227
228
  * 获取全部行政区划数据。该请求为GET请求。
228
229
  *
229
230
  * @return {Object}
230
231
  */
231
- getDistrict(keyword = '') {
232
+ getDistrict = (keyword = '') => {
232
233
  return new Promise((resolve, reject) => {
233
234
  if (!this._KEY_) {
234
235
  reject('请先设置Key');
@@ -286,6 +287,14 @@ class LbsClass {
286
287
  });
287
288
  }
288
289
  });
289
- }
290
+ };
291
+ }
292
+
293
+ export function useBindPlugin(bindInstance, options) {
294
+ const LbsObj = new LbsClass(options);
295
+
296
+ bindInstance.cv__lbsGetLocation = LbsObj.getLocation;
297
+
298
+ uni.cv__lbsGetLocation = LbsObj.getLocation;
290
299
  }
291
300
  export default LbsClass;
@@ -19,7 +19,7 @@ import mpMixin from '../../libs/mixin/mpMixin.js';
19
19
  import mixin from '../../libs/mixin/mixin.js';
20
20
  export default {
21
21
  mixins: [mpMixin, mixin],
22
- name: 'cvNavCol',
22
+ name: 'cvGridItem',
23
23
  emits: ['click'],
24
24
  inject: {
25
25
  cvGroupCol: {
@@ -1 +1,150 @@
1
- <template>
2
1
  <view class="uni-badge--x">
3
2
  <slot />
4
3
  <text v-if="text" :class="classNames" :style="[positionStyle, customStyle, dotStyle]" class="uni-badge" @click="onClick()">
5
4
  {{ displayValue }}
6
5
  </text>
7
6
  </view>
8
7
  * Badge 数字角标
9
8
  * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
10
9
  * @tutorial https://ext.dcloud.net.cn/plugin?id=21
11
10
  * @property {String} text 角标内容
12
11
  * @property {String} size = [normal|small] 角标内容
13
12
  * @property {String} type = [info|primary|success|warning|error] 颜色类型
14
13
  * @value info 灰色
15
14
  * @value primary 蓝色
16
15
  * @value success 绿色
17
16
  * @value warning 黄色
18
17
  * @value error 红色
19
18
  * @property {String} inverted = [true|false] 是否无需背景颜色
20
19
  * @property {Number} maxNum 展示封顶的数字值,超过 99 显示 99+
21
20
  * @property {String} absolute = [rightTop|rightBottom|leftBottom|leftTop] 开启绝对定位, 角标将定位到其包裹的标签的四角上
22
21
  * @value rightTop 右上
23
22
  * @value rightBottom 右下
24
23
  * @value leftTop 左上
25
24
  * @value leftBottom 左下
26
25
  * @property {Array[number]} offset 距定位角中心点的偏移量,只有存在 absolute 属性时有效,例如:[-10, -10] 表示向外偏移 10px,[10, 10] 表示向 absolute 指定的内偏移 10px
27
26
  * @property {String} isDot = [true|false] 是否显示为一个小点
28
27
  * @event {Function} click 点击 Badge 触发事件
29
28
  * @example <uni-badge text="1"></uni-badge>
30
29
  */
31
30
  name: 'UniBadge',
32
31
  emits: ['click'],
33
32
  props: {
34
33
  type: {
35
34
  type: String,
36
35
  default: 'error'
37
36
  },
38
37
  inverted: {
39
38
  type: Boolean,
40
39
  default: false
41
40
  },
42
41
  isDot: {
43
42
  type: Boolean,
44
43
  default: false
45
44
  },
46
45
  maxNum: {
47
46
  type: Number,
48
47
  default: 99
49
48
  },
50
49
  absolute: {
51
50
  type: String,
52
51
  default: ''
53
52
  },
54
53
  offset: {
55
54
  type: Array,
56
55
  default() {
57
56
  return [0, 0];
58
57
  }
59
58
  },
60
59
  text: {
61
60
  type: [String, Number],
62
61
  default: ''
63
62
  },
64
63
  size: {
65
64
  type: String,
66
65
  default: 'small'
67
66
  },
68
67
  customStyle: {
69
68
  type: Object,
70
69
  default() {
71
70
  return {};
72
71
  }
73
72
  }
74
73
  },
75
74
  data() {
76
75
  return {};
77
76
  },
78
77
  computed: {
79
78
  width() {
80
79
  return String(this.text).length * 8 + 12;
81
80
  },
82
81
  classNames() {
83
82
  const { inverted, type, size, absolute } = this;
84
83
  return [
85
84
  inverted ? 'uni-badge--' + type + '-inverted' : '',
86
85
  'uni-badge--' + type,
87
86
  'uni-badge--' + size,
88
87
  absolute ? 'uni-badge--absolute' : ''
89
88
  ].join(' ');
90
89
  },
91
90
  positionStyle() {
92
91
  if (!this.absolute) return {};
93
92
  let w = this.width / 2,
94
93
  h = 10;
95
94
  if (this.isDot) {
96
95
  w = 5;
97
96
  h = 5;
98
97
  }
99
98
  const x = `${-w + this.offset[0]}px`;
100
99
  const y = `${-h + this.offset[1]}px`;
101
100
  const whiteList = {
102
101
  rightTop: {
103
102
  right: x,
104
103
  top: y
105
104
  },
106
105
  rightBottom: {
107
106
  right: x,
108
107
  bottom: y
109
108
  },
110
109
  leftBottom: {
111
110
  left: x,
112
111
  bottom: y
113
112
  },
114
113
  leftTop: {
115
114
  left: x,
116
115
  top: y
117
116
  }
118
117
  };
119
118
  const match = whiteList[this.absolute];
120
119
  return match ? match : whiteList['rightTop'];
121
120
  },
122
121
  dotStyle() {
123
122
  if (!this.isDot) return {};
124
123
  return {
125
124
  width: '10px',
126
125
  minWidth: '0',
127
126
  height: '10px',
128
127
  padding: '0',
129
128
  borderRadius: '10px'
130
129
  };
131
130
  },
132
131
  displayValue() {
133
132
  const { isDot, text, maxNum } = this;
134
133
  return isDot ? '' : Number(text) > maxNum ? `${maxNum}+` : text;
135
134
  }
136
135
  },
137
136
  methods: {
138
137
  onClick() {
139
138
  this.$emit('click');
140
139
  }
141
140
  }
141
+ <template>
142
+ <view class="uni-badge--x">
143
+ <slot />
144
+ <text v-if="text" :class="classNames" :style="[positionStyle, customStyle, dotStyle]" class="uni-badge" @click="onClick()">
145
+ {{ displayValue }}
146
+ </text>
147
+ </view>
148
+ </template>
149
+ <script>
150
+ /**
151
+ * Badge 数字角标
152
+ * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
153
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=21
154
+ * @property {String} text 角标内容
155
+ * @property {String} size = [normal|small] 角标内容
156
+ * @property {String} type = [info|primary|success|warning|error] 颜色类型
157
+ * @value info 灰色
158
+ * @value primary 蓝色
159
+ * @value success 绿色
160
+ * @value warning 黄色
161
+ * @value error 红色
162
+ * @property {String} inverted = [true|false] 是否无需背景颜色
163
+ * @property {Number} maxNum 展示封顶的数字值,超过 99 显示 99+
164
+ * @property {String} absolute = [rightTop|rightBottom|leftBottom|leftTop] 开启绝对定位, 角标将定位到其包裹的标签的四角上
165
+ * @value rightTop 右上
166
+ * @value rightBottom 右下
167
+ * @value leftTop 左上
168
+ * @value leftBottom 左下
169
+ * @property {Array[number]} offset 距定位角中心点的偏移量,只有存在 absolute 属性时有效,例如:[-10, -10] 表示向外偏移 10px,[10, 10] 表示向 absolute 指定的内偏移 10px
170
+ * @property {String} isDot = [true|false] 是否显示为一个小点
171
+ * @event {Function} click 点击 Badge 触发事件
172
+ * @example <uni-badge text="1"></uni-badge>
173
+ */
174
+ export default {
175
+ name: 'UniBadge',
176
+ emits: ['click'],
177
+ props: {
178
+ type: {
179
+ type: String,
180
+ default: 'error'
181
+ },
182
+ inverted: {
183
+ type: Boolean,
184
+ default: false
185
+ },
186
+ isDot: {
187
+ type: Boolean,
188
+ default: false
189
+ },
190
+ maxNum: {
191
+ type: Number,
192
+ default: 99
193
+ },
194
+ absolute: {
195
+ type: String,
196
+ default: ''
197
+ },
198
+ offset: {
199
+ type: Array,
200
+ default() {
201
+ return [0, 0];
202
+ }
203
+ },
204
+ text: {
205
+ type: [String, Number],
206
+ default: ''
207
+ },
208
+ size: {
209
+ type: String,
210
+ default: 'small'
211
+ },
212
+ customStyle: {
213
+ type: Object,
214
+ default() {
215
+ return {};
216
+ }
217
+ }
218
+ },
219
+ data() {
220
+ return {};
221
+ },
222
+ computed: {
223
+ width() {
224
+ return String(this.text).length * 8 + 12;
225
+ },
226
+ classNames() {
227
+ const { inverted, type, size, absolute } = this;
228
+ return [
229
+ inverted ? 'uni-badge--' + type + '-inverted' : '',
230
+ 'uni-badge--' + type,
231
+ 'uni-badge--' + size,
232
+ absolute ? 'uni-badge--absolute' : ''
233
+ ].join(' ');
234
+ },
235
+ positionStyle() {
236
+ if (!this.absolute) return {};
237
+ let w = this.width / 2,
238
+ h = 10;
239
+ if (this.isDot) {
240
+ w = 5;
241
+ h = 5;
242
+ }
243
+ const x = `${-w + this.offset[0]}px`;
244
+ const y = `${-h + this.offset[1]}px`;
245
+ const whiteList = {
246
+ rightTop: {
247
+ right: x,
248
+ top: y
249
+ },
250
+ rightBottom: {
251
+ right: x,
252
+ bottom: y
253
+ },
254
+ leftBottom: {
255
+ left: x,
256
+ bottom: y
257
+ },
258
+ leftTop: {
259
+ left: x,
260
+ top: y
261
+ }
262
+ };
263
+ const match = whiteList[this.absolute];
264
+ return match ? match : whiteList['rightTop'];
265
+ },
266
+ dotStyle() {
267
+ if (!this.isDot) return {};
268
+ return {
269
+ width: '10px',
270
+ minWidth: '0',
271
+ height: '10px',
272
+ padding: '0',
273
+ borderRadius: '10px'
274
+ };
275
+ },
276
+ displayValue() {
277
+ const { isDot, text, maxNum } = this;
278
+ return isDot ? '' : Number(text) > maxNum ? `${maxNum}+` : text;
279
+ }
280
+ },
281
+ methods: {
282
+ onClick() {
283
+ this.$emit('click');
284
+ }
285
+ }
286
+ };
287
+ </script>
288
+ <style>
289
+ @import 'style.css';
290
+ </style>
@@ -1 +1,37 @@
1
- <template>
2
1
  <view class="uni-breadcrumb">
3
2
  <slot />
4
3
  </view>
5
4
  * Breadcrumb 面包屑导航父组件
6
5
  * @description 显示当前页面的路径,快速返回之前的任意页面
7
6
  * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
8
7
  * @property {String} separator 分隔符,默认为斜杠'/'
9
8
  * @property {String} separatorClass 图标分隔符 class
10
9
  */
11
10
  options: {
12
11
  virtualHost: true
13
12
  },
14
13
  props: {
15
14
  separator: {
16
15
  type: String,
17
16
  default: '/'
18
17
  },
19
18
  separatorClass: {
20
19
  type: String,
21
20
  default: ''
22
21
  }
23
22
  },
24
23
  provide() {
25
24
  return {
26
25
  uniBreadcrumb: this
27
26
  };
28
27
  }
28
+ <template>
29
+ <view class="uni-breadcrumb">
30
+ <slot />
31
+ </view>
32
+ </template>
33
+ <script>
34
+ /**
35
+ * Breadcrumb 面包屑导航父组件
36
+ * @description 显示当前页面的路径,快速返回之前的任意页面
37
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
38
+ * @property {String} separator 分隔符,默认为斜杠'/'
39
+ * @property {String} separatorClass 图标分隔符 class
40
+ */
41
+ export default {
42
+ options: {
43
+ virtualHost: true
44
+ },
45
+ props: {
46
+ separator: {
47
+ type: String,
48
+ default: '/'
49
+ },
50
+ separatorClass: {
51
+ type: String,
52
+ default: ''
53
+ }
54
+ },
55
+ provide() {
56
+ return {
57
+ uniBreadcrumb: this
58
+ };
59
+ }
60
+ };
61
+ </script>
62
+ <style>
63
+ @import 'style.css';
64
+ </style>
@@ -1 +1,83 @@
1
- <template>
2
1
  <view class="uni-breadcrumb-item">
3
2
  <view
4
3
  :class="{
5
4
  'uni-breadcrumb-item--slot': true,
6
5
  'uni-breadcrumb-item--slot-link': to && currentPage !== to
7
6
  }"
8
7
  @click="navTo"
9
8
  >
10
9
  <slot />
11
10
  </view>
12
11
  <i v-if="separatorClass" class="uni-breadcrumb-item--separator" :class="separatorClass" />
13
12
  <text v-else class="uni-breadcrumb-item--separator">{{ separator }}</text>
14
13
  </view>
15
14
  * BreadcrumbItem 面包屑导航子组件
16
15
  * @property {String/Object} to 路由跳转页面路径/对象
17
16
  * @property {Boolean} replace 在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持)
18
17
  */
19
18
  data() {
20
19
  return {
21
20
  currentPage: ''
22
21
  };
23
22
  },
24
23
  options: {
25
24
  virtualHost: true
26
25
  },
27
26
  props: {
28
27
  to: {
29
28
  type: String,
30
29
  default: ''
31
30
  },
32
31
  replace: {
33
32
  type: Boolean,
34
33
  default: false
35
34
  }
36
35
  },
37
36
  inject: {
38
37
  uniBreadcrumb: {
39
38
  from: 'uniBreadcrumb',
40
39
  default: null
41
40
  }
42
41
  },
43
42
  created() {
44
43
  const pages = getCurrentPages();
45
44
  const page = pages[pages.length - 1];
46
45
  if (page) {
47
46
  this.currentPage = `/${page.route}`;
48
47
  }
49
48
  },
50
49
  computed: {
51
50
  separator() {
52
51
  return this.uniBreadcrumb.separator;
53
52
  },
54
53
  separatorClass() {
55
54
  return this.uniBreadcrumb.separatorClass;
56
55
  }
57
56
  },
58
57
  methods: {
59
58
  navTo() {
60
59
  const { to } = this;
61
60
  if (!to || this.currentPage === to) {
62
61
  return;
63
62
  }
64
63
  if (this.replace) {
65
64
  uni.redirectTo({
66
65
  url: to
67
66
  });
68
67
  } else {
69
68
  uni.navigateTo({
70
69
  url: to
71
70
  });
72
71
  }
73
72
  }
74
73
  }
74
+ <template>
75
+ <view class="uni-breadcrumb-item">
76
+ <view
77
+ :class="{
78
+ 'uni-breadcrumb-item--slot': true,
79
+ 'uni-breadcrumb-item--slot-link': to && currentPage !== to
80
+ }"
81
+ @click="navTo"
82
+ >
83
+ <slot />
84
+ </view>
85
+ <i v-if="separatorClass" class="uni-breadcrumb-item--separator" :class="separatorClass" />
86
+ <text v-else class="uni-breadcrumb-item--separator">{{ separator }}</text>
87
+ </view>
88
+ </template>
89
+ <script>
90
+ /**
91
+ * BreadcrumbItem 面包屑导航子组件
92
+ * @property {String/Object} to 路由跳转页面路径/对象
93
+ * @property {Boolean} replace 在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持)
94
+ */
95
+ export default {
96
+ data() {
97
+ return {
98
+ currentPage: ''
99
+ };
100
+ },
101
+ options: {
102
+ virtualHost: true
103
+ },
104
+ props: {
105
+ to: {
106
+ type: String,
107
+ default: ''
108
+ },
109
+ replace: {
110
+ type: Boolean,
111
+ default: false
112
+ }
113
+ },
114
+ inject: {
115
+ uniBreadcrumb: {
116
+ from: 'uniBreadcrumb',
117
+ default: null
118
+ }
119
+ },
120
+ created() {
121
+ const pages = getCurrentPages();
122
+ const page = pages[pages.length - 1];
123
+ if (page) {
124
+ this.currentPage = `/${page.route}`;
125
+ }
126
+ },
127
+ computed: {
128
+ separator() {
129
+ return this.uniBreadcrumb.separator;
130
+ },
131
+ separatorClass() {
132
+ return this.uniBreadcrumb.separatorClass;
133
+ }
134
+ },
135
+ methods: {
136
+ navTo() {
137
+ const { to } = this;
138
+ if (!to || this.currentPage === to) {
139
+ return;
140
+ }
141
+ if (this.replace) {
142
+ uni.redirectTo({
143
+ url: to
144
+ });
145
+ } else {
146
+ uni.navigateTo({
147
+ url: to
148
+ });
149
+ }
150
+ }
151
+ }
152
+ };
153
+ </script>
154
+ <style>
155
+ @import 'style.css';
156
+ </style>