Commit 2f401be1 authored by wildfirecode's avatar wildfirecode

1

parent 0352d7fa
...@@ -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)
......
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