<template>
	<view>
		<web-view :src="src"></web-view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		getUserSig,
		consultation,
	} from '@/api/homepage/index.js'
	import {
		hospitalPerson
	} from '@/api/myinformation/myinformation.js'
	import {
		nextTick
	} from "vue";
	export default {
		data() {
			return {
				src: '',
				datalist: '',
				userSig: '', //获取userSig
				roomId: '', //获取roomId
				userId: '',
				userName: '', //医生Name
			};
		},
		onLoad(options) {
			this.datalist = JSON.parse(options.item)
			this.userId = uni.getStorageSync("id")
			hospitalPerson(this.userId).then(res => {
				this.userName = res.data.personName
				this.getUserSig()
			})

		},
		onShow() {

		},
		methods: {
			getUserSig() {
				// 获取userSig
				getUserSig(this.userId).then(res => {
					this.userSig = res.data
					// 获取roomId
					consultation(this.datalist.goodsOrderId).then(resp => {
						if (resp.code == 200) {
							this.roomId = resp.msg
							this.src =
								`https://msg.xinyilu.cn​​​​​?userId=${this.userId}&userName=${this.userName}&userSig=${this.userSig}&roomId=${this.roomId}`
						} else if (resp.code == 500) {
							this.$refs.uToast.show({
								title: resp.msg,
								type: 'error',
								duration: '1500'
							})

						}
						console.log(this.src, '99')
					})
				})
			},
		},
	}
</script>

<style lang="scss">

</style>