Commit fff4d058 by 李嘉林

兼容

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