btxui 1.0.1

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 (190) hide show
  1. package/README.md +42 -0
  2. package/app.vue +162 -0
  3. package/assets/css/_main.js +73 -0
  4. package/assets/css/btx.min.css +1 -0
  5. package/assets/css/btx.mob.min.css +1 -0
  6. package/assets/css/btx.pad.min.css +1 -0
  7. package/assets/css/btx.webapp.min.css +1 -0
  8. package/assets/css/custom_fonts/iconfont.css +37 -0
  9. package/assets/css/custom_fonts/iconfont.eot +0 -0
  10. package/assets/css/custom_fonts/iconfont.svg +47 -0
  11. package/assets/css/custom_fonts/iconfont.ttf +0 -0
  12. package/assets/css/custom_fonts/iconfont.woff +0 -0
  13. package/assets/css/custom_fonts/iconfont.woff2 +0 -0
  14. package/assets/css/res-l.css +47 -0
  15. package/assets/css/res-m.css +47 -0
  16. package/assets/css/res-s.css +61 -0
  17. package/assets/custom_fonts/iconfont.css +37 -0
  18. package/assets/custom_fonts/iconfont.eot +0 -0
  19. package/assets/custom_fonts/iconfont.svg +47 -0
  20. package/assets/custom_fonts/iconfont.ttf +0 -0
  21. package/assets/custom_fonts/iconfont.woff +0 -0
  22. package/assets/custom_fonts/iconfont.woff2 +0 -0
  23. package/assets/js/Btx.js +196 -0
  24. package/assets/js/Utils.js +421 -0
  25. package/assets/js/fastclick.js +802 -0
  26. package/assets/js/lazy.min.js +2 -0
  27. package/assets/js/touchwipe.js +111 -0
  28. package/assets/server.js +8 -0
  29. package/assets/start_site_code_str.js +119 -0
  30. package/cdn/css/btx.min.css +1 -0
  31. package/cdn/css/btx.min.css.map +1 -0
  32. package/cdn/fonts/iconfont.ttf +0 -0
  33. package/cdn/fonts/iconfont.woff +0 -0
  34. package/cdn/fonts/iconfont.woff2 +0 -0
  35. package/components/BTXUI/app/app-wid.vue +182 -0
  36. package/components/BTXUI/btn/btn-wid.vue +128 -0
  37. package/components/BTXUI/carousel/carousel-wid.vue +138 -0
  38. package/components/BTXUI/checkbox/checkbox-wid.vue +72 -0
  39. package/components/BTXUI/confirm/confirm-wid.vue +279 -0
  40. package/components/BTXUI/content/content-checkbox-wid.vue +44 -0
  41. package/components/BTXUI/content/content-node-wid.vue +114 -0
  42. package/components/BTXUI/content/content-tag-wid.vue +25 -0
  43. package/components/BTXUI/content/content-wid.vue +254 -0
  44. package/components/BTXUI/core/anis/ani-fail.vue +46 -0
  45. package/components/BTXUI/core/anis/ani-loading.vue +32 -0
  46. package/components/BTXUI/core/anis/ani-notic.vue +47 -0
  47. package/components/BTXUI/core/anis/ani-success.vue +48 -0
  48. package/components/BTXUI/core/b-drag.vue +258 -0
  49. package/components/BTXUI/core/b-grid.vue +84 -0
  50. package/components/BTXUI/core/b-hot.vue +171 -0
  51. package/components/BTXUI/core/b-icon.vue +76 -0
  52. package/components/BTXUI/core/b-img.vue +84 -0
  53. package/components/BTXUI/core/b-input.vue +198 -0
  54. package/components/BTXUI/core/b-list.vue +276 -0
  55. package/components/BTXUI/core/b-text/doc.ts +9 -0
  56. package/components/BTXUI/core/b-text/index.vue +16 -0
  57. package/components/BTXUI/core/b-textarea.vue +58 -0
  58. package/components/BTXUI/core/b-video.vue +35 -0
  59. package/components/BTXUI/core/b-view/doc.ts +10 -0
  60. package/components/BTXUI/core/b-view/index.vue +20 -0
  61. package/components/BTXUI/core/b-webview.vue +20 -0
  62. package/components/BTXUI/core/lib/ChapterLink.js +49 -0
  63. package/components/BTXUI/core/lib/Search.vue +60 -0
  64. package/components/BTXUI/core/styles/doc.ts +55 -0
  65. package/components/BTXUI/core/styles/index.vue +98 -0
  66. package/components/BTXUI/core/styles/prestyles.ts +471 -0
  67. package/components/BTXUI/core/styles/theme.ts +29 -0
  68. package/components/BTXUI/drawer/drawer-wid.vue +165 -0
  69. package/components/BTXUI/drawer/title-tag-wid.vue +114 -0
  70. package/components/BTXUI/form/form-select-wid.vue +57 -0
  71. package/components/BTXUI/form/form-wid.vue +324 -0
  72. package/components/BTXUI/formPannel/form-pannel-wid.vue +133 -0
  73. package/components/BTXUI/imgsUpload/imgs-upload-wid.vue +149 -0
  74. package/components/BTXUI/index.js +83 -0
  75. package/components/BTXUI/pageFlip/page-flip-wid.vue +206 -0
  76. package/components/BTXUI/pannel/pannel-wid.vue +167 -0
  77. package/components/BTXUI/range/range-wid.vue +134 -0
  78. package/components/BTXUI/search/search-wid.vue +80 -0
  79. package/components/BTXUI/select/select-wid.vue +186 -0
  80. package/components/BTXUI/slider/slider-wid.vue +444 -0
  81. package/components/BTXUI/tab/tab-wid.vue +109 -0
  82. package/components/BTXUI/table/table-wid.vue +324 -0
  83. package/components/BTXUI/tag/tag-wid.vue +183 -0
  84. package/components/BTXUI/tags/tags-wid.vue +121 -0
  85. package/components/BTXUI/tooltip/tooltip-wid.vue +146 -0
  86. package/components/BTXUI/upload/upload-wid.vue +215 -0
  87. package/components/BTXUI/waterfall/waterfall-wid.vue +166 -0
  88. package/components/header-info.vue +167 -0
  89. package/composables/@types.ts +4 -0
  90. package/composables/api.ts +18 -0
  91. package/env.d.ts +5 -0
  92. package/main.js +6 -0
  93. package/nuxt.config.ts +51 -0
  94. package/package.json +23 -0
  95. package/pages/article.vue +16 -0
  96. package/pages/download.vue +50 -0
  97. package/pages/example/app_wid/app/data_demo.vue +9 -0
  98. package/pages/example/app_wid/app/download_demo.vue +9 -0
  99. package/pages/example/app_wid/app/list_demo.vue +11 -0
  100. package/pages/example/app_wid/app/system_demo.vue +9 -0
  101. package/pages/example/app_wid/app_wid_demo.vue +198 -0
  102. package/pages/example/app_wid/btn_wid_demo.vue +179 -0
  103. package/pages/example/app_wid/carousel_wid_demo.vue +152 -0
  104. package/pages/example/app_wid/checkbox_wid_demo.vue +65 -0
  105. package/pages/example/app_wid/confirm_wid_demo.vue +197 -0
  106. package/pages/example/app_wid/content_wid_demo.vue +369 -0
  107. package/pages/example/app_wid/drawer_wid_demo.vue +155 -0
  108. package/pages/example/app_wid/form_pannel_wid_demo.vue +338 -0
  109. package/pages/example/app_wid/form_wid_demo.vue +550 -0
  110. package/pages/example/app_wid/imgs_upload_wid_demo.vue +159 -0
  111. package/pages/example/app_wid/index.js +158 -0
  112. package/pages/example/app_wid/page_flip_wid_demo.vue +99 -0
  113. package/pages/example/app_wid/pannel_wid_demo.vue +177 -0
  114. package/pages/example/app_wid/range_wid_demo.vue +101 -0
  115. package/pages/example/app_wid/search_wid_demo.vue +75 -0
  116. package/pages/example/app_wid/select_wid_demo.vue +217 -0
  117. package/pages/example/app_wid/slider_wid_demo.vue +143 -0
  118. package/pages/example/app_wid/tab_wid_demo.vue +170 -0
  119. package/pages/example/app_wid/table_wid_demo.vue +377 -0
  120. package/pages/example/app_wid/tag_wid_demo.vue +133 -0
  121. package/pages/example/app_wid/tags_wid_demo.vue +143 -0
  122. package/pages/example/app_wid/tooltip_wid_demo.vue +117 -0
  123. package/pages/example/app_wid/upload_wid_demo.vue +123 -0
  124. package/pages/example/base_wid/b_drag_demo.vue +159 -0
  125. package/pages/example/base_wid/b_grid_demo.vue +225 -0
  126. package/pages/example/base_wid/b_hot_demo.vue +135 -0
  127. package/pages/example/base_wid/b_icon_demo.vue +80 -0
  128. package/pages/example/base_wid/b_img_demo.vue +95 -0
  129. package/pages/example/base_wid/b_input_demo.vue +171 -0
  130. package/pages/example/base_wid/b_list_demo.vue +241 -0
  131. package/pages/example/base_wid/b_style_demo.vue +928 -0
  132. package/pages/example/base_wid/b_text_demo.vue +36 -0
  133. package/pages/example/base_wid/b_textarea_demo.vue +64 -0
  134. package/pages/example/base_wid/b_video_demo.vue +42 -0
  135. package/pages/example/base_wid/b_view_demo.vue +36 -0
  136. package/pages/example/base_wid/index.js +76 -0
  137. package/pages/example/content.js +49 -0
  138. package/pages/example/global_style/animation.vue +197 -0
  139. package/pages/example/global_style/color.vue +134 -0
  140. package/pages/example/global_style/decoration.vue +546 -0
  141. package/pages/example/global_style/icon.vue +345 -0
  142. package/pages/example/global_style/index.js +52 -0
  143. package/pages/example/global_style/layout.vue +846 -0
  144. package/pages/example/global_style/special.vue +37 -0
  145. package/pages/example/global_style/table.vue +298 -0
  146. package/pages/example/global_style/text.vue +159 -0
  147. package/pages/index.vue +29 -0
  148. package/pages/level_widget.vue +11 -0
  149. package/pages/start.vue +200 -0
  150. package/plugins/index.ts +2 -0
  151. package/public/favicon.gif +0 -0
  152. package/public/fonts/iconfont.ttf +0 -0
  153. package/public/fonts/iconfont.woff +0 -0
  154. package/public/fonts/iconfont.woff2 +0 -0
  155. package/public/img/banner.jpg +0 -0
  156. package/public/img/banner2.jpg +0 -0
  157. package/public/img/bg_pattern.png +0 -0
  158. package/public/img/btx.jpg +0 -0
  159. package/public/img/btx_ui.jpg +0 -0
  160. package/public/img/dir.png +0 -0
  161. package/public/img/f.png +0 -0
  162. package/public/img/head.jpg +0 -0
  163. package/public/img/head2.jpg +0 -0
  164. package/public/img/home_ico.png +0 -0
  165. package/public/img/icons.svg +164 -0
  166. package/public/img/mechanism/b-style.png +0 -0
  167. package/public/img/mechanism/slider-wid.png +0 -0
  168. package/public/img/mechanism/upload-wid.png +0 -0
  169. package/public/img/transform_origin.png +0 -0
  170. package/sass/animation.scss +400 -0
  171. package/sass/btx.mob.scss +10 -0
  172. package/sass/btx.pad.scss +3 -0
  173. package/sass/btx.scss +22 -0
  174. package/sass/btx.webapp.scss +22 -0
  175. package/sass/colors.scss +65 -0
  176. package/sass/decoration.scss +220 -0
  177. package/sass/flex.scss +29 -0
  178. package/sass/icons.scss +100 -0
  179. package/sass/layout.scss +88 -0
  180. package/sass/reset.scss +111 -0
  181. package/sass/response/flex_mixin.scss +91 -0
  182. package/sass/response/layout_mixin.scss +227 -0
  183. package/sass/response/main.scss +59 -0
  184. package/sass/response/text_mixin.scss +65 -0
  185. package/sass/scroll.scss +100 -0
  186. package/sass/special.scss +13 -0
  187. package/sass/table.scss +103 -0
  188. package/sass/text.scss +86 -0
  189. package/sass/webpack.config.js +31 -0
  190. package/tsconfig.json +4 -0
