<template>
    <view>
        <web-view :src="src" type="im"></web-view>
    </view>
</template>

<script>
	var api = require('@/config/api.js');
// d:\Jz\Code\Mall20220601\douyin\pages\chat\im\im.js
export default {
    data() {
        return {
				// #ifdef MP-TOUTIAO
                 src: 'https://im6a9eefe.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=f7659f6c-52bd-4ee2-9162-46425604af70',
			     nickName: '抖音用户',
				// #endif
				// #ifdef MP-ALIPAY
				src: 'https://im6a9eefe.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=6e10867f-ab6d-446e-81f6-018eab9eb0bb',
				nickName: '支付宝用户',
					// #endif
                userId: '',
       
			
        };
    },
    onLoad: function (options) {
		let yunjia= api.checkYunJia();
		if(yunjia){
			console.log('云嘉客服');
			uni.showModal({
			    title: '提示',
			    content: '是否拨打客服热线：4009218987',
			    success: function (res) {
			        if (res.confirm) { 
						uni.makePhoneCall({
						          phoneNumber: '4009218987'  
						        })
			        } else if (res.cancel) {
			            console.log('用户点击取消');
			        }
			    }
			});
			this.src="https://imxcx2.7x24cc.com/phone_webChat.html?accountId=N000000023246&chatId=13a693f5-031c-49e5-b94a-1b63d41fdd21";
		}
		
        let userInfo = uni.getStorageSync('userInfo');
        console.info(userInfo);

        //读取缓存中的昵称
        let nickName = uni.getStorageSync('nickName');

        //随机数
        let md = Math.random() * 10000 + 10000;
        if (userInfo) {
            this.setData({
                nickName: userInfo.nickName,
                userId: userInfo.id
            });
        } else {
            if (!nickName) {
					// #ifdef MP-TOUTIAO
                nickName = '抖音用户' + md.toFixed(0);
				// #endif
				// #ifdef MP-ALIPAY
			 nickName = '支付宝用户' + md.toFixed(0);
					// #endif
            }
            this.setData({
                nickName: nickName,
                userId: userInfo.id
            });
            uni.setStorageSync('nickName', nickName);
        }
        this.setData({
            src: this.src + '&nickName=' + encodeURI(this.nickName)
        });
    },
    methods: {}
};
</script>
<style>
/* d:\Jz\Code\Mall20220601\douyin\pages\chat\im\im.ttss */
</style>
