Commit fff4d058 by 李嘉林

兼容

parent 446dc856
<template>
<div class="text">
<div v-if="loadFlag<=1">正在跳转到其他小程序...</div>
<div class="text" v-if="pageType == 0">
<div v-if="loadFlag <= 1">正在跳转到其他小程序...</div>
<div v-else class="toMini" @click="toMini">点击跳转到其他小程序</div>
</div>
</template>
<script>
export default {
data(){
export default {
data() {
return {
loadFlag: 0,
options: "",
pageType: 0, // 0默认 1打开地图
}
},
onLoad(options){
onLoad(options) {
this.options = options;
console.log("onLoad",this.loadFlag)
console.log("onLoad", this.loadFlag, this.options)
if (this.options && this.options.type == 1) {
this.pageType = 1;
this.openLocation();
} else {
this.toMini();
}
},
onShow(){
this.loadFlag ++;
console.log("onShow",this.loadFlag)
onShow() {
this.loadFlag++;
console.log("onShow", this.loadFlag)
this.toMini();
if (this.pageType == 1) {
wx.navigateBack();
}
},
methods: {
toMini(){
openLocation() {
wx.openLocation({
latitude: this.options.latitude - 0,
longitude: this.options.longitude - 0,
address: this.options.address,
scale: 18,
success(res) {
console.log("success", res)
},
fail(res) {
console.log("fail", res)
},
complete(res) {
console.log("complete", res)
}
})
},
toMini() {
let _this = this;
wx.navigateToMiniProgram({
appId: _this.options.weappAppId,
......@@ -32,14 +58,14 @@
// envVersion: 'release',
extraData: _this.options.extraData && JSON.parse(_this.options.extraData),
success(res) {
console.log(res,'--------打开成功')
console.log(res, '--------打开成功')
// 打开成功
},
complete(res){
console.log(res,'------------------38')
complete(res) {
console.log(res, '------------------38')
if (res.errMsg == 'navigateToMiniProgram:fail cancel') {
// 点击了取消
_this.loadFlag ++;
_this.loadFlag++;
} else if (res.errMsg == 'navigateToMiniProgram:ok') {
// 点击了跳转
wx.navigateBack();
......@@ -48,17 +74,18 @@
})
}
}
}
}
</script>
<style lang="scss" scoped>
.text{
.text {
text-align: center;
margin-top: 30px;
font-size: 16px;
color: #333;
}
.toMini{
.toMini {
width: 60%;
margin: 0 auto;
margin-top: 40vh;
......
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