@@ -0,0 +1,444 @@
1
+ <template>
2
+ <b-view :styles="`rel h-${view.height} bg-color-${view.bg_color}`"
3
+ @on_enter="stop_auto_play"
4
+ @on_leave="auto_play_data.enable && auto_play()">
5
+
6
+ <!--轮播内容-->
7
+ <b-view :styles="`rel no-scroll h-${view.height}`">
8
+ <b-view ref="sliderBar"
9
+ :styles="`flex touch-none h-${view.height}`"
10
+ :dynamic="`w-${slider_bar_width}px translateX-${this.touch_point.x.toString().replace('-', 'f')}px ${this.flip_ani? 'trans-fast': 'trans-no'}`"
11
+ @on_touchstart="$_touch_start"
12
+ @on_touchmove="$_touch_move"
13
+ @on_touchend="$_touch_end"
14
+ @on_transitionend="$_flip_over">
15
+ <b-list v-for="page of slider_pages" :key="page.id"
16
+ styles="grow-1"
17
+ :go-top-btn="goTopBtn"
18
+ :state="page.state">
19
+ <slot :name="page.id"></slot>
20
+ </b-list>
21
+ </b-view>
22
+ </b-view>
23
+
24
+ <!--计数点-->
25
+ <b-view :styles="`flex-5 abs z1 max-w h-0 b-${showDot.bottom}`" v-if="showDot">
26
+ <b-hot v-for="(page,index) of slider_pages" :key="index"
27
+ :styles="`round mrg-h-.5 w-.5 h-.5 bg-color-${showDot.color}`"
28
+ :states="{
29
+ act: {
30
+ style: `bg-color-${showDot.act_color}`,
31
+ state: page.state === 'act'
32
+ }
33
+ }"
34
+ @on_click="$_dot_click(index + 1)"
35
+ :data-s="page.state"
36
+ :data-page="index + 1">
37
+ </b-hot>
38
+ </b-view>
39
+
40
+ <!--切换按钮-->
41
+ <template v-if="show_flip_btn" >
42
+ <b-hot styles="round bg-color-neutral translateY-f50 flex-5 abs t-50% l-1 w-4 h-4 fsize-2"
43
+ hover="bg-color-rgba(255,255,255,.4)"
44
+ @on_click="prev">
45
+ <b-icon icon="arrow-left" />
46
+ </b-hot>
47
+ <b-hot styles="round bg-color-neutral translateY-f50 flex-5 abs t-50% r-1 w-4 h-4 fsize-2"
48
+ hover="bg-color-rgba(255,255,255,.4)"
49
+ @on_click="next">
50
+ <b-icon icon="arrow-right" />
51
+ </b-hot>
52
+ </template>
53
+
54
+ </b-view>
55
+ </template>
56
+
57
+ <script>
58
+ import BView from "@/components/BTXUI/core/b-view"
59
+ import BHot from "@/components/BTXUI/core/b-hot"
60
+ import BIcon from "@/components/BTXUI/core/b-icon"
61
+ import BList from "@/components/BTXUI/core/b-list"
62
+
63
+ const desc = ["该组件用于设置内容轮播,支持页面 resize 时自动校正尺寸。",{
64
+ cover: "slider-wid.png",
65
+ title: "轮播执行机制原理"
66
+ }],
67
+ extend = [],
68
+ dependent = ["b-list", "b-hot", "b-icon", "b-view"],
69
+ api = {
70
+ event: [
71
+ {
72
+ name: "on_flip",
73
+ ef: "分页完成",
74
+ params: "cur_page"
75
+ },
76
+ {
77
+ name: "on_load",
78
+ ef: "分页结构生成",
79
+ params: "-"
80
+ }
81
+ ],
82
+ methods: [
83
+ {
84
+ name: "prev",
85
+ ef: "向前翻页",
86
+ params: "flip_ani",
87
+ return: "-"
88
+ },
89
+ {
90
+ name: "next",
91
+ ef: "向后翻页",
92
+ params: "flip_ani",
93
+ return: "-"
94
+ },
95
+ {
96
+ name: "flip",
97
+ ef: "翻页",
98
+ params: "page, flip_ani",
99
+ return: "-"
100
+ },
101
+ {
102
+ name: "auto_play",
103
+ ef: "自动播放",
104
+ params: "restart",
105
+ return: "-"
106
+ },
107
+ {
108
+ name: "stop_auto_play",
109
+ ef: "停止自动播放",
110
+ params: "-",
111
+ return: "-"
112
+ },
113
+ {
114
+ name: "forbid_touch",
115
+ ef: "禁止触控滑动",
116
+ params: "if_forbid",
117
+ return: "-"
118
+ }
119
+ ]
120
+ },
121
+ init_data = `{
122
+ pages: [
123
+ {
124
+ id: "内容标识"
125
+ },...
126
+ ],
127
+ /* view: {
128
+ height: "轮播器高度(默认为 auto,由内容撑起)",
129
+ bg_color: "轮播器背景色(默认为透明)"
130
+ } */,
131
+ /* showDot: {
132
+ bottom: "底边位移",
133
+ color: "点颜色",
134
+ act_color: "点激活颜色"
135
+ } */,
136
+ /* showFlipBtn: "显示切换按钮" */,
137
+ /* autoPlayDuration: "自动播放时间间隔(毫秒)" */,
138
+ /* loop: "是否循环播放" */,
139
+ /* keyboardFlip: "是否启用键盘切换" */,
140
+ /* goTopBtn: "(参照:b-list 组件 goTopBtn 入参)" */
141
+ }`;
142
+
143
+ export default {
144
+ name: "slider-wid",
145
+ introduce: { desc, extend, dependent, api, init_data },
146
+ components: {
147
+ BHot,
148
+ BIcon,
149
+ BView,
150
+ BList
151
+ },
152
+ props: {
153
+ pages: {
154
+ type: Array,
155
+ required: true
156
+ },
157
+ view: {
158
+ type: Object,
159
+ required: false,
160
+ default: ()=>{
161
+ return {
162
+ height: "auto",
163
+ bg_color: "none"
164
+ }
165
+ }
166
+ },
167
+ showDot: {
168
+ type: Object,
169
+ required: false
170
+ },
171
+ showFlipBtn: {
172
+ type: Boolean,
173
+ required: false
174
+ },
175
+ autoPlayDuration: {
176
+ type: Number,
177
+ required: false
178
+ },
179
+ loop: {
180
+ type: Boolean,
181
+ required: false
182
+ },
183
+ keyboardFlip: {
184
+ type: Boolean,
185
+ required: false
186
+ },
187
+ goTopBtn: {
188
+ type: Object,
189
+ required: false
190
+ }
191
+ },
192
+ data(){
193
+ return {
194
+
195
+ //数据分页
196
+ slider_pages: [],
197
+
198
+ //滑动条宽度
199
+ slider_bar_width: 0,
200
+
201
+ //索引指针
202
+ point: {
203
+ prev: 0,
204
+ cur: 0,
205
+ },
206
+
207
+ //是否自动播放
208
+ auto_play_data: {
209
+ enable: false,
210
+ interval: 0
211
+ },
212
+
213
+ //触控点
214
+ touch_point: {
215
+ start: 0,
216
+ left: 0,
217
+ x: 0,
218
+ threshold: 2,
219
+ offset: 0,
220
+ direction: {
221
+ enable: true,
222
+ offset: false,
223
+ dir: null
224
+ }
225
+ },
226
+
227
+ //翻页缓动
228
+ flip_ani: true,
229
+
230
+ //滑动启用状态
231
+ touch_move_enable: true,
232
+
233
+ //是否显示翻页按钮
234
+ show_flip_btn: false
235
+
236
+ }
237
+ },
238
+ computed: {
239
+
240
+ //轮播容器
241
+ slider_bar(){
242
+ return this.$refs.sliderBar;
243
+ }
244
+
245
+ },
246
+ methods: {
247
+
248
+ //向前翻页
249
+ prev(flip_ani){
250
+ this.flip(this.point.cur, flip_ani);
251
+ },
252
+
253
+ //向后翻页
254
+ next(flip_ani){
255
+ this.flip(this.point.cur + 2, flip_ani);
256
+ },
257
+
258
+ //翻页
259
+ flip(page, flip_ani=true){
260
+ let page_len = this.slider_pages.length;
261
+
262
+ //设置播放模式(point:索引,page:页码)
263
+ if(this.loop){//循环
264
+ if(page < 1){
265
+ this.point.cur = page_len - 1;
266
+ }else if(page > page_len){
267
+ this.point.cur = 0;
268
+ }else{
269
+ this.point.cur = page - 1;
270
+ }
271
+ }else{//定向
272
+ this.point.cur = Math.min(page_len - 1, Math.max(0, page - 1));
273
+ }
274
+ this.touch_point.x = this.touch_point.left = -this.point.cur * this.$el.clientWidth; //位移
275
+
276
+ //设置分页激活状态
277
+ if(this.point.prev !== this.point.cur){
278
+ let cur_page_data = this.slider_pages[this.point.cur];
279
+ this.slider_pages[this.point.prev].state = "";
280
+ cur_page_data.state = "act";
281
+ this.point.prev = this.point.cur;
282
+ }
283
+
284
+ //设置分页缓动
285
+ !flip_ani && this.$emit("on_flip", this.point.cur + 1);
286
+ this.flip_ani = flip_ani;
287
+ },
288
+
289
+ //自动播放
290
+ auto_play(restart){
291
+ this.auto_play_data.interval = setInterval(()=>{
292
+ restart? this.flip(1): this.next(true);
293
+ }, this.auto_play_data.duration)
294
+ },
295
+
296
+ //停止自动播放
297
+ stop_auto_play(){
298
+ clearInterval(this.auto_play_data.interval);
299
+ },
300
+
301
+ //禁止触控滑动
302
+ forbid_touch(if_forbid){
303
+ this.touch_move_enable = if_forbid === true? false: true;
304
+ },
305
+
306
+ //初始化组件数据
307
+ $_init_data(){
308
+ this.point = {
309
+ prev: 0,
310
+ cur: 0
311
+ };
312
+ this.show_flip_btn = this.showFlipBtn;
313
+ this.slider_pages = this.pages.map((data, i) => {
314
+ return {
315
+ id: data.id,
316
+ state: i==0?"act":""
317
+ };
318
+ })
319
+ this.$_set_slider_bar_width();
320
+ this.$_init_auto_play();
321
+ if(this.keyboardFlip) this.$_bind_keyboard_flip_event();
322
+
323
+ //分页结构生成
324
+ this.$nextTick(()=>{
325
+ this.$emit("on_load");
326
+ })
327
+
328
+ },
329
+
330
+ //初始化自动播放
331
+ $_init_auto_play(){
332
+ let duration = this.autoPlayDuration;
333
+ if(duration){
334
+ this.auto_play_data = {
335
+ enable: true,
336
+ duration: duration,
337
+ interval: null,
338
+ };
339
+ this.auto_play();
340
+ }
341
+ },
342
+
343
+ //触控开始手势
344
+ $_touch_start(e){
345
+ this.touch_point.start = e.touches[0].pageX;
346
+ this.touch_point.direction.enable = true;
347
+ this.flip_ani = false;
348
+ this.stop_auto_play();
349
+ },
350
+
351
+ //触控结束手势
352
+ $_touch_end(){
353
+ this.$_flip_as_threshold();
354
+ this.auto_play_data.enable && this.auto_play()
355
+ },
356
+
357
+ //触控滑动手势
358
+ $_touch_move(e){
359
+ if(this.touch_move_enable){
360
+ let touch = e.touches[0],
361
+ touch_point = this.touch_point,
362
+ offset;
363
+ this.$_flip_direction(touch, touch_point);
364
+ if(touch_point.direction.dir === "horizontal"){
365
+ touch_point.offset = offset = touch.pageX - touch_point.start;
366
+ e.cancelable && e.preventDefault();
367
+ touch_point.x = touch_point.left + offset;
368
+ }
369
+ }
370
+ },
371
+
372
+ //触控分页阈值处理
373
+ $_flip_as_threshold(){
374
+ let touch_point = this.touch_point;
375
+ if(touch_point.offset !== 0){ //无位移,不执行
376
+ let flip = Math.abs(touch_point.x / this.$el.clientWidth),
377
+ flip_dir = touch_point.x < touch_point.left? "left": "right",
378
+ page = this.point.cur + 1,
379
+ overflow_x = flip.toString().split(".")[1][0];
380
+ if(flip_dir === "right" && overflow_x < 10 - touch_point.threshold){//向右滑动:上一页
381
+ page--;
382
+ }else if(flip_dir === "left" && overflow_x >= touch_point.threshold){//向左滑动:下一页
383
+ page++;
384
+ }
385
+ this.flip(page, true);
386
+ touch_point.offset = 0;
387
+ }
388
+ },
389
+
390
+ //滑动结束
391
+ $_flip_over(){
392
+ this.$emit("on_flip", this.point.cur + 1);
393
+ },
394
+
395
+ //滑动方向判断
396
+ $_flip_direction(touch, touch_point){
397
+ let direction = touch_point.direction;
398
+ if(direction.enable){
399
+ if(direction.offset){ //方向判断
400
+ let offset_x = Math.abs(touch.pageX - direction.x),
401
+ offset_y = Math.abs(touch.pageY - direction.y);
402
+ direction.dir = offset_x >= offset_y? "horizontal": "vertical";
403
+ direction.offset = direction.enable = false;
404
+ }else{ //定位起始坐标
405
+ direction.x = touch.pageX;
406
+ direction.y = touch.pageY;
407
+ direction.offset = true;
408
+ }
409
+ }
410
+ },
411
+
412
+ //计数点点击
413
+ $_dot_click(page){
414
+ this.flip(page, true);
415
+ },
416
+
417
+ //绑定键盘翻页事件
418
+ $_bind_keyboard_flip_event(){
419
+ window.addEventListener("keyup", (e) => {
420
+ if(e.key === "ArrowLeft") this.prev(".54s");
421
+ if(e.key === "ArrowRight") this.next(".54s");
422
+ });
423
+ },
424
+
425
+ //设置 slider_bar 宽度
426
+ $_set_slider_bar_width(){
427
+ this.slider_bar_width = this.slider_pages.length * this.$el.clientWidth;
428
+ }
429
+
430
+ },
431
+ watch: {
432
+ pages(){
433
+ this.$_init_data();
434
+ }
435
+ },
436
+ mounted(){
437
+ this.$_init_data();
438
+ window.addEventListener("resize", this.$_set_slider_bar_width)
439
+ },
440
+ destroyed(){
441
+ window.removeEventListener("resize", this.$_set_slider_bar_width);
442
+ }
443
+ }
444
+ </script>
@@ -0,0 +1,109 @@
1
+ <template>
2
+ <b-view>
3
+ <b-view styles="rel t-2px">
4
+ <tags-wid v-bind="tags_data" v-model="cur_tab"/>
5
+ </b-view>
6
+ <b-view styles="rel">
7
+ <slider-wid :pages="tags_data.tagList" ref="slider"
8
+ @on_flip="$_page_flip"
9
+ @on_load="$_init_page">
10
+ <slot v-for="page of tags_data.tagList"
11
+ :slot="page.id"
12
+ :name="page.id" />
13
+ </slider-wid>
14
+ </b-view>
15
+ </b-view>
16
+ </template>
17
+
18
+ <script>
19
+ import BView from "@/components/BTXUI/core/b-view"
20
+ import BText from "@/components/BTXUI/core/b-text"
21
+ import TagsWid from "@/components/BTXUI/tags/tags-wid"
22
+ import SliderWid from "@/components/BTXUI/slider/slider-wid"
23
+
24
+ let desc = ["该组件用于进行标签切换交互操作。"],
25
+ extend = [],
26
+ dependent = ["slider-wid", "tags-wid", "b-text", "b-view"],
27
+ api = null,
28
+ init_data = `{
29
+ curTab: "(v-model)当前 tag id",
30
+ tagsData: "(参照:tags-wid 组件入参,不含 mode 项)",
31
+ /* smooth: "平滑切换,默认 false" */,
32
+ }`;
33
+
34
+ export default {
35
+ name: "tab-wid",
36
+ introduce: { desc, extend, dependent, api, init_data },
37
+ components: {
38
+ BView,
39
+ BText,
40
+ TagsWid,
41
+ SliderWid
42
+ },
43
+ model:{
44
+ prop: "curTab",
45
+ event: "on_select"
46
+ },
47
+ props: {
48
+ curTab: {
49
+ type: String,
50
+ required: true
51
+ },
52
+ tagsData: {
53
+ type: Object,
54
+ required: true
55
+ },
56
+ smooth: {
57
+ type: Boolean,
58
+ required: false,
59
+ default: false
60
+ }
61
+ },
62
+ data(){
63
+ return {
64
+
65
+ //当前所选标签
66
+ cur_tab: [this.curTab],
67
+
68
+ //tags_data
69
+ tags_data: { ...this.tagsData, mode: "radio" }
70
+
71
+ }
72
+ },
73
+ computed: {
74
+
75
+ //轮播器
76
+ slider(){
77
+ return this.$refs.slider;
78
+ }
79
+
80
+ },
81
+ watch: {
82
+
83
+ //监听当前所选标签
84
+ cur_tab(val){
85
+ this.slider.flip(this.tags_data.tagList.findIndex((item)=>{
86
+ return item.id === val[0]
87
+ }) + 1, this.smooth);
88
+ this.$emit("on_select", val[0]);
89
+ }
90
+
91
+ },
92
+ methods: {
93
+
94
+ //初始化内容定位
95
+ $_init_page(){
96
+ this.slider.flip(this.tags_data.tagList.findIndex((item)=>{
97
+ return item.id === this.cur_tab[0]
98
+ }) + 1, false);
99
+ },
100
+
101
+ //触控分页
102
+ $_page_flip(page){
103
+ const val = this.tagsData.tagList[page - 1].id;
104
+ if(this.cur_tab[0] !== val) this.cur_tab = [val];
105
+ }
106
+
107
+ }
108
+ }
109
+ </script>