├── LICENSE
├── README.md
├── screen_shot
└── wege_weapp_1.gif
└── wega_weapp
├── app.js
├── app.json
├── app.wxss
├── pages
├── countdown_demo
│ ├── countdown_demo.js
│ ├── countdown_demo.json
│ ├── countdown_demo.wxml
│ └── countdown_demo.wxss
├── delayButton_demo
│ ├── delayButton_demo.js
│ ├── delayButton_demo.json
│ ├── delayButton_demo.wxml
│ └── delayButton_demo.wxss
├── dialog_demo
│ ├── dialog_demo.js
│ ├── dialog_demo.json
│ ├── dialog_demo.wxml
│ └── dialog_demo.wxss
├── index
│ ├── index.js
│ ├── index.wxml
│ └── index.wxss
└── toast_demo
│ ├── toast_demo.js
│ ├── toast_demo.json
│ ├── toast_demo.wxml
│ └── toast_demo.wxss
└── utils
├── countdown
├── countdown.js
├── countdown.wxml
└── countdown.wxss
├── delayButton
├── delayButton.js
├── delayButton.wxml
└── delayButton.wxss
├── delayButton2
├── delayButton2.js
├── delayButton2.wxml
└── delayButton2.wxss
├── dialog
├── dialog.js
├── dialog.wxml
└── dialog.wxss
├── toast
├── toast.js
├── toast.wxml
└── toast.wxss
└── util.js
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wega_weapp
2 |
3 | toast dailog delayButton
4 |
5 | 
6 |
7 |
8 |
9 | ## 一.toast
10 |
11 | 1.将/utils/toast文件夹copy到根目录下的utils
12 |
13 | 2.copy以下代码 到所需page目录xxx.wxss,或者 多个页面使用,直接导入app.wxss 全局都可使用(建议)
14 |
15 | ```js
16 | /* 导入toast样式 */
17 | @import "utils/toast/toast.wxss";
18 | ```
19 |
20 | 3.copy以下代码到所需page目录xxx.wxml
21 |
22 | ```js
23 |
24 |
25 | ```
26 |
27 | 4.copy以下代码到所需page目录xxx.js
28 |
29 | ```js
30 | /**
31 | * toast提示框
32 | */
33 | var toast = require('../../utils/toast/toast.js');
34 | ```
35 |
36 | 5.使用
37 |
38 | ```js
39 | //全屏可点击 默认1500ms 类似android toast
40 | toast.showToastDefault(page, toastText)
41 | //全屏不可点击 默认 2000ms
42 | toast.showToastWithMask(page, toastText)
43 | //可定制
44 | toast.showToast(page, toastText, count, isShowMask)
45 | //参数
46 | page:页面
47 | toastText:提示文字
48 | count:显示时间
49 | isShowMask:是否显示蒙层
50 | ```
51 |
52 | 6.参考
53 |
54 | 更多细节参考wega_weapp/pages/toast_demo/
55 |
56 | ## 二.dialog
57 |
58 | 1.将/utils/dialog文件夹copy到根目录下的utils
59 |
60 | 2.copy以下代码 到所需page目录xxx.wxss,或者 多个页面使用,直接导入app.wxss 全局都可使用(建议)
61 |
62 | ```js
63 | /* 导入dialog样式 */
64 | @import "utils/dialog/dialog.wxss";
65 | ```
66 |
67 | 3.copy以下代码到所需page目录xxx.wxml
68 |
69 | ```js
70 |
71 |
72 | ```
73 |
74 | 4.copy以下代码到所需page目录xxx.js
75 |
76 | ```js
77 | /**
78 | * dialog对话框
79 | */
80 | var dialog = require('../../utils/dialog/dialog.js');
81 | ```
82 |
83 | 5.使用
84 |
85 | ```js
86 | dialog.dialog({
87 | page: this,
88 | currentStatu: "open",
89 | message:"是否拨打客服电话",
90 | confirmText: '拨打',
91 | confirmColor: "#00a7e5",
92 | confirm: function () {
93 | console.log("confirm");
94 | }
95 | })
96 | //参数
97 | page:页面 (必需)
98 | currentStatu:状态 'open' 'close' 'confirm'
99 | message:提示文字
100 | confirmText:确定键文字
101 | confirmColor:确定键文字颜色 如"#ff00ff" rgb(0,0,0)
102 | confirm:确定键点击事件
103 | showCancel:是否显示取消键,默认 true
104 | canceledOnTouchOutside:蒙层是否可以取消 默认 true,
105 | ```
106 |
107 | 6.参考
108 |
109 | 更多细节参考wega_weapp/pages/dialog_demo/
110 |
111 |
112 |
113 | to be continue...
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/screen_shot/wege_weapp_1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LinweiJ/wega_weapp/eababa95ead6c201230d34786aed897524fc6506/screen_shot/wege_weapp_1.gif
--------------------------------------------------------------------------------
/wega_weapp/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 |
4 | globalData: {
5 | userInfo: null
6 | }
7 | })
--------------------------------------------------------------------------------
/wega_weapp/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/toast_demo/toast_demo",
5 | "pages/dialog_demo/dialog_demo",
6 | "pages/delayButton_demo/delayButton_demo",
7 | "pages/countdown_demo/countdown_demo"
8 | ],
9 | "window": {
10 | "backgroundTextStyle": "light",
11 | "navigationBarBackgroundColor": "#00a7e5",
12 | "navigationBarTitleText": "wega_weapp",
13 | "navigationBarTextStyle": "white"
14 | }
15 | }
--------------------------------------------------------------------------------
/wega_weapp/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 |
3 | .container {
4 | /* height: 100%;
5 | display: flex;
6 | flex-direction: column;
7 | align-items: center;
8 | justify-content: space-between;
9 |
10 | box-sizing: border-box; */
11 | padding: 20rpx;
12 | }
13 |
14 | .btn {
15 | margin: 20rpx;
16 | /* color: #00a7a5; */
17 | }
18 |
--------------------------------------------------------------------------------
/wega_weapp/pages/countdown_demo/countdown_demo.js:
--------------------------------------------------------------------------------
1 | // pages/countdown/countdown_demo.js
2 |
3 | var countdown = require("../../utils/countdown/countdown.js")
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 |
11 |
12 |
13 | },
14 |
15 | btn:function(e){
16 |
17 | console.log(e);
18 |
19 |
20 | },
21 |
22 | /**
23 | * 生命周期函数--监听页面加载
24 | */
25 | onLoad: function (options) {
26 | countdown.start(this);
27 | },
28 |
29 | /**
30 | * 生命周期函数--监听页面初次渲染完成
31 | */
32 | onReady: function () {
33 |
34 | },
35 |
36 | /**
37 | * 生命周期函数--监听页面显示
38 | */
39 | onShow: function () {
40 |
41 | },
42 |
43 | /**
44 | * 生命周期函数--监听页面隐藏
45 | */
46 | onHide: function () {
47 |
48 | },
49 |
50 | /**
51 | * 生命周期函数--监听页面卸载
52 | */
53 | onUnload: function () {
54 |
55 | },
56 |
57 | /**
58 | * 页面相关事件处理函数--监听用户下拉动作
59 | */
60 | onPullDownRefresh: function () {
61 |
62 | },
63 |
64 | /**
65 | * 页面上拉触底事件的处理函数
66 | */
67 | onReachBottom: function () {
68 |
69 | },
70 |
71 | /**
72 | * 用户点击右上角分享
73 | */
74 | onShareAppMessage: function () {
75 |
76 | }
77 | })
--------------------------------------------------------------------------------
/wega_weapp/pages/countdown_demo/countdown_demo.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/wega_weapp/pages/countdown_demo/countdown_demo.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/wega_weapp/pages/countdown_demo/countdown_demo.wxss:
--------------------------------------------------------------------------------
1 | /* pages/countdown/countdown_demo.wxss */
2 | @import "../../utils/countdown/countdown.wxss";
--------------------------------------------------------------------------------
/wega_weapp/pages/delayButton_demo/delayButton_demo.js:
--------------------------------------------------------------------------------
1 | // pages/delayButton_demo/delayButton_demo.js
2 |
3 | var delayButton=require("../../utils/delayButton/delayButton.js")
4 | var delayButtonTemplate = require("../../utils/delayButton2/delayButton2.js")
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 |
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function (options) {
18 | var that=this;
19 | delayButton.init(this, "点击开始", "点击再次开始", 5000, function(e){
20 | //开始倒计时
21 | delayButton.countdown(that);
22 |
23 | })
24 |
25 | var data = {
26 | name:'delayButtonData',
27 | id:1,
28 | hint_begin:'点击开始',
29 | hint_finish:'再次点击',
30 | delay_time:5000,
31 | delay: function (data){
32 | console.log(data);
33 | delayButtonTemplate.countdown(that, data)
34 | }
35 | }
36 | delayButtonTemplate.init(this, data);
37 |
38 | var data2 = {
39 | name: 'delayButtonData2',
40 | id: 2,
41 | hint_begin: '获取验证码',
42 | hint_finish: '重新获取验证码',
43 | delay_time: 60000,
44 | delay: function (data) {
45 | console.log(data);
46 | delayButtonTemplate.countdown(that, data)
47 | }
48 | }
49 | delayButtonTemplate.init(this, data2);
50 |
51 |
52 | var data3 = {
53 | name: 'delayButtonData3',
54 | id: 3,
55 | hint_begin: '点击提交',
56 | hint_finish: '再次提交',
57 | delay_time: 15000,
58 | delay: function (data) {
59 | console.log(data);
60 | delayButtonTemplate.countdown(that, data)
61 | }
62 | }
63 | delayButtonTemplate.init(this, data3);
64 | },
65 |
66 | /**
67 | * 生命周期函数--监听页面初次渲染完成
68 | */
69 | onReady: function () {
70 |
71 | },
72 |
73 | /**
74 | * 生命周期函数--监听页面显示
75 | */
76 | onShow: function () {
77 |
78 | },
79 |
80 | /**
81 | * 生命周期函数--监听页面隐藏
82 | */
83 | onHide: function () {
84 |
85 | },
86 |
87 | /**
88 | * 生命周期函数--监听页面卸载
89 | */
90 | onUnload: function () {
91 |
92 | },
93 |
94 | /**
95 | * 页面相关事件处理函数--监听用户下拉动作
96 | */
97 | onPullDownRefresh: function () {
98 |
99 | },
100 |
101 | /**
102 | * 页面上拉触底事件的处理函数
103 | */
104 | onReachBottom: function () {
105 |
106 | },
107 |
108 | /**
109 | * 用户点击右上角分享
110 | */
111 | onShareAppMessage: function () {
112 |
113 | }
114 | })
--------------------------------------------------------------------------------
/wega_weapp/pages/delayButton_demo/delayButton_demo.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | "navigationBarTitleText": "delayButton延时按钮"
4 | }
--------------------------------------------------------------------------------
/wega_weapp/pages/delayButton_demo/delayButton_demo.wxml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/wega_weapp/pages/delayButton_demo/delayButton_demo.wxss:
--------------------------------------------------------------------------------
1 | /* pages/delayButton_demo/delayButton_demo.wxss */
2 | @import "../../utils/delayButton/delayButton.wxss";
3 | @import "../../utils/delayButton2/delayButton2.wxss";
4 | .delayButton_out{
5 |
6 | margin: 20rpx;
7 | }
8 |
9 | .delayButton_out_2{
10 |
11 | margin: 20rpx 120rpx;
12 | }
--------------------------------------------------------------------------------
/wega_weapp/pages/dialog_demo/dialog_demo.js:
--------------------------------------------------------------------------------
1 | // pages/dialog_demo/dialog_demo.js
2 |
3 | /**
4 | * dialog对话框
5 | */
6 | var dialog = require('../../utils/dialog/dialog.js');
7 |
8 | Page({
9 |
10 | /**
11 | * 页面的初始数据
12 | */
13 | data: {
14 |
15 | },
16 |
17 | dialog1:function(e){
18 |
19 | dialog.dialog({
20 | page:this,
21 | currentStatu:"open",
22 | message:"默认dialog",
23 | confirm:function(){
24 | console.log("confirm");
25 | },
26 | });
27 |
28 | },
29 |
30 |
31 | dialog2:function(e){
32 |
33 | dialog.dialog({
34 | page:this,
35 | showCancel: false,
36 | currentStatu:"open",
37 | canceledOnTouchOutside: false,
38 | message:"单键dialog",
39 | confirm:function(){
40 | console.log("confirm");
41 | },
42 |
43 | });
44 |
45 | },
46 |
47 | dialog3: function (e) {
48 |
49 | dialog.dialog({
50 | page: this,
51 | currentStatu: "open",
52 | confirmColor:"#00a7e5",
53 | message: "蓝色dialog\n蓝色dialog",
54 | confirm: function () {
55 | console.log("confirm");
56 | },
57 | });
58 |
59 | },
60 | /**
61 | * 生命周期函数--监听页面加载
62 | */
63 | onLoad: function (options) {
64 |
65 | },
66 |
67 | /**
68 | * 生命周期函数--监听页面初次渲染完成
69 | */
70 | onReady: function () {
71 |
72 | },
73 |
74 | /**
75 | * 生命周期函数--监听页面显示
76 | */
77 | onShow: function () {
78 |
79 | },
80 |
81 | /**
82 | * 生命周期函数--监听页面隐藏
83 | */
84 | onHide: function () {
85 |
86 | },
87 |
88 | /**
89 | * 生命周期函数--监听页面卸载
90 | */
91 | onUnload: function () {
92 |
93 | },
94 |
95 | /**
96 | * 页面相关事件处理函数--监听用户下拉动作
97 | */
98 | onPullDownRefresh: function () {
99 |
100 | },
101 |
102 | /**
103 | * 页面上拉触底事件的处理函数
104 | */
105 | onReachBottom: function () {
106 |
107 | },
108 |
109 | /**
110 | * 用户点击右上角分享
111 | */
112 | onShareAppMessage: function () {
113 |
114 | }
115 | })
--------------------------------------------------------------------------------
/wega_weapp/pages/dialog_demo/dialog_demo.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | "navigationBarTitleText":"dialog对话框"
4 |
5 | }
--------------------------------------------------------------------------------
/wega_weapp/pages/dialog_demo/dialog_demo.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/wega_weapp/pages/dialog_demo/dialog_demo.wxss:
--------------------------------------------------------------------------------
1 | /* pages/dialog_demo/dialog_demo.wxss */
2 | /* 导入toast样式 */
3 | @import "../../utils/dialog/dialog.wxss";
--------------------------------------------------------------------------------
/wega_weapp/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | const app = getApp()
4 |
5 | Page({
6 | data: {
7 |
8 | },
9 |
10 | //事件处理函数
11 | toast: function () {
12 | wx.navigateTo({
13 | url: '../toast_demo/toast_demo',
14 | })
15 | },
16 | dialog: function () {
17 | wx.navigateTo({
18 | url: '../dialog_demo/dialog_demo',
19 | })
20 | },
21 | delayButton: function () {
22 | wx.navigateTo({
23 | url: '../delayButton_demo/delayButton_demo',
24 | })
25 | }
26 | })
27 |
--------------------------------------------------------------------------------
/wega_weapp/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/wega_weapp/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 |
--------------------------------------------------------------------------------
/wega_weapp/pages/toast_demo/toast_demo.js:
--------------------------------------------------------------------------------
1 | // pages/toast/toast.js
2 | /**
3 | * toast提示框
4 | */
5 | var toast = require('../../utils/toast/toast.js');
6 | Page({
7 |
8 | /**
9 | * 页面的初始数据
10 | */
11 | data: {
12 |
13 | },
14 |
15 |
16 | showToast1:function(e){
17 | toast.showToastDefault(this, "默认");
18 | },
19 | showToast2: function (e) {
20 | toast.showToastWithMask(this, "带蒙层");
21 | },
22 | showToast3: function (e) {
23 | toast.showToast(this, "5s无蒙层",5000,false);
24 | },
25 | showToast4: function (e) {
26 | toast.showToast(this, "5s有蒙层",5000,true);
27 | },
28 | /**
29 | * 生命周期函数--监听页面加载
30 | */
31 | onLoad: function (options) {
32 |
33 | },
34 |
35 | /**
36 | * 生命周期函数--监听页面初次渲染完成
37 | */
38 | onReady: function () {
39 |
40 | },
41 |
42 | /**
43 | * 生命周期函数--监听页面显示
44 | */
45 | onShow: function () {
46 |
47 | },
48 |
49 | /**
50 | * 生命周期函数--监听页面隐藏
51 | */
52 | onHide: function () {
53 |
54 | },
55 |
56 | /**
57 | * 生命周期函数--监听页面卸载
58 | */
59 | onUnload: function () {
60 |
61 | },
62 |
63 | /**
64 | * 页面相关事件处理函数--监听用户下拉动作
65 | */
66 | onPullDownRefresh: function () {
67 |
68 | },
69 |
70 | /**
71 | * 页面上拉触底事件的处理函数
72 | */
73 | onReachBottom: function () {
74 |
75 | },
76 |
77 | /**
78 | * 用户点击右上角分享
79 | */
80 | onShareAppMessage: function () {
81 |
82 | }
83 | })
--------------------------------------------------------------------------------
/wega_weapp/pages/toast_demo/toast_demo.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | "navigationBarTitleText":"toast提示框"
4 | }
--------------------------------------------------------------------------------
/wega_weapp/pages/toast_demo/toast_demo.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/wega_weapp/pages/toast_demo/toast_demo.wxss:
--------------------------------------------------------------------------------
1 | /* pages/toast/toast.wxss */
2 |
3 | /* 导入toast样式 */
4 | @import "../../utils/toast/toast.wxss";
--------------------------------------------------------------------------------
/wega_weapp/utils/countdown/countdown.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /* 初始化 */
6 | function start(page) {
7 |
8 | var data = {
9 | interval: 1000,
10 | now_micro_second: 2*60*60*1000,
11 | format: 'H:m:s',
12 | clock: "wode"
13 | };
14 | console.log(data);
15 | page.setData({
16 | countdownData: data
17 | });
18 | console.log(page.data.countdownData);
19 | countdown(page, data)
20 | }
21 |
22 | /* 秒级倒计时 */
23 | function countdown(page, data) {
24 |
25 | if (data.now_micro_second <= 0) {
26 |
27 | data.clock = dateformat(data.now_micro_second);
28 | data.isClocking = false;
29 | // 复原时间
30 | page.setData({
31 | countdownData: data
32 | });
33 | // timeout则跳出递归
34 | return;
35 | } else {
36 | // 渲染倒计时时钟
37 | data.clock = dateformat(data.now_micro_second, data.format);
38 | data.isClocking = true;
39 | page.setData({
40 | countdownData: data
41 | });
42 | }
43 |
44 | setTimeout(function () {
45 | // 放在最后--
46 | data.now_micro_second -= data.interval;
47 | countdown(page, data);
48 | }, data.interval)
49 | }
50 |
51 | // 时间格式化输出,如60。每1000ms都会调用一次
52 | function dateformat(micro_second, str_format) {
53 | // 秒数
54 | var second = Math.floor(micro_second / 1000);
55 | // 毫秒位,保留2位
56 | var micro_sec = Math.floor((micro_second % 1000) / 10);
57 |
58 |
59 | var result;
60 | switch (str_format) {
61 | case 'H:m:s ms':
62 | // 小时位
63 | var hr = Math.floor(second / 3600);
64 | // 分钟位
65 | var min = Math.floor((second - hr * 3600) / 60);
66 | // 秒位
67 | var sec = (second - hr * 3600 - min * 60);// equal to => var sec = second % 60;
68 | result = hr + ':'+ min + ':' + sec + " " + micro_sec;
69 | break;
70 | case 'H:m:s':
71 | // 小时位
72 | var hr = Math.floor(second / 3600);
73 | // 分钟位
74 | var min = Math.floor((second - hr * 3600) / 60);
75 | // 秒位
76 | var sec = (second - hr * 3600 - min * 60);// equal to => var sec = second % 60;
77 | result = hr + ':' + min + ':' + sec ;
78 | break;
79 | case 'm:s ms':
80 | // 分钟位
81 | var min = Math.floor(second / 60);
82 | // 秒位
83 | var sec = (second - min * 60);// equal to => var sec = second % 60;
84 |
85 | result = min + ':' + sec + " " + micro_sec;
86 | break;
87 | case 'm:s':
88 | // 分钟位
89 | var min = Math.floor(second / 60);
90 | // 秒位
91 | var sec = (second - min * 60);// equal to => var sec = second % 60;
92 |
93 | result = min + ':' + sec;
94 | break;
95 | case 's ms':
96 | result = second + " " + micro_sec;
97 | break;
98 | case 's':
99 | result = second;
100 | break;
101 | }
102 |
103 | return result;
104 | }
105 |
106 |
107 |
108 |
109 | module.exports = {
110 |
111 | countdown: countdown,
112 | start: start
113 | }
--------------------------------------------------------------------------------
/wega_weapp/utils/countdown/countdown.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{clock}}dd
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/wega_weapp/utils/countdown/countdown.wxss:
--------------------------------------------------------------------------------
1 | /* utils/countdown/countdown.wxss */
2 |
3 | /* 验证码 */
4 |
5 | .countdown {
6 | font-size: 28rpx;
7 | color: #00a7e5;
8 | background-color: transparent;
9 |
10 | border: none;
11 | padding-right: 0rpx;
12 | padding-left: 0rpx;
13 |
14 | }
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton/delayButton.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | // 传入一个时间点,转换成总毫秒数
4 | var total_micro_second;
5 |
6 | var text_finish;
7 |
8 | var delay_micro_second;
9 |
10 | /* 初始化 */
11 | function init(page, hint_begin, hint_finish, delay_time, delay) {
12 |
13 | text_finish = hint_finish;
14 | total_micro_second = parseInt(delay_time);
15 | delay_micro_second = parseInt(delay_time);
16 | page.setData({
17 | clock: hint_begin,
18 | isClocking: false
19 | });
20 | page.delaybutton = function (e) {
21 |
22 | if (page.data.isClocking) {
23 | //正在倒计时
24 | return;
25 | }
26 | delay();
27 | }
28 |
29 | }
30 |
31 | /**
32 | * 秒级倒计时
33 | *
34 | */
35 | function countdown(page) {
36 |
37 | if (total_micro_second <= 0) {
38 | // 复原时间
39 | total_micro_second = delay_micro_second;
40 | page.setData({
41 | clock: text_finish,
42 | isClocking: false
43 | });
44 | // timeout则跳出递归
45 | return;
46 | } else {
47 | // 渲染倒计时时钟
48 | page.setData({
49 | clock: dateformat(total_micro_second),
50 | isClocking: true
51 | });
52 | }
53 |
54 | setTimeout(function () {
55 | // 放在最后--
56 | total_micro_second -= 1000;
57 | countdown(page);
58 | }, 1000)
59 | }
60 |
61 | // 时间格式化输出,如60。每1000ms都会调用一次
62 | function dateformat(micro_second) {
63 | // 秒数
64 | var second = Math.floor(micro_second / 1000);
65 | return second + "秒后可点击";
66 | }
67 |
68 | module.exports = {
69 | countdown: countdown,
70 | init: init
71 | }
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton/delayButton.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton/delayButton.wxss:
--------------------------------------------------------------------------------
1 | /* utils/delayButton/delayButton.wxss */
2 |
3 | /* delaybutton */
4 |
5 | .delaybutton[type="default"] {
6 | font-size: 28rpx;
7 | color: #00a7e5;
8 | background-color: transparent;
9 | padding-right: 0rpx;
10 | padding-left: 0rpx;
11 | }
12 |
13 | .delaybutton::after {
14 | border: 2px solid #00a7e5;
15 | }
16 |
17 | .delaybutton[disabled][type="default"] {
18 | color: #00a7e5;
19 | background-color: transparent;
20 | }
21 |
22 | .hover_delaybutton {
23 | opacity: 0.6;
24 | }
25 |
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton2/delayButton2.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | // 传入一个时间点,转换成总毫秒数
4 | // var total_micro_second;
5 |
6 | // var text_finish;
7 |
8 | // var delay_micro_second;
9 |
10 | //多个点击数据组
11 | var dataArr = [];
12 |
13 |
14 | /* 初始化 */
15 | function init(page, data) {
16 |
17 | data.clock = data.hint_begin;
18 | data.isClocking = false;
19 | data.now_micro_second = data.delay_time;
20 | dataArr.push(data);
21 |
22 | page.setData({
23 | [data.name]: data
24 | });
25 | page.delaybutton2 = function (e) {
26 |
27 | var dataName = e.currentTarget.dataset.name;
28 | if (page.data[dataName].isClocking) {
29 | //正在倒计时
30 | return;
31 | }
32 | page.data[dataName].delay(page.data[dataName]);
33 | }
34 |
35 | }
36 |
37 | /**
38 | * 秒级倒计时
39 | *
40 | */
41 | function countdown(page, data) {
42 |
43 | if (data.now_micro_second <= 0) {
44 | // 复原时间
45 | data.now_micro_second = data.delay_time;
46 | data.isClocking = false;
47 | data.clock = data.hint_finish;
48 | page.setData({
49 | [data.name]: data,
50 | });
51 | // timeout则跳出递归
52 | return;
53 | } else {
54 | // 渲染倒计时时钟
55 | data.clock = dateformat(data.now_micro_second),
56 | data.isClocking = true,
57 | page.setData({
58 | [data.name]: data,
59 | });
60 | }
61 |
62 | setTimeout(function () {
63 | // 放在最后--
64 | data.now_micro_second -= 1000;
65 | countdown(page, data);
66 | }, 1000)
67 | }
68 |
69 | // 时间格式化输出,如60。每1000ms都会调用一次
70 | function dateformat(micro_second) {
71 | // 秒数
72 | var second = Math.floor(micro_second / 1000);
73 | return second + "秒后可点击";
74 | }
75 |
76 | module.exports = {
77 | countdown: countdown,
78 | init: init
79 | }
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton2/delayButton2.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/wega_weapp/utils/delayButton2/delayButton2.wxss:
--------------------------------------------------------------------------------
1 | /* utils/delayButton/delayButton.wxss */
2 |
3 | /* delaybutton */
4 |
5 | .delaybutton2[type="default"] {
6 | font-size: 28rpx;
7 | color: #00a7a5;
8 | background-color: transparent;
9 | padding-right: 0rpx;
10 | padding-left: 0rpx;
11 | }
12 |
13 | .delaybutton2::after {
14 | border: 2px solid #00a7a5;
15 | }
16 |
17 | .delaybutton2[disabled][type="default"] {
18 | color: #00a7a5;
19 | background-color: transparent;
20 | }
21 |
22 | .hover_delaybutton {
23 | opacity: 0.6;
24 | }
25 |
--------------------------------------------------------------------------------
/wega_weapp/utils/dialog/dialog.js:
--------------------------------------------------------------------------------
1 | // dialog.js
2 |
3 | /**
4 | * 显示 打开dialog 默认隐藏标题 内容 取消 确定按钮 蒙层点击取消
5 | */
6 | function dialog(data) {
7 | var that=this;
8 | var page = data.page;
9 | var currentStatu = data.currentStatu;
10 | var message = data.message;
11 | var cancelText = "取消";
12 | var confirmText ="确定";
13 | var confirm = data.confirm;
14 | var confirmColor ='rgb(75,75,75)';
15 |
16 | if (data.confirmColor)
17 | {
18 | var confirmColor = data.confirmColor;
19 | }
20 | if (data.confirmText) {
21 | confirmText = data.confirmText;
22 | }
23 | var showCancel=true;
24 | if (data.showCancel==false) {
25 | showCancel = data.showCancel;
26 | }
27 | var hiddenTitle = true;
28 | if (data.hiddenTitle == false) {
29 | hiddenTitle = data.hiddenTitle;
30 | }
31 | var canceledOnTouchOutside = true;
32 | if (data.canceledOnTouchOutside == false) {
33 | console.log("canceledOnTouchOutside");
34 | canceledOnTouchOutside = data.canceledOnTouchOutside;
35 | }else{
36 | console.log("canceledOnTouchOutside" + true);
37 | data.canceledOnTouchOutside == true;
38 | }
39 | // 点击事件
40 | page.powerDrawer = function (e) {
41 | var currentStatu = e.currentTarget.dataset.statu;
42 | data.currentStatu = currentStatu;
43 | that.openOrCloseDialog(data);
44 | }
45 |
46 | /* 动画部分 */
47 | // 第1步:创建动画实例 隐藏
48 | var animation = wx.createAnimation({
49 | duration: 200, //动画时长
50 | timingFunction: "ease", //线性
51 | delay: 0 //0则不延迟
52 | });
53 | // 蒙层动画
54 | var animation0 = wx.createAnimation({
55 | duration: 200, //动画时长
56 | timingFunction: "ease", //线性
57 | delay: 0 //0则不延迟
58 | });
59 |
60 | // 第2步:这个动画实例赋给当前的动画实例
61 | page.animation = animation;
62 | page.animation0 = animation0;
63 |
64 | // 第3步:执行第一组动画
65 | page.animation.opacity(0).scaleX(0).step();
66 | page.animation0.opacity(0).step();
67 |
68 | // 第4步:导出动画对象赋给数据对象储存
69 | page.setData({
70 | animationData: page.animation.export(),
71 | animationData0: page.animation0.export(),
72 | message: message,
73 | cancelText: cancelText,
74 | confirmText: confirmText,
75 | confirmColor: confirmColor,
76 | showCancel: showCancel,
77 | hiddenTitle: hiddenTitle,
78 | canceledOnTouchOutside: canceledOnTouchOutside,
79 | })
80 |
81 | // 第5步:设置定时器到指定时候后,执行第二组动画
82 | setTimeout(function () {
83 | // 显示
84 | if (currentStatu == "open") {
85 | page.setData(
86 | {
87 | showModalStatus: true
88 | }
89 | );
90 | }
91 | // 执行第二组动画 显示
92 | page.animation.opacity(1).scaleX(1).step();
93 | page.animation0.opacity(0.5).step();
94 | // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
95 | page.setData({
96 | animationData: page.animation,
97 | animationData0: page.animation0,
98 | })
99 | }.bind(page), 200)
100 | }
101 |
102 | /**
103 | * 打开或关闭
104 | */
105 | function openOrCloseDialog(data) {
106 |
107 |
108 | var page = data.page;
109 | var confirm = data.confirm;
110 | var currentStatu = data.currentStatu;
111 | console.log(data);
112 | //蒙层
113 | if (!page.data.canceledOnTouchOutside&¤tStatu == "out") {
114 | console.log("canceledOnTouchOutside" + "out");
115 | return;
116 | }
117 |
118 | /* 动画部分 */
119 | // 第1步:创建动画实例 隐藏
120 | var animation = wx.createAnimation({
121 | duration: 200, //动画时长
122 | timingFunction: "ease", //线性
123 | delay: 0 //0则不延迟
124 | });
125 |
126 | var animation0 = wx.createAnimation({
127 | duration: 200, //动画时长
128 | timingFunction: "ease", //线性
129 | delay: 0 //0则不延迟
130 | });
131 |
132 | var that = this;
133 |
134 | // 第2步:这个动画实例赋给当前的动画实例
135 | page.animation = animation;
136 | page.animation0 = animation0;
137 |
138 | // 第3步:执行第一组动画
139 | page.animation.opacity(0).scaleX(0).step();
140 | page.animation0.opacity(0).step();
141 |
142 | // 第4步:导出动画对象赋给数据对象储存
143 | page.setData({
144 | animationData: page.animation.export(),
145 | animationData0: page.animation0.export(),
146 | })
147 |
148 | // 第5步:设置定时器到指定时候后,执行第二组动画
149 | setTimeout(function () {
150 | //关闭
151 | if (currentStatu == "close") {
152 | page.setData(
153 | {
154 | showModalStatus: false
155 | }
156 | );
157 | return;
158 | }
159 | //确定
160 | if (currentStatu == "confirm") {
161 |
162 | page.setData(
163 | {
164 | showModalStatus: false
165 | }
166 | );
167 | if (confirm)
168 | {
169 | confirm();
170 | }
171 |
172 | return;
173 | }
174 | //蒙层
175 | if (currentStatu == "out") {
176 |
177 | page.setData(
178 | {
179 | showModalStatus: false
180 | }
181 | );
182 | return;
183 | }
184 | // 显示
185 | if (currentStatu == "open") {
186 | page.setData(
187 | {
188 | showModalStatus: true
189 | }
190 | );
191 | }
192 | // 执行第二组动画 显示
193 | page.animation.opacity(1).scaleX(1).step();
194 | page.animation0.opacity(0.5).step();
195 | // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
196 | page.setData({
197 | animationData: page.animation,
198 | animationData0: page.animation0,
199 | })
200 | }.bind(page), 200)
201 | }
202 |
203 | module.exports = {
204 | dialog: dialog,
205 | // initDialog: initDialog,
206 | openOrCloseDialog: openOrCloseDialog,
207 | }
--------------------------------------------------------------------------------
/wega_weapp/utils/dialog/dialog.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | 弹窗标题
12 |
13 | {{message}}
14 |
15 |
16 | {{cancelText}}
17 | {{confirmText}}
18 |
19 |
20 |
--------------------------------------------------------------------------------
/wega_weapp/utils/dialog/dialog.wxss:
--------------------------------------------------------------------------------
1 | /* dialog.wxss */
2 |
3 | /*mask*/
4 |
5 | .drawer_screen {
6 | width: 100%;
7 | height: 100%;
8 | position: fixed;
9 | top: 0;
10 | left: 0;
11 | z-index: 1000;
12 | background: #000;
13 | opacity: 0.5;
14 | overflow: hidden;
15 | display: flex;
16 | justify-content: center;
17 | align-items: center;
18 | }
19 |
20 | /*content*/
21 |
22 | .drawer_box {
23 | width: 600rpx;
24 | overflow: hidden;
25 | position: fixed;
26 | top: 35%;
27 | left: 0;
28 | z-index: 1001;
29 | background: #fafafa;
30 | margin: 0 75rpx;
31 | background: #fafafa;
32 | border-radius: 16rpx;
33 | }
34 |
35 | /* 标题 */
36 |
37 | /* .drawer_title{
38 | padding:15px;
39 | text-align: center;
40 | } */
41 |
42 | /* 内容 */
43 |
44 | .drawer_content {
45 | height: 148rpx;
46 | font-size: 14px;
47 | text-align: center;
48 | display: flex;
49 | justify-content: center;
50 | align-items: center;
51 | }
52 |
53 | /* 按钮 */
54 |
55 | .drawer_btnView {
56 | height: 88rpx;
57 | display: flex;
58 | border-top: 1px solid rgb(200, 200, 200);
59 | }
60 |
61 | /* 取消按钮 */
62 |
63 | .drawer_btn_cancel {
64 | font-size: 28rpx;
65 | text-align: center;
66 | border-right: 1px solid rgb(200, 200, 200);
67 | color: rgb(75, 75, 75);
68 | flex: 1;
69 | display: flex;
70 | justify-content: center;
71 | align-items: center;
72 | }
73 |
74 | /* 确定按钮 */
75 |
76 | .drawer_btn_ok {
77 | font-size: 28rpx;
78 | text-align: center;
79 | color: rgb(75, 75, 75);
80 | flex: 1;
81 | display: flex;
82 | justify-content: center;
83 | align-items: center;
84 | }
85 |
86 | /* 按钮 点击效果 */
87 |
88 | .drawer_hover_btn {
89 | background-color: rgb(240, 240, 240);
90 | }
91 |
--------------------------------------------------------------------------------
/wega_weapp/utils/toast/toast.js:
--------------------------------------------------------------------------------
1 | // toast.js
2 |
3 | /**
4 | * 显示toast 默认3000ms
5 | */
6 | function showToast(page, toastText, count, isShowMask) {
7 |
8 | // toast时间
9 | count = parseInt(count) ? parseInt(count) : 3000;
10 |
11 | page.setData({
12 | //设置toast时间,toast内容
13 | count: count,
14 | toastText: toastText,
15 | // 显示toast
16 | isShowToast: true,
17 | isShowMask: isShowMask,
18 | });
19 |
20 | // 定时器关闭
21 | setTimeout(function () {
22 | page.setData({
23 | isShowToast: false,
24 | isShowMask: false
25 | });
26 | }, count);
27 | }
28 |
29 | /**
30 | * 显示toast 默认1500ms
31 | */
32 | function showToastDefault(page, toastText) {
33 | this.showToast(page, toastText, 1500, false);
34 | }
35 |
36 | /**
37 | * 全屏不可点击 显示toast 默认2000ms
38 | */
39 | function showToastWithMask(page, toastText) {
40 | this.showToast(page, toastText, 2000, true);
41 | }
42 |
43 | module.exports = {
44 | showToast: showToast,
45 | showToastDefault: showToastDefault,
46 | showToastWithMask: showToastWithMask
47 | }
48 |
--------------------------------------------------------------------------------
/wega_weapp/utils/toast/toast.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {{toastText}}
10 |
11 |
12 |
--------------------------------------------------------------------------------
/wega_weapp/utils/toast/toast.wxss:
--------------------------------------------------------------------------------
1 | /* toast.wxss */
2 |
3 | /* mask 背景 */
4 |
5 | .toast_mask {
6 | /* opacity: 0.5; */
7 | width: 100%;
8 | height: 100%;
9 | top: 0;
10 | left: 0;
11 | overflow: hidden;
12 | position: fixed;
13 | z-index: 888;
14 | background: rgba(0, 0, 0, 0.2);
15 | }
16 |
17 | /*toast 盒子*/
18 |
19 | .toast_content_box {
20 | display: flex;
21 | width: 100%;
22 | bottom: 0;
23 | left: 0;
24 | align-items: center;
25 | position: fixed;
26 | flex-direction: column;
27 | justify-content: center;
28 | z-index: 999;
29 | margin-bottom: 300rpx;
30 | }
31 |
32 | /*toast 内容*/
33 |
34 | .toast_content {
35 | padding: 12rpx 30rpx;
36 | background: rgba(0, 0, 0, 0.7);
37 | border-radius: 6rpx;
38 | margin-left: 15rpx;
39 | margin-right: 15rpx;
40 | }
41 |
42 | /*toast 内容文字*/
43 |
44 | .toast_content_text {
45 | height: 100%;
46 | width: 100%;
47 | color: #fff;
48 | font-size: 12px;
49 | text-align: center;
50 | }
51 |
--------------------------------------------------------------------------------
/wega_weapp/utils/util.js:
--------------------------------------------------------------------------------
1 | const formatTime = date => {
2 | const year = date.getFullYear()
3 | const month = date.getMonth() + 1
4 | const day = date.getDate()
5 | const hour = date.getHours()
6 | const minute = date.getMinutes()
7 | const second = date.getSeconds()
8 |
9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
10 | }
11 |
12 | const formatNumber = n => {
13 | n = n.toString()
14 | return n[1] ? n : '0' + n
15 | }
16 |
17 | module.exports = {
18 | formatTime: formatTime
19 | }
20 |
--------------------------------------------------------------------------------