13 changed files with 156 additions and 24 deletions
@ -0,0 +1,129 @@ |
|||
// pages/pbService/web/index.js
|
|||
let app = getApp() |
|||
import commonApi from "../../../utils/https/common" |
|||
import userApi from "../../../utils/https/user" |
|||
import https from "../../../utils/https.js" |
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
webUrl:"", |
|||
shareTitle: "", |
|||
shareUrl: "", |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
let weburl = 'https://test.m.cloud.sz-trip.com/aiPlay' |
|||
let token = wx.getStorageSync('jstrip_token') |
|||
if (token) { |
|||
weburl += '?token='+token |
|||
} |
|||
let _this = this |
|||
try { |
|||
let lonAndLat = (wx.getStorageSync('lonAndLat')) |
|||
if (lonAndLat && JSON.parse(lonAndLat)) { |
|||
lonAndLat = JSON.parse(lonAndLat) |
|||
if (Object.keys(webParam).length>0 || token) { |
|||
weburl+=`&lon=${lonAndLat.lon}&lat=${lonAndLat.lat}` |
|||
} else { |
|||
weburl+=`?lon=${lonAndLat.lon}&lat=${lonAndLat.lat}` |
|||
} |
|||
this.setUrl(weburl) |
|||
return |
|||
} else { |
|||
wx.getLocation({ |
|||
type: 'gcj02', |
|||
success: (res) => { |
|||
let lonAndLat = JSON.stringify({lat: res.latitude,lon: res.longitude}) |
|||
wx.setStorageSync('lonAndLat', lonAndLat) |
|||
if (Object.keys(webParam).length>0 || token) { |
|||
weburl+=`&lon=${lonAndLat.lon}&lat=${lonAndLat.lat}` |
|||
} else { |
|||
weburl+=`?lon=${lonAndLat.lon}&lat=${lonAndLat.lat}` |
|||
} |
|||
_this.setUrl(weburl) |
|||
}, |
|||
fail: (err) => { |
|||
_this.setUrl(weburl) |
|||
} |
|||
}) |
|||
} |
|||
} catch(e) { |
|||
this.setUrl(weburl) |
|||
} |
|||
|
|||
}, |
|||
handleMessage(data) { |
|||
console.log('打印22222',data); |
|||
}, |
|||
|
|||
setUrl (url) { |
|||
this.setData({ |
|||
webUrl:url |
|||
}) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage: function () { |
|||
return { |
|||
title: this.data.shareTitle, |
|||
path: `/pages/pbService/web/index?weburl=${encodeURIComponent(this.data.webUrl)}`, |
|||
} |
|||
}, |
|||
|
|||
onShareTimeline: function() { |
|||
return { |
|||
title: this.data.shareTitle, |
|||
path: `/pages/pbService/web/index?weburl=${encodeURIComponent(this.data.webUrl)}`, |
|||
} |
|||
} |
|||
}) |
|||
@ -0,0 +1,3 @@ |
|||
{ |
|||
"usingComponents": {} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
<!--pages/pbService/web/index.wxml--> |
|||
<view wx:if="{{webUrl}}"> |
|||
<web-view src="{{webUrl}}" bindmessage="handleMessage"></web-view> |
|||
</view> |
|||
@ -0,0 +1 @@ |
|||
/* pages/pbService/web/index.wxss */ |
|||
Loading…
Reference in new issue