index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <view class="debug-swiper">
  3. <view class="debug-swiper-header">
  4. <view class="header-content">
  5. <view class="header-content-info">
  6. <view class="logo">
  7. <image class="image" src="https://swiper.zebraui.com/logo.png" mode="widthFix"></image>
  8. </view>
  9. </view>
  10. <view class="header-content-button">
  11. <a class="button-item" href="https://swiper.zebraui.com/" target="_blank">文档</a>
  12. <a class="button-item" href="https://ext.dcloud.net.cn/plugin?id=7273" target="_blank">插件地址</a>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="debug-swiper-bottom">
  17. <view class="debug-swiper-left">
  18. <view class="left-content-wrapper">
  19. <view class="left-content">
  20. <view class="left-content-view">
  21. <demo-block title="调试">
  22. <z-swiper ref="zSwiper" v-model="list" :options="options" :custom-style="customStyle">
  23. <z-swiper-item v-for="(item,index) in list" :key="index">
  24. <image class="image" :src="item.img" mode="aspectFill">
  25. </image>
  26. </z-swiper-item>
  27. </z-swiper>
  28. </demo-block>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="debug-swiper-content">
  34. <scroll-view scroll-y="true" class="content-scroll">
  35. <view class="content-scroll-wrapper">
  36. <view class="wrapper-item">
  37. <view class="item-title">
  38. 数据
  39. </view>
  40. <view class="item-content-list">
  41. <view class="content-list-item">
  42. <view class="item-left">
  43. 条数
  44. </view>
  45. <view class="item-right">
  46. <radio-group @change="radioChangeData">
  47. <radio value="1" />1
  48. <radio style="margin-left: 20rpx;" value="2" />2
  49. <radio style="margin-left: 20rpx;" value="3" />3
  50. <radio style="margin-left: 20rpx;" value="4" />4
  51. <radio style="margin-left: 20rpx;" value="5" />5
  52. <radio style="margin-left: 20rpx;" value="6" checked />6
  53. <radio style="margin-left: 20rpx;" value="7" />7
  54. <radio style="margin-left: 20rpx;" value="8" />8
  55. </radio-group>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="wrapper-item">
  61. <view class="item-title">
  62. Basic (swiper一般选项)
  63. </view>
  64. <view class="item-content-list">
  65. <view class="content-list-item">
  66. <view class="item-left">
  67. direction
  68. </view>
  69. <view class="item-right">
  70. <radio-group @change="radioChangeDirection">
  71. <radio value="horizontal" checked />horizontal
  72. <radio style="margin-left: 20rpx;" value="vertical" />vertical
  73. </radio-group>
  74. </view>
  75. </view>
  76. <view class="content-list-item">
  77. <view class="item-left">
  78. speed
  79. </view>
  80. <view class="item-right">
  81. <input v-model="speedValue" style="width: 100rpx;" type="number" maxlength="4"
  82. placeholder="毫秒" />
  83. <button size="mini" @click="confirmSpeed()">确定</button>
  84. </view>
  85. </view>
  86. <view class="content-list-item">
  87. <view class="item-left">
  88. enabled
  89. </view>
  90. <view class="item-right">
  91. <radio-group @change="radioChangeEnabled">
  92. <radio value="true" checked />true
  93. <radio style="margin-left: 20rpx;" value="false" />false
  94. </radio-group>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="wrapper-item">
  100. <view class="item-title">
  101. Carousel (旋转木马)
  102. </view>
  103. <view class="item-content-list">
  104. <view class="content-list-item">
  105. <view class="item-left">
  106. slidesPerView
  107. </view>
  108. <view class="item-right">
  109. <radio-group @change="radioChangeSlidesPerView">
  110. <radio value="1" checked />1
  111. <radio style="margin-left: 20rpx;" value="2" />2
  112. <radio style="margin-left: 20rpx;" value="3" />3
  113. </radio-group>
  114. </view>
  115. </view>
  116. <view class="content-list-item">
  117. <view class="item-left">
  118. centeredSlides
  119. </view>
  120. <view class="item-right">
  121. <radio-group @change="radioChangeCenteredSlides">
  122. <radio value="true" />true
  123. <radio style="margin-left: 20rpx;" value="false" checked />false
  124. </radio-group>
  125. </view>
  126. </view>
  127. <view class="content-list-item">
  128. <view class="item-left">
  129. centeredSlidesBounds
  130. </view>
  131. <view class="item-right">
  132. <radio-group @change="radioChangeCenteredSlidesBounds">
  133. <radio value="true" />true
  134. <radio style="margin-left: 20rpx;" value="false" checked />false
  135. </radio-group>
  136. </view>
  137. </view>
  138. <view class="content-list-item">
  139. <view class="item-left">
  140. slidesPerGroup
  141. </view>
  142. <view class="item-right">
  143. <radio-group @change="radioChangeSlidesPerGroup">
  144. <radio value="1" checked />1
  145. <radio style="margin-left: 20rpx;" value="2" />2
  146. <radio style="margin-left: 20rpx;" value="3" />3
  147. <radio style="margin-left: 20rpx;" value="3" />4
  148. <radio style="margin-left: 20rpx;" value="3" />5
  149. </radio-group>
  150. </view>
  151. </view>
  152. <view class="content-list-item">
  153. <view class="item-left">
  154. spaceBetween
  155. </view>
  156. <view class="item-right">
  157. <input v-model="spaceBetween" style="width: 100rpx;" type="number" maxlength="2"
  158. placeholder="距离" />
  159. <button size="mini" @click="confirmSpaceBetween()">确定</button>
  160. </view>
  161. </view>
  162. <view class="content-list-item">
  163. <view class="item-left">
  164. slidesOffsetBefore
  165. </view>
  166. <view class="item-right">
  167. <input v-model="slidesOffsetBefore" style="width: 100rpx;" type="number"
  168. maxlength="2" placeholder="距离" />
  169. <button size="mini" @click="confirmSlidesOffsetBefore()">确定</button>
  170. </view>
  171. </view>
  172. <view class="content-list-item">
  173. <view class="item-left">
  174. slidesOffsetAfter
  175. </view>
  176. <view class="item-right">
  177. <input v-model="slidesOffsetAfter" style="width: 100rpx;" type="number"
  178. maxlength="2" placeholder="距离" />
  179. <button size="mini" @click="confirmSlidesOffsetAfter()">确定</button>
  180. </view>
  181. </view>
  182. <view class="content-list-item">
  183. <view class="item-left">
  184. centerInsufficientSlides
  185. </view>
  186. <view class="item-right">
  187. <radio-group @change="radioChangeCenterInsufficientSlides">
  188. <radio value="true" />true
  189. <radio style="margin-left: 20rpx;" value="false" checked />false
  190. </radio-group>
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. <view class="wrapper-item">
  196. <view class="item-title">
  197. Loop (无限循环)
  198. </view>
  199. <view class="item-content-list">
  200. <view class="content-list-item">
  201. <view class="item-left">
  202. loop
  203. </view>
  204. <view class="item-right">
  205. <radio-group @change="radioChangeLoop">
  206. <radio value="true" checked />true
  207. <radio style="margin-left: 20rpx;" value="false" />false
  208. </radio-group>
  209. </view>
  210. </view>
  211. <view class="content-list-item">
  212. <view class="item-left">
  213. speed
  214. </view>
  215. <view class="item-right">
  216. <input v-model="speedValue" style="width: 100rpx;" type="number" maxlength="4"
  217. placeholder="毫秒" />
  218. <button size="mini" @click="confirmSpeed()">确定</button>
  219. </view>
  220. </view>
  221. <view class="content-list-item">
  222. <view class="item-left">
  223. enabled
  224. </view>
  225. <view class="item-right">
  226. <radio-group @change="radioChangeEnabled">
  227. <radio value="true" checked />true
  228. <radio style="margin-left: 20rpx;" value="false" />false
  229. </radio-group>
  230. </view>
  231. </view>
  232. </view>
  233. </view>
  234. </view>
  235. </scroll-view>
  236. </view>
  237. </view>
  238. </view>
  239. </template>
  240. <script>
  241. import DemoBlock from '../../components/DemoBlock/DemoBlock.vue';
  242. export default {
  243. components: {
  244. DemoBlock
  245. },
  246. data() {
  247. return {
  248. customStyle: {},
  249. options: {
  250. speed: 300,
  251. slidesPerView: 1,
  252. centeredSlides: false,
  253. centeredSlidesBounds: false,
  254. slidesPerGroup: 1,
  255. spaceBetween: 0,
  256. slidesOffsetBefore: 0,
  257. slidesOffsetAfter: 0,
  258. centerInsufficientSlides: false,
  259. loop: false,
  260. pagination: {
  261. el: true,
  262. },
  263. // effect: 'coverflow',
  264. // centeredSlides: true,
  265. // spaceBetween: 60,
  266. // slidesPerView: 3,
  267. // width: 200,
  268. // loop: true
  269. },
  270. speedValue: 300,
  271. spaceBetween: 0,
  272. slidesOffsetBefore: 0,
  273. slidesOffsetAfter: 0,
  274. list: [{
  275. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe1.jpg'
  276. }, {
  277. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe2.jpg'
  278. }, {
  279. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe3.jpg'
  280. }, {
  281. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe4.jpg'
  282. }, {
  283. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe5.jpg'
  284. }, {
  285. img: 'https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe6.jpg'
  286. }],
  287. }
  288. },
  289. methods: {
  290. radioChangeData(val) {
  291. this.list = Array(...Array(parseInt(val.detail.value))).map((item, index) => {
  292. return {
  293. img: `https://cdn.zebraui.com/zebra-ui/images/swipe-demo/swipe${index+1}.jpg`
  294. }
  295. })
  296. },
  297. radioChangeDirection(value) {
  298. if (value.detail.value == "vertical") {
  299. Object.assign(this.customStyle, {
  300. height: '900rpx'
  301. })
  302. }
  303. this.$refs.zSwiper.swiper.changeDirection(value.detail.value);
  304. },
  305. radioChangeEnabled(value) {
  306. Object.assign(this.options, {
  307. enabled: value.detail.value == "true" ? true : false
  308. })
  309. if (value.detail.value == "true") {
  310. this.$refs.zSwiper.swiper.enable();
  311. } else {
  312. this.$refs.zSwiper.swiper.disable();
  313. }
  314. },
  315. radioChangeSlidesPerView(value) {
  316. Object.assign(this.options, {
  317. slidesPerView: parseInt(value.detail.value)
  318. })
  319. },
  320. radioChangeCenteredSlides(value) {
  321. Object.assign(this.options, {
  322. centeredSlides: value.detail.value == "true" ? true : false
  323. })
  324. },
  325. radioChangeCenteredSlidesBounds(value) {
  326. Object.assign(this.options, {
  327. centeredSlidesBounds: value.detail.value == "true" ? true : false
  328. })
  329. },
  330. radioChangeCenterInsufficientSlides(value) {
  331. Object.assign(this.options, {
  332. centerInsufficientSlides: value.detail.value == "true" ? true : false
  333. })
  334. },
  335. radioChangeLoop(value) {
  336. Object.assign(this.options, {
  337. loop: value.detail.value == "true" ? true : false
  338. })
  339. },
  340. radioChangeSlidesPerGroup(value) {
  341. Object.assign(this.options, {
  342. slidesPerGroup: parseInt(value.detail.value)
  343. })
  344. },
  345. confirmSpeed() {
  346. Object.assign(this.options, {
  347. speed: parseInt(this.speedValue)
  348. })
  349. },
  350. confirmSpaceBetween() {
  351. Object.assign(this.options, {
  352. spaceBetween: parseInt(this.spaceBetween)
  353. })
  354. },
  355. confirmSlidesOffsetBefore() {
  356. Object.assign(this.options, {
  357. slidesOffsetBefore: parseInt(this.slidesOffsetBefore)
  358. })
  359. },
  360. confirmSlidesOffsetAfter() {
  361. Object.assign(this.options, {
  362. slidesOffsetAfter: parseInt(this.slidesOffsetAfter)
  363. })
  364. }
  365. }
  366. }
  367. </script>
  368. <style scoped lang="scss">
  369. @media (max-width:719px) {}
  370. .debug-swiper {
  371. height: 100%;
  372. .debug-swiper-bottom {
  373. display: flex;
  374. flex-wrap: wrap;
  375. .debug-swiper-left {
  376. width: 860rpx;
  377. height: calc(100vh - 170rpx);
  378. // padding: 0 100rpx;
  379. .left-content-wrapper {
  380. margin: 50rpx;
  381. .left-content {
  382. // height: 1200rpx;
  383. height: calc(100vh - 270rpx);
  384. overflow: hidden;
  385. border-radius: 8rpx;
  386. box-shadow: 0 8rpx 24rpx #ebedf0;
  387. background: linear-gradient(131.16deg, #f0f2f7, snow 100%, #d8dce6 0);
  388. .left-content-view {
  389. padding: 50rpx 0;
  390. .image {
  391. height: 900rpx;
  392. width: 100%;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .debug-swiper-content {
  399. height: calc(100vh - 170rpx);
  400. width: calc(100vw - 860rpx);
  401. .content-scroll {
  402. height: 100%;
  403. .content-scroll-wrapper {
  404. padding: 50rpx;
  405. .wrapper-item {
  406. margin-bottom: 80rpx;
  407. .item-title {
  408. font-size: 40rpx;
  409. font-weight: bold;
  410. }
  411. .item-content-list {
  412. margin-top: 30rpx;
  413. display: flex;
  414. flex-wrap: wrap;
  415. align-items: center;
  416. .content-list-item {
  417. margin-right: 100rpx;
  418. margin-bottom: 20rpx;
  419. display: flex;
  420. align-items: center;
  421. .item-left {
  422. font-size: 34rpx;
  423. font-weight: bold;
  424. }
  425. .item-right {
  426. margin-left: 30rpx;
  427. display: flex;
  428. align-items: center;
  429. font-size: 28rpx;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. }
  436. }
  437. }
  438. .debug-swiper-header {
  439. width: 100%;
  440. background-color: #08c6c8;
  441. user-select: none;
  442. height: 120rpx;
  443. .header-content {
  444. padding: 0 60rpx;
  445. display: flex;
  446. align-items: center;
  447. justify-content: space-between;
  448. .header-content-button {
  449. display: flex;
  450. align-items: center;
  451. .button-item {
  452. margin-left: 50rpx;
  453. position: relative;
  454. display: block;
  455. padding: 0 24rpx;
  456. color: #fff;
  457. font-size: 28rpx;
  458. line-height: 48rpx;
  459. text-align: center;
  460. border: 1rpx solid hsla(0, 0%, 100%, .7);
  461. border-radius: 40rpx;
  462. cursor: pointer;
  463. transition: .3s ease-in-out;
  464. text-decoration: none;
  465. }
  466. }
  467. .header-content-info {
  468. display: flex;
  469. align-items: center;
  470. .logo {
  471. width: 220rpx;
  472. height: 120rpx;
  473. display: flex;
  474. align-items: center;
  475. .image {
  476. width: 100%;
  477. height: 100%;
  478. }
  479. }
  480. .name {
  481. color: #fff;
  482. font-size: 32rpx;
  483. }
  484. }
  485. }
  486. }
  487. }
  488. </style>