<template>
	<view class="h100vh page-bg-color">
		<u-navbar v-if="showNavbar" :customBack="handleBackHome" :title="typeLabel[currentType]"></u-navbar>
		<view class="workflow-page" :style="{height: `calc(100vh - ${diStatusBarHeight}px - 48px)`}">
			<view class="workflow-main">
				<start-workflow v-if="currentType === 'start'"></start-workflow>
				<approve-center v-else :type='currentType'></approve-center>
			</view>
		</view>
	</view>	
</template>

<script>
    // import wx from "weixin-js-sdk";
	import startWorkflow from './startWorkflow/startWorkflow'
	import approveCenter from './approveCenter/index'
    import constant from '@/utils/constant.js'
	export default {
		data() {
			return {
				currentType: 'start',
                showNavbar:true,
				typeLabel: {
					start: '发起申请',
					myLaunch: '我发起的',
					todo: '我的待办',
					done: '我的已办',
					cc: '抄送我的',
					manager: '流程干预',
				},
				diStatusBarHeight: 0
			};
		},
		onLoad(options) {
			this.diStatusBarHeight = uni.getSystemInfoSync().statusBarHeight
			this.currentType = options.type
            if(options?.mpType){
                this.showNavbar=false
            }
            uni.setNavigationBarTitle({
                    title: this.typeLabel[this.currentType] || ''
                });
            // console.log('类型',options.type)
		},
       
		components: {
			startWorkflow,
			approveCenter
		},
		methods: {
			handleBackHome() {
				console.log('000000')
                let url=constant.host()
                window.parent.postMessage('/pages/index/index',url+'/mobile/pages/flow/flow')
                // try {
                    // console.log('unipostMessage')
                    // uni.webView.postMessage({
                    //     data: {
                    //         action: '/pages/index/index'
                    //     }
                    // });
                // } catch (error) {
                //     console.warn('unipostMessage',error)
                // }
                // uni.switchTab({
				// 	url: '/pages/index/index'
				// })
			}
		}
	}
</script>

<style lang="scss">
	.h100vh {
		height: 100vh;
	}
	.workflow-page {
		.workflow-main {
			height: 100%;
			overflow: hidden;
		}
	}
	
</style>
