Commit 2f401be1 authored by wildfirecode's avatar wildfirecode

1

parent 0352d7fa
......@@ -162,81 +162,87 @@ Page({
},
//和main通信的方法,接收main的信息
onMessage(e) {
console.log(e)
try {
//接口名字
let netName = e.data.netName;
//接口参数
let parameter = e.data.parameter;
//暂时发现3个需要用户操作的接口
//定制的授权
if (netName == "mine.authorize") {
this.getAuth()
}
//获取地址
else if (netName == "mine.getUserAddress") {
this.getUserAddress(parameter.prizeId)
}
//关注店铺的操作
else if (netName == "mine.favorShop") {
this.doFavorShop()
}
//前端接口
else if (netName.indexOf("mine") == 0) {
var data = { success: true }
switch (netName) {
case "mine.getAppData": //获取信息
data = {
success: true,
data: {
activityId: app.activityId, //|| "5e7c40e98564b57d7fb95812",
nickName: app.nickName,
avatar: app.avatar,
inviteId: app.inviteId,
isFocusShop: app.isFollow || false,
shareCode: this.shareCode, //判断是否要发助力用
let netName = e.data.netName;
//接口参数
let parameter = e.data.parameter;
//暂时发现3个需要用户操作的接口
//定制的授权
if (netName == "mine.authorize") {
this.getAuth()
}
//获取地址
else if (netName == "mine.getUserAddress") {
this.getUserAddress(parameter.prizeId)
}
//关注店铺的操作
else if (netName == "mine.favorShop") {
this.doFavorShop()
}
//前端接口
else if (netName.indexOf("mine") == 0) {
var data = { success: true }
switch (netName) {
case "mine.getAppData": //获取信息
data = {
success: true,
data: {
activityId: app.activityId, //|| "5e7c40e98564b57d7fb95812",
nickName: app.nickName,
avatar: app.avatar,
inviteId: app.inviteId,
isFocusShop: app.isFollow || false,
shareCode: this.shareCode, //判断是否要发助力用
}
}
}
break
case "mine.navigateToOutside": //跳转小程序外的页面
my.call("navigateToOutside", {
url: parameter.url
}, (res) => {
// my.alert({ content: "success - " + JSON.stringify(res)})
})
console.log(parameter.url)
break
case "mine.navigateTo": //跳转小程序内的页面
my.navigateTo({
url: parameter.url
})
break
case "mine.navigateBack": //返回页面
my.navigateBack({
delta: parameter.delta || 1
break
case "mine.navigateToOutside": //跳转小程序外的页面
my.call("navigateToOutside", {
url: parameter.url
}, (res) => {
// my.alert({ content: "success - " + JSON.stringify(res)})
})
console.log(parameter.url)
break
case "mine.navigateTo": //跳转小程序内的页面
my.navigateTo({
url: parameter.url
})
break
case "mine.navigateBack": //返回页面
my.navigateBack({
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 => {
// console.log("返回数据" + JSON.stringify(res));
//发送消息
// this.webViewContext.postMessage({ netName: netName, data: res })
this.postMessage(netName, res)
})
} catch (error) {
console.log(error)
}
},
postMessage(netName, data) {
// this.main.dispatchGlobalEvent(netName, data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment