<template>
|
<view>
|
<web-view v-if="webshow" :webview-styles="webviewStyles" :src="webviewUrl" @message='received'></web-view>
|
<!-- taobao -->
|
<u-popup v-model="empowerModel" mode="center" border-radius="12">
|
<empowerModel @closemodel='closeMdl' @updataInfo='updataUser'></empowerModel>
|
</u-popup>
|
</view>
|
|
</template>
|
|
<script>
|
import empowerModel from '../../components/empowerModel.vue'
|
var wv;
|
export default {
|
components: {
|
empowerModel
|
},
|
data() {
|
return {
|
webshow:true,
|
empowerModel: false,
|
webviewUrl: '',
|
user:'',
|
webviewStyles: {
|
progress: {
|
color: '#EE1B14'
|
}
|
},
|
}
|
},
|
onLoad(options) {
|
if(!this.hasLogin){
|
uni.reLaunch({
|
url:"/pages/login/wxlogin"
|
})
|
}
|
else{
|
const value = uni.getStorageSync('userInfo');
|
console.log(value)
|
this.webviewUrl = encodeURI('http://appapitest.ushopvip.com/html/compareprice.html?token='+value.token);
|
}
|
|
},
|
onReady() {
|
this.clearMuiBack();
|
},
|
methods: {
|
|
received(e) {
|
var res=e.detail.data[0];
|
console.log(res);
|
switch(res.action)
|
{
|
case "back"://返回
|
this.backLast();
|
break;
|
case "tbauth"://淘宝授权
|
this.openTbMd();
|
break;
|
case "totb":
|
this.targetTb(res.tburl);
|
break;
|
case "copy":
|
this.getCopyTxt();
|
break;
|
case "getlike":
|
this.getLike();
|
break;
|
}
|
},
|
getLike()
|
{
|
console.log('进来了');
|
var postData={
|
deviceType: getApp().globalData.platform == 'android' ? (getApp().globalData.systemLevel < 10 ? 'IMEI' : 'OAID') :
|
'IDFA',
|
deviceValue: getApp().globalData.equipmentNumber
|
};
|
console.log(postData);
|
var currentWebview = this.$scope.$getAppWebview().children()[0];
|
currentWebview.evalJS(`likeDataGet(${JSON.stringify(postData)})`);
|
},
|
getCopyTxt()
|
{
|
uni.getClipboardData({
|
success: res => {
|
//调用页面里的方法
|
console.log(res, '======================================================');
|
var currentWebview = this.$scope.$getAppWebview().children()[0];
|
currentWebview.evalJS(`scanCode(${JSON.stringify(res)})`);
|
}
|
})
|
},
|
targetTb(tburl)
|
{
|
// #ifdef APP-PLUS
|
if (plus.runtime.isApplicationExist({
|
pname: 'com.taobao.taobao',
|
action: 'taobao://'
|
})) {
|
const plug = uni.requireNativePlugin('xiguazhu-baichuan')
|
plug.detailPage({
|
url: tburl,
|
"openType": 0
|
}, result => {
|
});
|
} else {
|
uni.navigateTo({
|
url:'@/webView/webView?url=' + tburl
|
})
|
}
|
// #endif
|
},
|
backLast()
|
{
|
console.log("返回")
|
uni.navigateBack({
|
delta: 1
|
});
|
},
|
closeMdl() {
|
this.empowerModel = false;
|
this.webshow=true;
|
},
|
openTbMd()
|
{
|
this.webshow=false;
|
this.empowerModel = true
|
},
|
updataUser() {
|
var that = this;
|
this.$u.api.getUserInfo({}).then(e => {
|
utils.setCache('userInfo', e.data.userinfo)
|
that.user = e.data.userinfo;
|
}).catch(function(err) {})
|
},
|
// 关闭mui返回
|
clearMuiBack() {
|
// #ifdef APP-PLUS
|
/* var currentWebview = this.$scope.$getAppWebview().children()[0];
|
//监听注入的js
|
currentWebview.addEventListener("loaded", function() {
|
currentWebview.evalJS("mui.init({keyEventBind: {backbutton: false }});");
|
}); */
|
// #endif
|
},
|
|
},
|
onNavigationBarButtonTap(e) {
|
// #ifdef APP-PLUS
|
const currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
|
var wv = currentWebview.children()[0]
|
wv.reload();
|
// #endif
|
},
|
}
|
</script>
|
|
<style>
|
|
</style>
|