1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| var defaultEvent = function defaultEvent() {};
|
| var COUNT_DOWN_TIMES = 10;
| Component({
| props: {
| className: '',
| type: 'network',
| local: false,
| footer: null,
| onTapLeft: defaultEvent,
| onTapRight: defaultEvent,
| isCountDown: false,
| countDownText: '重新刷新'
| },
| data: {
| defaultTitle: {
| network: '网络不给力',
| error: '页面遇到一些小问题',
| busy: '请稍等哦,马上出来',
| empty: '什么都没有',
| logoff: '此用户已注销',
| payment: '付款没成功',
| redpacket: '什么都没有'
| },
| defaultBrief: {
| network: '世界上最遥远的距离莫过于此',
| error: '请稍后刷新',
| busy: '前面还有很多朋友在排队',
| empty: '前不见古人,后不见来者',
| logoff: '',
| payment: '请重新付款',
| redpacket: '红包已领空'
| },
| countDownTitle: ''
| },
| didMount: function didMount() {
| var _this = this;
|
| var _this$props = this.props,
| countDownText = _this$props.countDownText,
| isCountDown = _this$props.isCountDown;
|
| if (!isCountDown) {
| return;
| }
|
| var countDownTimes = COUNT_DOWN_TIMES;
| this._timer = null;
|
| var execCountDown = function execCountDown() {
| _this.setData({
| countDownTitle: countDownTimes + " \u79D2\u540E" + countDownText
| });
|
| countDownTimes -= 1;
|
| if (countDownTimes < 0) {
| clearTimeout(_this._timer);
|
| _this.setData({
| isCountDown: false
| });
| } else {
| _this._timer = setTimeout(execCountDown, 1000);
| }
| };
|
| execCountDown();
| },
| didUnmount: function didUnmount() {
| if (this._timer) {
| clearTimeout(this._timer);
| this._timer = null;
| }
| },
| methods: {
| onDefaultTap: function onDefaultTap(propName) {
| if (this.props.footer && this.props[propName]) {
| var _this$props2;
|
| for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
| args[_key - 1] = arguments[_key];
| }
|
| (_this$props2 = this.props)[propName].apply(_this$props2, args);
| } else {
| defaultEvent();
| }
| },
| onLeftButton: function onLeftButton() {
| for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
| args[_key2] = arguments[_key2];
| }
|
| this.onDefaultTap.apply(this, ['onTapLeft'].concat(args));
| },
| onRightButton: function onRightButton() {
| for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
| args[_key3] = arguments[_key3];
| }
|
| this.onDefaultTap.apply(this, ['onTapRight'].concat(args));
| }
| }
| });
|
|