Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-back
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
doublescreen-back
Commits
bbc82c5e
Commit
bbc82c5e
authored
Feb 27, 2020
by
pengguangpu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加全局吐司并自测;
parent
cab5fb70
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
10 deletions
+71
-10
index.acss
pages/index/index.acss
+32
-0
index.axml
pages/index/index.axml
+6
-0
index.js
pages/index/index.js
+33
-10
No files found.
pages/index/index.acss
View file @
bbc82c5e
...
@@ -1262,4 +1262,36 @@
...
@@ -1262,4 +1262,36 @@
color: rgba(91, 105, 129, 1);
color: rgba(91, 105, 129, 1);
line-height: 21rpx;
line-height: 21rpx;
margin-right: 6rpx;
margin-right: 6rpx;
}
/* 吐司样式 */
.toastLayout {
text-align: center;
width: 100%;
height: 100%;
position: absolute;
top: 0rpx;
/* border: 2px solid red; */
align-items: center;
align-content: center;
box-sizing: border-box;
white-space: nowrap;
display: flex;
}
.toast {
box-sizing: border-box;
/* border: 2px solid red; */
float: left;
padding-left: 30rpx;
padding-right: 30rpx;
padding-top: 14rpx;
padding-bottom: 14rpx;
background: rgba(0, 0, 0, 0.85);
border-radius: 5rpx;
margin: 0 auto;
font-size: 19rpx;
color: white;
}
}
\ No newline at end of file
pages/index/index.axml
View file @
bbc82c5e
...
@@ -489,4 +489,10 @@
...
@@ -489,4 +489,10 @@
</view>
</view>
</view>
</view>
</view>
</view>
<!--全局吐司-->
<view class="toastLayout" hidden="{{!isShowToast}}">
<view class="toast">
<text>{{toastText}}</text>
</view>
</view>
</view>
</view>
\ No newline at end of file
pages/index/index.js
View file @
bbc82c5e
...
@@ -16,6 +16,9 @@ import { FLOW_IDLE, FLOW_COLLECTIONS, FLOW_REFUND, FLOW_DIRECT_PAYMENT, FLOW_VER
...
@@ -16,6 +16,9 @@ import { FLOW_IDLE, FLOW_COLLECTIONS, FLOW_REFUND, FLOW_DIRECT_PAYMENT, FLOW_VER
Page
({
Page
({
data
:
{
data
:
{
//页面控制相关参数
//页面控制相关参数
//吐司显示
isShowToast
:
false
,
toastText
:
"------"
,
pageShow
:
{
pageShow
:
{
"home"
:
true
,
"home"
:
true
,
"landscan"
:
false
,
"landscan"
:
false
,
...
@@ -108,6 +111,30 @@ Page({
...
@@ -108,6 +111,30 @@ Page({
],
],
},
},
/**
* 显示吐司方法
* @param text 吐司内容
* @param timeoutMs 倒计时,单位ms
*/
showToast
(
text
,
timeoutMs
)
{
if
(
timeoutMs
==
null
||
timeoutMs
==
0
)
{
timeoutMs
=
1500
;
}
let
context
=
this
;
context
.
setData
({
isShowToast
:
true
,
toastText
:
text
});
setTimeout
(
function
()
{
context
.
setData
({
isShowToast
:
false
});
},
timeoutMs
);
},
/**跳转页面方法 */
/**跳转页面方法 */
goPage
(
pageName
)
{
goPage
(
pageName
)
{
var
pageShowTemp
=
{
...
this
.
data
.
pageShow
};
var
pageShowTemp
=
{
...
this
.
data
.
pageShow
};
...
@@ -296,7 +323,7 @@ Page({
...
@@ -296,7 +323,7 @@ Page({
//拿到当前显示的图片url
//拿到当前显示的图片url
var
curAdUrl
=
res
.
data
;
var
curAdUrl
=
res
.
data
;
//重置广告选中数据
//重置广告选中数据
var
tempPosterList
=
{
...
context
.
data
.
posterList
}
;
var
tempPosterList
=
context
.
data
.
posterList
.
slice
()
;
for
(
var
i
=
0
;
i
<
tempPosterList
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
tempPosterList
.
length
;
i
++
)
{
if
(
tempPosterList
[
i
].
url
==
curAdUrl
)
{
if
(
tempPosterList
[
i
].
url
==
curAdUrl
)
{
tempPosterList
[
i
].
selected
=
true
;
tempPosterList
[
i
].
selected
=
true
;
...
@@ -535,7 +562,7 @@ Page({
...
@@ -535,7 +562,7 @@ Page({
},
},
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
console
.
info
(
`sendBuddyMessage success:
${
JSON
.
stringify
(
res
)}
`
);
my
.
showToast
({
content
:
"正在打印中"
});
},
},
fail
:
(
res
)
=>
{
fail
:
(
res
)
=>
{
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
console
.
info
(
`sendBuddyMessage failed:
${
JSON
.
stringify
(
res
)}
`
);
...
@@ -1181,7 +1208,7 @@ Page({
...
@@ -1181,7 +1208,7 @@ Page({
console
.
log
(
"event==>"
+
JSON
.
stringify
(
event
));
console
.
log
(
"event==>"
+
JSON
.
stringify
(
event
));
//获取点击的index
//获取点击的index
var
index
=
event
.
target
.
dataset
.
index
;
var
index
=
event
.
target
.
dataset
.
index
;
var
tempList
=
{
...
this
.
data
.
posterList
}
;
var
tempList
=
this
.
data
.
posterList
.
slice
()
;
//遍历改变posterList状态
//遍历改变posterList状态
for
(
var
i
=
0
;
i
<
tempList
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
tempList
.
length
;
i
++
)
{
if
(
i
==
index
)
{
if
(
i
==
index
)
{
...
@@ -1201,19 +1228,15 @@ Page({
...
@@ -1201,19 +1228,15 @@ Page({
data
:
selAdUrl
data
:
selAdUrl
},
},
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
my
.
showToast
({
console
.
log
(
"sendBuddyMessage success:"
+
JSON
.
stringify
(
res
));
content
:
"设置成功"
});
context
.
setData
({
context
.
setData
({
posterList
:
tempList
posterList
:
tempList
});
});
con
sole
.
log
(
"sendBuddyMessage success:"
+
JSON
.
stringify
(
res
)
);
con
text
.
showToast
(
"设置成功"
);
},
},
fail
:
(
res
)
=>
{
fail
:
(
res
)
=>
{
my
.
showToast
({
content
:
"设置失败"
});
console
.
log
(
"sendBuddyMessage fail:"
+
JSON
.
stringify
(
res
));
console
.
log
(
"sendBuddyMessage fail:"
+
JSON
.
stringify
(
res
));
context
.
showToast
(
"设置失败"
);
},
},
});
});
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment