diff --git a/dist/nav-bar/index.js b/dist/nav-bar/index.js new file mode 100644 index 00000000..28ac24dc --- /dev/null +++ b/dist/nav-bar/index.js @@ -0,0 +1,30 @@ +'use strict'; + +Component({ + externalClasses: ['custom-class', 'title-class'], + + options: { + multipleSlots: true + }, + + properties: { + title: String, + leftText: String, + rightText: String, + leftArrow: Boolean, + fixed: Boolean, + zIndex: { + type: Number, + value: 1 + } + }, + + methods: { + onTapLeft: function onTapLeft() { + this.triggerEvent('tap-left'); + }, + onTapRight: function onTapRight() { + this.triggerEvent('tap-right'); + } + } +}); \ No newline at end of file diff --git a/dist/toast/index.json b/dist/nav-bar/index.json similarity index 100% rename from dist/toast/index.json rename to dist/nav-bar/index.json diff --git a/dist/nav-bar/index.wxml b/dist/nav-bar/index.wxml new file mode 100644 index 00000000..5fc9f268 --- /dev/null +++ b/dist/nav-bar/index.wxml @@ -0,0 +1,24 @@ + + + + + {{ leftText }} + + + + + {{ title }} + + + + {{ rightText }} + + + diff --git a/dist/nav-bar/index.wxss b/dist/nav-bar/index.wxss new file mode 100644 index 00000000..c21c6b73 --- /dev/null +++ b/dist/nav-bar/index.wxss @@ -0,0 +1 @@ +.van-nav-bar{height:46px;position:relative;-webkit-user-select:none;user-select:none;text-align:center;line-height:46px;background-color:#fff}.van-nav-bar__arrow{color:#38f;vertical-align:middle;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.van-nav-bar__arrow+.van-nav-bar__text{margin-left:-20px;padding-left:25px}.van-nav-bar--fixed{top:0;left:0;width:100%;position:fixed}.van-nav-bar__title{margin:0 auto;max-width:60%;font-size:16px}.van-nav-bar__left,.van-nav-bar__right{bottom:0;font-size:14px;position:absolute}.van-nav-bar__left{left:15px}.van-nav-bar__right{right:15px}.van-nav-bar__text{color:#38f;margin:0 -15px;padding:0 15px;display:inline-block;vertical-align:middle}.van-nav-bar__text:active{background-color:#e8e8e8} \ No newline at end of file diff --git a/dist/notify/index.js b/dist/notify/index.js new file mode 100644 index 00000000..eda59805 --- /dev/null +++ b/dist/notify/index.js @@ -0,0 +1,77 @@ +'use strict'; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +Component({ + properties: { + text: String, + color: { + type: String, + value: '#fff' + }, + backgroundColor: { + type: String, + value: '#e64340' + }, + duration: { + type: Number, + value: 3000 + } + }, + + methods: { + show: function show() { + var _this = this; + + var duration = this.data.duration; + + + clearTimeout(this.timer); + this.setData({ + show: true + }); + + if (duration > 0 && duration !== Infinity) { + this.timer = setTimeout(function () { + _this.hide(); + }, duration); + } + }, + hide: function hide() { + clearTimeout(this.timer); + this.setData({ + show: false + }); + } + } +}); + +var defaultOptions = { + selector: '#van-notify', + duration: 3000 +}; + +function Notify() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var pages = getCurrentPages(); + var ctx = pages[pages.length - 1]; + + options = Object.assign({}, defaultOptions, parseParam(options)); + + var el = ctx.selectComponent(options.selector); + delete options.selector; + + if (el) { + el.setData(_extends({}, options)); + el.show(); + } +} + +function parseParam() { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + return typeof params === 'object' ? params : { text: params }; +} + +module.exports = Notify; \ No newline at end of file diff --git a/dist/notify/index.json b/dist/notify/index.json new file mode 100644 index 00000000..32640e0d --- /dev/null +++ b/dist/notify/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/dist/notify/index.wxml b/dist/notify/index.wxml new file mode 100644 index 00000000..5fc9f597 --- /dev/null +++ b/dist/notify/index.wxml @@ -0,0 +1,6 @@ + + {{ text }} + diff --git a/dist/notify/index.wxss b/dist/notify/index.wxss new file mode 100644 index 00000000..81be6eb5 --- /dev/null +++ b/dist/notify/index.wxss @@ -0,0 +1 @@ +.van-notify{top:0;opacity:0;width:100%;z-index:110;color:#fff;position:fixed;min-height:32px;line-height:2.3;font-size:14px;text-align:center;background-color:#e64340;-webkit-transition:all .4s ease;transition:all .4s ease;-webkit-transform:translateZ(0) translateY(-100%);transform:translateZ(0) translateY(-100%)}.van-notify--show{opacity:1;-webkit-transform:translateZ(0) translateY(0);transform:translateZ(0) translateY(0)} \ No newline at end of file diff --git a/dist/toast/index.js b/dist/toast/index.js deleted file mode 100644 index 924a2fdc..00000000 --- a/dist/toast/index.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var DEFAULT_DATA = { - show: false, - message: '', - icon: '', - image: '', - mask: false -}; - -var SUPPORT_TYPE = ['loading', 'success', 'fail']; - -Component({ - data: _extends({}, DEFAULT_DATA), - - methods: { - show: function show(options) { - var toastOptions = _extends({}, options); - - var icon = options.icon || ''; - var image = options.image || ''; - if (SUPPORT_TYPE.indexOf(options.type) > -1) { - icon = options.type; - image = ''; - } - - this.setData(_extends({}, toastOptions, { - icon: icon, - image: image - })); - }, - clear: function clear() { - this.setData(_extends({}, DEFAULT_DATA)); - } - } -}); \ No newline at end of file diff --git a/dist/toast/index.wxml b/dist/toast/index.wxml deleted file mode 100644 index af4af861..00000000 --- a/dist/toast/index.wxml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - {{ message }} - diff --git a/dist/toast/index.wxss b/dist/toast/index.wxss deleted file mode 100644 index b7460d18..00000000 --- a/dist/toast/index.wxss +++ /dev/null @@ -1 +0,0 @@ -.van-toast{position:fixed;top:35%;left:50%;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:14px;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px 18px;text-align:center;border-radius:4px;z-index:100}.van-toast--notitle{padding:18px}.van-toast__icon{display:block;width:40px;height:40px;line-height:40px;margin:0 auto;padding:12px 15px;font-size:38px;text-align:center}.van-toast__icon-loading{line-height:0}.van-loading{width:20px;height:20px;display:inline-block;vertical-align:middle;-webkit-animation:weuiLoading 1s steps(12,end) infinite;animation:weuiLoading 1s steps(12,end) infinite;background:transparent url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICA8L3JlY3Q+CiAgICA8cmVjdCB4PSc0Ni41JyB5PSc0MCcgd2lkdGg9JzcnIGhlaWdodD0nMjAnIHJ4PSc1JyByeT0nNScgZmlsbD0nIzk4OTY5NycKICAgICAgICAgIHRyYW5zZm9ybT0ncm90YXRlKDMwIDUwIDUwKSB0cmFuc2xhdGUoMCAtMzApJz4KICAgICAgICAgICAgICAgICByZXBlYXRDb3VudD0naW5kZWZpbml0ZScvPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyM5Qjk5OUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSg2MCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICAgICAgICAgICAgICAgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnLz4KICAgI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Gw9JyNDQkNCQ0InCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEMkQyRDInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=) no-repeat;background-size:100%}.van-toast__icon-loading .van-loading{width:40px;height:40px}.van-toast__icon-image{background-size:40px;background-position:center;background-repeat:no-repeat} \ No newline at end of file diff --git a/dist/toast/toast.js b/dist/toast/toast.js deleted file mode 100644 index 5f206e7b..00000000 --- a/dist/toast/toast.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict'; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var TOAST_CONFIG_KEY = 'vant.__zanToastPageConfig'; -var DEFAULT_SHOW_TOAST_TIME = 3000; - -var timeoutData = { - timeoutId: 0, - toastCtx: null -}; - -var globalToastUserConfig = {}; - -// 获取页面上下文 -function getPageCtx(pageCtx) { - var ctx = pageCtx; - - if (!ctx) { - var pages = getCurrentPages(); - ctx = pages[pages.length - 1]; - } - - return ctx; -} - -// 获取当前页面的 toast 配置数据 -function getPageToastConfig(pageCtx) { - var vantData = pageCtx.data.vant || {}; - return vantData.__zanToastPageConfig || {}; -} - -// Toast 显示函数 -function Toast(optionsOrMsg, pageCtx) { - // 参数格式化处理 - // 如果是文字,默认为 message - var options = optionsOrMsg || {}; - if (typeof optionsOrMsg === 'string') { - options = { message: optionsOrMsg }; - } - - var ctx = getPageCtx(pageCtx); - var pageToastUserSetting = getPageToastConfig(ctx); - var parsedOptions = _extends({}, globalToastUserConfig, pageToastUserSetting, options); - var toastCtx = ctx.selectComponent(parsedOptions.selector); - - if (!toastCtx) { - console.error('无法找到对应的toast组件,请于页面中注册并在 wxml 中声明 toast 自定义组件'); - return; - } - - if (timeoutData.timeoutId) { - Toast.clear(); - } - - toastCtx.show(_extends({}, parsedOptions, { - show: true - })); - - var timeoutId = 0; - // toast 计时,如果小于0,就不会去关闭。 - // 如果不传,就取默认值 - var timeoutOption = parsedOptions.timeout || DEFAULT_SHOW_TOAST_TIME; - if (timeoutOption >= 0) { - timeoutId = setTimeout(function () { - toastCtx.clear(); - }, timeoutOption); - } - - timeoutData = { - timeoutId: timeoutId, - toastCtx: toastCtx - }; -} - -// 设置 toast 基础属性 -Toast.setDefaultOptions = function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'page'; - - var parsedDefaultOptions = { - selector: options.selector || '', - type: options.type || '', - icon: options.icon || '', - image: options.image || '', - timeout: options.timeout || DEFAULT_SHOW_TOAST_TIME - }; - - if (type === 'global') { - globalToastUserConfig = _extends({}, parsedDefaultOptions); - } else if (type === 'page') { - var _ctx$setData; - - var ctx = getPageCtx(); - ctx.setData((_ctx$setData = {}, _ctx$setData['' + TOAST_CONFIG_KEY] = parsedDefaultOptions, _ctx$setData)); - } -}; - -// 重置 toast 基础属性 -Toast.resetDefaultOptions = function () { - var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'page'; - - if (type === 'global') { - globalToastUserConfig = {}; - } else { - var _ctx$setData2; - - var ctx = getPageCtx(); - ctx.setData((_ctx$setData2 = {}, _ctx$setData2['' + TOAST_CONFIG_KEY] = {}, _ctx$setData2)); - } -}; - -// 清理所有 toast -Toast.clear = function () { - clearTimeout(timeoutData.timeoutId); - - try { - timeoutData.toastCtx && timeoutData.toastCtx.clear(); - } catch (e) {} - - timeoutData = { - timeoutId: 0, - toastCtx: null - }; -}; - -// 显示 loading -Toast.loading = function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - Toast(_extends({}, options, { - type: 'loading' - })); -}; - -module.exports = Toast; \ No newline at end of file