Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobaominiDemo
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
taobaominiDemo
Commits
2f401be1
Commit
2f401be1
authored
Jun 23, 2020
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
0352d7fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
69 deletions
+75
-69
index.js
client/pages/index/index.js
+75
-69
No files found.
client/pages/index/index.js
View file @
2f401be1
...
@@ -162,81 +162,87 @@ Page({
...
@@ -162,81 +162,87 @@ Page({
},
},
//和main通信的方法,接收main的信息
//和main通信的方法,接收main的信息
onMessage
(
e
)
{
onMessage
(
e
)
{
console
.
log
(
e
)
try
{
//接口名字
//接口名字
let
netName
=
e
.
data
.
netName
;
let
netName
=
e
.
data
.
netName
;
//接口参数
//接口参数
let
parameter
=
e
.
data
.
parameter
;
let
parameter
=
e
.
data
.
parameter
;
//暂时发现3个需要用户操作的接口
//暂时发现3个需要用户操作的接口
//定制的授权
//定制的授权
if
(
netName
==
"mine.authorize"
)
{
if
(
netName
==
"mine.authorize"
)
{
this
.
getAuth
()
this
.
getAuth
()
}
}
//获取地址
//获取地址
else
if
(
netName
==
"mine.getUserAddress"
)
{
else
if
(
netName
==
"mine.getUserAddress"
)
{
this
.
getUserAddress
(
parameter
.
prizeId
)
this
.
getUserAddress
(
parameter
.
prizeId
)
}
}
//关注店铺的操作
//关注店铺的操作
else
if
(
netName
==
"mine.favorShop"
)
{
else
if
(
netName
==
"mine.favorShop"
)
{
this
.
doFavorShop
()
this
.
doFavorShop
()
}
}
//前端接口
//前端接口
else
if
(
netName
.
indexOf
(
"mine"
)
==
0
)
{
else
if
(
netName
.
indexOf
(
"mine"
)
==
0
)
{
var
data
=
{
success
:
true
}
var
data
=
{
success
:
true
}
switch
(
netName
)
{
switch
(
netName
)
{
case
"mine.getAppData"
:
//获取信息
case
"mine.getAppData"
:
//获取信息
data
=
{
data
=
{
success
:
true
,
success
:
true
,
data
:
{
data
:
{
activityId
:
app
.
activityId
,
//|| "5e7c40e98564b57d7fb95812",
activityId
:
app
.
activityId
,
//|| "5e7c40e98564b57d7fb95812",
nickName
:
app
.
nickName
,
nickName
:
app
.
nickName
,
avatar
:
app
.
avatar
,
avatar
:
app
.
avatar
,
inviteId
:
app
.
inviteId
,
inviteId
:
app
.
inviteId
,
isFocusShop
:
app
.
isFollow
||
false
,
isFocusShop
:
app
.
isFollow
||
false
,
shareCode
:
this
.
shareCode
,
//判断是否要发助力用
shareCode
:
this
.
shareCode
,
//判断是否要发助力用
}
}
}
}
break
break
case
"mine.navigateToOutside"
:
//跳转小程序外的页面
case
"mine.navigateToOutside"
:
//跳转小程序外的页面
my
.
call
(
"navigateToOutside"
,
{
my
.
call
(
"navigateToOutside"
,
{
url
:
parameter
.
url
url
:
parameter
.
url
},
(
res
)
=>
{
},
(
res
)
=>
{
// my.alert({ content: "success - " + JSON.stringify(res)})
// my.alert({ content: "success - " + JSON.stringify(res)})
})
})
console
.
log
(
parameter
.
url
)
console
.
log
(
parameter
.
url
)
break
break
case
"mine.navigateTo"
:
//跳转小程序内的页面
case
"mine.navigateTo"
:
//跳转小程序内的页面
my
.
navigateTo
({
my
.
navigateTo
({
url
:
parameter
.
url
url
:
parameter
.
url
})
})
break
break
case
"mine.navigateBack"
:
//返回页面
case
"mine.navigateBack"
:
//返回页面
my
.
navigateBack
({
my
.
navigateBack
({
delta
:
parameter
.
delta
||
1
delta
:
parameter
.
delta
||
1
})
break
case
"mine.showSharePanel"
:
//分享
//多一个参数
this
.
shareStatus
=
parameter
.
shareStatus
//1是任务分享,2是复活液分享
my
.
showSharePanel
()
break
}
console
.
log
(
879797897
)
// this.webViewContext.postMessage({ netName: netName, data: data })
this
.
postMessage
(
netName
,
data
)
}
else
{
//获取后端接口
const
{
function
:
fc
}
=
app
.
cloud
fc
.
invoke
(
app
.
cloudName
,
parameter
,
netName
.
split
(
"."
)[
1
])
.
then
(
res
=>
{
// console.log("返回数据" + JSON.stringify(res));
//发送消息
// this.webViewContext.postMessage({ netName: netName, data: res })
this
.
postMessage
(
netName
,
res
)
})
})
break
case
"mine.showSharePanel"
:
//分享
//多一个参数
this
.
shareStatus
=
parameter
.
shareStatus
//1是任务分享,2是复活液分享
my
.
showSharePanel
()
break
}
}
console
.
log
(
879797897
)
// this.webViewContext.postMessage({ netName: netName, data: data })
this
.
postMessage
(
netName
,
data
)
}
else
{
//获取后端接口
const
{
function
:
fc
}
=
app
.
cloud
console
.
log
(
'app.cloudName, parameter, netName.spilt(".")[1]'
,
app
.
cloudName
,
parameter
,
netName
.
spilt
(
"."
)[
1
])
fc
.
invoke
(
app
.
cloudName
,
parameter
,
netName
.
spilt
(
"."
)[
1
])
.
then
(
res
=>
{
}
catch
(
error
)
{
// console.log("返回数据" + JSON.stringify(res));
console
.
log
(
error
)
//发送消息
// this.webViewContext.postMessage({ netName: netName, data: res })
this
.
postMessage
(
netName
,
res
)
})
}
}
},
},
postMessage
(
netName
,
data
)
{
postMessage
(
netName
,
data
)
{
// this.main.dispatchGlobalEvent(netName, data)
// this.main.dispatchGlobalEvent(netName, data)
...
...
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