<template>
    <view>
        <web-view :webview-styles="webviewStyles" :src="url" @message="getMessage"></web-view>
    </view>
</template>

<script>
	import { getShopMallToken} from '@/common/api.js';
	import { callbackRequest, setStorage, getStorage, sureAlterTip, devEnv, alertTip } from '@/common/util.js';
    export default {
        data() {
            return {
                webviewStyles: {
                    progress: {
                        color: '#4db4ea'
                    }
                },
				userInfo: getStorage("userInfo"),
				url:""
                //url: 'http://124.126.19.5:19847/vuemrst-wh/index.html#/'
				//url:'http://192.168.171.60:8080/vuemrst-wh/index.html#/'
            }
        },
        onLoad(options) {
			this.goShopMall();
        },
        methods: {
			getMessage(event){
				console.log(event.detail.data);
			},
			goShopMall(){
				let params = {
					method:getShopMallToken,
					data: {
						mobile:this.userInfo.mobile,
						realName:this.userInfo.realName,
						id:this.userInfo.id,
						deptName:this.userInfo.departmentName
					}
				}
				callbackRequest(params).then(res => {
					res = res.data;
					if (res.returnCode == 1) {
						// this.$api.msg(res.returnMsg);
						var token = res.returnData.token;
						
						var aesutil = require('@/common/AESUtil.js');
						let aesToken = aesutil.encrypt("c32ad1415f6c89fee76d8457c31efb4b",token);
						this.url = res.returnData.url+'?token='+aesToken;
						// uni.navigateTo({
						// 	url: `/pages/shopmall/shopmall?token=`+token
						// });
					} else {
						this.$api.msg(res.returnMsg);
					
					}
				});
			}
        }
    }
</script>