c5e7bb74 by simon

no message

1 parent a3892636
......@@ -28,6 +28,7 @@ App({
tlMemberCode: "",
giftInfo: null, // 来自 gift-shop
addressEditInfo: null, // 编辑时的临时对象
// postMessageData: null,
},
//重写分享方法
share: function () {
......
......@@ -35,6 +35,7 @@ module.exports = {
signInfo: '/sign/info', // post 签到信息 用户注册接口
sign: '/sign', // post 签到动作 用户注册接口
signRecord: '/sign/record', // post 签到记录 用户注册接口
saveOpenid:'/member/save/subscription/openid', //保存 openid
areaQuery: 'https://api.k.wxpai.cn/bizproxy/kdapi/area', // post 区域查询
......
......@@ -25,13 +25,58 @@ Page({
},
onShow() {
this.initData();
},
onLoad(options) {
// app.router.push({
// path: "webview"
// })
},
initData() {
this.queryMember().then((result) => {
this.querySignInfo();
let subscriptionOpenid = result.subscriptionOpenid;
if (subscriptionOpenid) {
// member表 已有openid 继续流程
this.querySignInfo();
} else {
// member表无openid ,重h5授权回来的local拿,成功就继续往下走
this.querySaveOpenid().then((result) => {
this.queryMember().then((result) => {
this.querySignInfo();
})
}).catch((err) => {
// 如果均没有,则去h5授权
app.router.push({
path: "webview"
})
});
}
});
},
/**
* 保存openid
*/
querySaveOpenid() {
return new Promise((resolve, reject) => {
let openid = app.store.getItem("openid");
if (openid) {
app.post({
toast: false,
url: app.api.saveOpenid,
data: {
subscriptionOpenid: openid
}
}).then((result) => {
console.log("result:", result);
app.store.clear("openid");
resolve();
}).catch((err) => {
reject();
});
} else {
reject();
}
});
},
......@@ -157,7 +202,7 @@ Page({
this.setData({
userInfo: result
})
resolve();
resolve(result);
})
});
},
......
......@@ -2,24 +2,48 @@ let app = getApp();
Page({
data: {
isShow: false, // 控制组件显示隐藏
url: ''
url: '',
message: "-",
},
onShareAppMessage(options) {
return {
title: 'title',
path: this.url,
success: function (res) {
// that.web_url = return_url
// 转发成功
wx.showToast({
title: "转发成功",
icon: 'success',
duration: 2000
})
},
fail: function (res) {
// 转发失败
}
}
},
onLoad(options = {}) {
let url = options.url;
url = "https://k.wxpai.cn/IdgW/index.html"
console.log("url:", url);
if (url) {
this.setData({
url: url,
isShow: true
})
} else {
wx.showToast({
title: '未找到页面地址',
title: 'none',
});
// wx.showToast({
// title: '未找到页面地址',
// title: 'none',
// });
}
},
onBindMessage(e) {
console.log("webview message:", e);
let postMessageData = e.detail.data[0]
let openid = postMessageData.openid;
app.store.setItem("openid", openid);
}
})
......
{
"navigationBarTitleText": "webview"
"navigationBarTitleText": "加载中"
}
......
<view class="loading-wrap">
<view class="loading">
<view class="icon"></view>
<view class="text">加载中...</view>
<view class="text">{{message}}</view>
</view>
</view>
<!-- <view class="message">{{message}}</view> -->
<web-view wx:if="{{isShow}}" src="{{url}}" bindload="loadSucc" bindmessage="onBindMessage" />
......
......@@ -19,6 +19,7 @@ const routerPath = {
signInRecord: '/pages/sign-in-record/sign-in-record', // 签到记录
rank: '/pages/rank/rank', // 排行榜
rankGift: '/pages/rank-gift/rank-gift', // 排行榜奖励
webview: '/pages/webview/webview',
example: '/pages/example/example',
more: '/pages/more/more',
}
......