【前端】印包客app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.8 KiB

<template>
<view>
<web-view :src="url"></web-view>
</view>
</template>
<script>
import { go2, back } from '@/utils/hook.js'
import { makeSocket } from '@/utils/index.js'
export default {
data() {
return {
url: '',
socket: null,
params: null
}
},
onLoad(option) {
if (option) {
// this.url = decodeURIComponent(option.url)
this.url = option.url
this.params = option.params ? JSON.parse(option.params) : ''
console.log('params', option.params)
} else {
uni.showToast({
title: '参数错误',
icon: 'none',
complete: () => {
setTimeout(() => {
back()
}, 1000)
}
})
}
},
onShow() {
this.initSocket()
},
onHide() {
console.log('onHide')
this.destroySocket()
},
onUnload() {
console.log('onUnload')
this.destroySocket()
},
methods: {
initSocket() {
makeSocket({ pageInfo: 'page-view', retry: true }).then((res) => {
this.destroySocket()
this.socket = res
this.socket.onMessage(this.getMessage)
})
},
/**
* @param {Object} data {data:{},type:''}
*/
getMessage(data) {
// 供应商担保协议回调
if (data.type === 'guaranteeSuccess') {
go2('fs-credit', { ...this.params }, true)
}
// 订单合同签署成功
if (data.type == 'ybkClientTCSignSuccess') {
go2('order-detail', { orderId: data.data.orderId }, true)
}
// 签约成功
if (data.type == 'signSuccess') {
// go2('order-detail', { id: data.orderId }, true)
}
// 实名认证成功
if (data.type == 'certificatedSuccess') {
go2('mine')
}
},
destroySocket() {
if (this.socket) {
this.socket.close()
this.socket = null
}
}
}
}
</script>