mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-16 21:02:42 +08:00
增加微信小程序版
This commit is contained in:
1
liferestartWX/utils/wux/toast/index.js
Normal file
1
liferestartWX/utils/wux/toast/index.js
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_index=require("../index");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,s)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var defaults={prefixCls:"wux-toast",classNames:"wux-animate--fadeIn",type:"default",duration:1500,color:"#fff",text:"",icon:"",mask:!0,transparent:!0,success:function(){}},iconTypes={success:"ios-checkmark-circle-outline",cancel:"ios-close-circle-outline",forbidden:"ios-alert",text:"",default:""},_toast=null;(0,_baseComponent.default)({useFunc:!0,data:defaults,computed:{classes:["prefixCls, icon",function(e,t){return{wrap:(0,_classNames2.default)(e),content:(0,_classNames2.default)("".concat(e,"__content"),_defineProperty({},"".concat(e,"__content--has-icon"),t)),icon:"".concat(e,"__icon"),text:"".concat(e,"__text")}}]},methods:{hide:function(){if(this.removed)return!1;this.removed=!0,_toast&&(clearTimeout(_toast.timeout),_toast=null),this.$$setData({in:!1}),this.$wuxBackdrop&&this.$wuxBackdrop.release(),"function"==typeof this.fns.success&&this.fns.success()},show:function(s,e){var r=this;"string"==typeof s&&(s=Object.assign({},{text:arguments[0]},e));function t(){_toast&&_toast.hide.call(r)}var n=new Promise(function(e){var t=r.$$mergeOptionsAndBindMethods(Object.assign({},defaults,s)),n=iconTypes[t.type]||t.icon;t.icon=n,r.removed=!1,r.$$setData(_objectSpread({in:!0},t)),r.$wuxBackdrop&&r.$wuxBackdrop.retain(),_toast&&(clearTimeout(_toast.timeout),_toast=null),(_toast={hide:r.hide}).timeout=setTimeout(function(){return r.hide(),e(!0)},Math.max(0,t.duration))});return t.then=function(e,t){return n.then(e,t)},t.promise=n,t},success:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign({type:"success"},e))},warning:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign({type:"forbidden"},e))},error:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign({type:"cancel"},e))},info:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign({type:"text"},e))}},created:function(){this.data.mask&&(this.$wuxBackdrop=(0,_index.$wuxBackdrop)("#wux-backdrop",this))}});
|
||||
8
liferestartWX/utils/wux/toast/index.json
Normal file
8
liferestartWX/utils/wux/toast/index.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-animation-group": "../animation-group/index",
|
||||
"wux-backdrop": "../backdrop/index",
|
||||
"wux-icon": "../icon/index"
|
||||
}
|
||||
}
|
||||
7
liferestartWX/utils/wux/toast/index.wxml
Normal file
7
liferestartWX/utils/wux/toast/index.wxml
Normal file
@@ -0,0 +1,7 @@
|
||||
<wux-backdrop id="wux-backdrop" transparent="{{ transparent }}" wx:if="{{ mask }}" />
|
||||
<wux-animation-group wux-class="{{ classes.wrap }}" in="{{ in }}" classNames="{{ classNames }}">
|
||||
<view class="{{ classes.content }}">
|
||||
<wux-icon wux-class="{{ classes.icon }}" type="{{ icon }}" size="55" color="{{ color }}" wx:if="{{ icon }}" />
|
||||
<view class="{{ classes.text }}">{{ text }}</view>
|
||||
</view>
|
||||
</wux-animation-group>
|
||||
1
liferestartWX/utils/wux/toast/index.wxss
Normal file
1
liferestartWX/utils/wux/toast/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
.wux-toast{position:fixed;z-index:5000;top:50%;left:50%;background:rgba(40,40,40,.75);font-size:28rpx;line-height:1.5;text-align:center;border-radius:8rpx;color:#fff;transform:translate3d(-50%,-50%,0)}.wux-toast__content{min-width:236rpx;padding:18rpx 30rpx;box-sizing:border-box}.wux-toast__content--has-icon{padding:30rpx}.wux-toast__content--has-icon .wux-toast__text{margin-top:12rpx}.wux-toast__icon{margin:0;display:block}
|
||||
Reference in New Issue
Block a user