Authored by 李奇

delete wetoast

... ... @@ -5,7 +5,6 @@ import {verify} from './common/api';
import config from './common/config';
import Promise from './vendors/es6-promise';
import { MD5 } from './vendors/crypto';
import { WeToast } from './vendors/toast/wetoast';
import { wechatAuthLogin, verifySessionKey } from './common/login';
import { stringify } from './vendors/query-stringify';
import './router/index';
... ... @@ -247,6 +246,5 @@ App({
},
getPvid() {
return MD5(`${new Date().getTime()}${udid.get()}`).toString();
},
WeToast
}
});
... ...
... ... @@ -17,5 +17,4 @@
}
@import "./iconfont.wxss";
@import "./vendors/toast/wetoast.wxss";
@import "./vendors/zanui/index.wxss";
... ...
... ... @@ -335,13 +335,6 @@ Page({
this.shopRecList(res.data.shop_id);
}
})
.catch(function (error) {
this.wetoast.toast({
title: error.code + error.message + '',
titleClassName: 'wetoast-title',
duration: 1000
});
});
},
supportService: function () {
... ... @@ -468,10 +461,10 @@ Page({
}
if (tempItem.storage_number <= 0) {
this.wetoast.toast({
wx.showToast({
title: '该尺码已经售罄',
titleClassName: 'wetoast-title',
duration: 1000
icon: 'none',
duration: 2000
});
pickData.view.buyButtonEnable = false
... ...
/**
* WeToast by kiinlam
* WeApp Toast add-ons
* 微信小程序toast增强插件
* Github: https://github.com/kiinlam/wetoast
* LICENSE: MIT
*/
function WeToastClass () {
//构造函数
function WeToast () {
let pages = getCurrentPages()
let curPage = pages[pages.length - 1]
this.__page = curPage
this.__timeout = null
//附加到page上,方便访问
curPage.wetoast = this
return this
}
//切换显示/隐藏
WeToast.prototype.toast = function(data) {
try {
if (!data) {
this.hide()
} else {
this.show(data)
}
} catch (err) {
// console.error(err)
// fail callback
data && typeof data.fail === 'function' && data.fail(data)
} finally {
// complete callback
data && typeof data.complete === 'function' && data.complete(data)
}
}
//显示
WeToast.prototype.show = function(data) {
let page = this.__page
clearTimeout(this.__timeout)
//display需要先设置为block之后,才能执行动画
page.setData({
'__wetoast__.reveal': true
})
setTimeout(()=>{
let animation = wx.createAnimation()
animation.opacity(1).step()
data.animationData = animation.export()
data.reveal = true
page.setData({
__wetoast__: data
})
},30)
if (data.duration === 0) {
// success callback after toast showed
setTimeout (() => {
typeof data.success === 'function' && data.success(data)
}, 430)
} else {
this.__timeout = setTimeout(() => {
this.toast()
// success callback
typeof data.success === 'function' && data.success(data)
}, (data.duration || 1500) + 400)
}
}
//隐藏
WeToast.prototype.hide = function() {
let page = this.__page
clearTimeout(this.__timeout)
if (!page.data.__wetoast__.reveal) {
return
}
let animation = wx.createAnimation()
animation.opacity(0).step()
page.setData({
'__wetoast__.animationData': animation.export()
})
setTimeout(() => {
page.setData({
__wetoast__: {'reveal': false}
})
}, 400)
}
return new WeToast()
}
module.exports = {
WeToast: WeToastClass
}
\ No newline at end of file
<!-- wetoast.wxml -->
<template name="wetoast">
<view class="wetoast {{reveal ? 'wetoast_show' : ''}}">
<view class="wetoast__mask"></view>
<view class="wetoast__bd" animation="{{animationData}}">
<block wx:if="{{img}}">
<view class="wetoast__bd__img {{imgClassName || ''}}">
<image class="wetoast__bd__img_desc" src="{{img}}" mode="{{imgMode || 'scaleToFill'}}"></image>
</view>
</block>
<block wx:if="{{title}}">
<view class="wetoast__bd__title {{titleClassName || ''}}">{{title}}</view>
</block>
</view>
</view>
</template>
\ No newline at end of file
/**toast.wxss**/
.wetoast {
display: none;
}
.wetoast_show {
display: block;
}
.wetoast__mask {
position: fixed;
z-index: 1000;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.wetoast__bd {
opacity: 0;
display: flex;
flex-direction: column;
position: fixed;
z-index: 5000;
/*min-width: 8.4em;
min-height: 8.4em;*/
max-width: 70%;
top: 140px;
left: 50%;
padding: 15px;
box-sizing: border-box;
transform: translateX(-50%);
background: rgba(40, 40, 40, 0.75);
border-radius: 5px;
color: #FFFFFF;
word-wrap: break-word;
word-break: break-all;
align-items: center;
justify-content: space-around;
}
.wetoast__bd__img {
margin-top: 3px;
}
.wetoast__bd__img_desc {
width: 55px;
height: 55px;
vertical-align: middle;
}
.wetoast__bd__title {
margin: 3px 0;
font-size: 1.2em;
text-align: center;
}
.wetoast-title {
font-size: 28rpx;
}
\ No newline at end of file