UNPKG

captain-ui

Version:

有赞vue wap业务组件库

243 lines (224 loc) 6.49 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = void 0; require("vant/es/icon/style"); var _icon = _interopRequireDefault(require("vant/es/icon")); var _mapKeysToCamelCase = _interopRequireDefault(require("@youzan/utils/string/mapKeysToCamelCase")); var _mask = _interopRequireDefault(require("./components/mask")); var _swiper = _interopRequireDefault(require("./components/swiper")); var _slide = _interopRequireDefault(require("./components/slide")); var _coffee = _interopRequireDefault(require("./components/coffee")); var _load = _interopRequireDefault(require("./directive/load")); var _viewport = _interopRequireDefault(require("./utils/viewport")); var _components; var _default2 = { render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { staticClass: "cap-scroll" }, [_vm.loadingImg ? _c('div', { staticClass: "cap-scroll__loading" }) : _vm._e(), _c('div', { directives: [{ name: "show", rawName: "v-show", value: !_vm.loadingImg, expression: "!loadingImg" }] }, [_vm.$attrs['has-page-wipe'] ? _c('cap-scroll-mask', { attrs: { "has-page-wipe": _vm.$attrs['has-page-wipe'], "mask-url": _vm.$attrs['wipe-image-url'], "bg-url": _vm.firstPageImageUrl }, on: { "remove": function remove($event) { _vm.showSwiper = true; } } }) : _vm._e(), _c('div', { directives: [{ name: "show", rawName: "v-show", value: _vm.showSwiper, expression: "showSwiper" }], staticClass: "cap-scroll__content" }, [_vm.showHome ? _c('a', { attrs: { "href": _vm.homeLink } }, [_c('van-icon', { staticClass: "cap-scroll__home-icon", attrs: { "name": "wap-home" } })], 1) : _vm._e(), _vm.showSwiper && _vm.showAudio && !_vm.loadingImg ? _c('div', { staticClass: "cap-scroll__media" }, [_c('van-icon', { staticClass: "cap-scroll__audio-icon", attrs: { "name": "audio" } }), _c('audio', { ref: "audio", attrs: { "src": _vm.audioUrl, "loop": "" } }), _c('cap-scroll-coffee', { attrs: { "steam-height": 100, "steam-width": 80 } }, [_c('img', { attrs: { "src": "//b.yzcdn.cn/v2/image/scroll/audio_widget_01@2x.png", "alt": "coffee" } })])], 1) : _vm._e(), _c('img', { directives: [{ name: "show", rawName: "v-show", value: _vm.showIndicator, expression: "showIndicator" }], staticClass: "cap-scroll__indicator", attrs: { "src": "//b.yzcdn.cn/v2/image/scroll/gesture_mini.png", "alt": "滑动提示", "width": "230", "height": "280" } }), _c('cap-scroll-swiper', { ref: "swiper", attrs: { "loop": _vm.$attrs['loop'], "effect": _vm.$attrs['flipway'] }, on: { "pagechange": _vm.onPageChange } }, _vm._l(_vm.list, function (item, index) { return _c('cap-scroll-slide', { directives: [{ name: "load", rawName: "v-load", value: _vm.loadResource, expression: "loadResource" }], key: index, attrs: { "active": _vm.activeIndex === index, "enter-class": _vm.enterClass, "leave-active-class": _vm.leaveActiveClass, "data": item, "index": index } }); }), 1)], 1)], 1)]); }, name: 'cap-scroll', directives: { load: _load.default }, components: (_components = {}, _components[_icon.default.name] = _icon.default, _components[_mask.default.name] = _mask.default, _components[_swiper.default.name] = _swiper.default, _components[_slide.default.name] = _slide.default, _components[_coffee.default.name] = _coffee.default, _components), inheritAttrs: false, props: { showHome: { type: Boolean, default: true }, hasAudio: { type: Boolean, default: false }, audioUrl: { type: String, default: '' }, scenes: { type: Array, default: function _default() { return []; } }, flipway: { type: String, default: 'default' }, firstPageImageUrl: String, lastPageImageUrl: String }, data: function data() { var global = window._global; var homeLink = global.url.wap + "/showcase/home?kdt_id=" + global.kdt_id; var showSwiper = !this.$attrs['has-page-wipe']; return { homeLink: homeLink, showSwiper: showSwiper, showIndicator: true, loadingImg: true, activeIndex: 0, enterClass: '', leaveActiveClass: '', slideCount: 0 }; }, computed: { list: function list() { return [{ imageUrl: this.firstPageImageUrl }].concat(this.scenes, [{ imageUrl: this.lastPageImageUrl }]).map(function (item) { return (0, _mapKeysToCamelCase.default)(item); }); }, showAudio: function showAudio() { return this.hasAudio && !!this.audioUrl; } }, watch: { showSwiper: function showSwiper(val) { var _this = this; if (val && !this.loadingImg) { this.$nextTick(function () { _this.playMedia(); }); } }, loadingImg: function loadingImg(val) { var _this2 = this; if (!val && this.showSwiper) { this.$nextTick(function () { _this2.playMedia(); }); } } }, created: function created() { (0, _viewport.default)(); }, methods: { onPageChange: function onPageChange(cur, prev, direction) { this.showIndicator && (this.showIndicator = false); this.activeIndex = cur; this.enterClass = "slide-enter-" + direction; this.leaveActiveClass = "slide-" + this.flipway + "-" + direction + "-leave-active"; }, loadResource: function loadResource(total) { !this.slideCount && (this.slideCount = this.$refs.swiper.$slots.default.length); if (this.slideCount && this.slideCount === total) { this.loadingImg = false; } }, playMedia: function playMedia() { this.$refs.audio.play(); } } }; exports.default = _default2;