service.html 7.1 KB
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <script src="../../assets/js/fontsize.js"></script>
    <!--<link rel="stylesheet" href="../../assets/css/api.css"/>-->
    <!--<link rel="stylesheet" href="http://at.alicdn.com/t/font_641470_jg64l6ijsg4lsor.css">-->
    <link rel="stylesheet" href="../../assets/icon/iconfont.css">
    <style>
        body, html {
            background-color: transparent !important;
            height: 100%;
            color: #dbb25f;
        }

        .send_box {
            position: fixed;
            width: 100%;
            bottom: 0;
            left: 0;
            background-color: #fff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.13rem 0 0.13rem 0.31rem;
            font-size: 10px;
            color: #424242;
        }

        .send_box input {
            border: 1px solid #DEDEDE;
            padding: 0.1rem;
            flex: 1;
        }

        .msg {
            font-size: 12px;
            color: #fff;
            background-color: #D8B25F;
            padding: 0.1rem 0.3rem;
            margin-left: 0.5rem;
        }
    </style>
</head>
<body>
<div id="app">

</div>
</body>
</html>
<script type="text/javascript" src="../../assets/js/api.js"></script>
<script type="text/javascript" src="../../assets/js/public.js"></script>
<script type="text/javascript" src="../../assets/js/fastclick.js"></script>
<script>
    new FastClick(document.body);
</script>
<script type="text/javascript" src="../../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../../assets/js/swiper-3.4.2.min.js"></script>
<script type="text/javascript" src="../../assets/icon/iconfont.js"></script>
<script type="text/javascript" src="../../assets/js/axios.min.js"></script>
<!--<script type="text/javascript" src="http://at.alicdn.com/t/font_641470_jg64l6ijsg4lsor.js"></script>-->
<script>
    var app = new Vue({
        el: '#app',
        data: {
            rongYunToken: '',
            textContent: '',
            userId: '',
            user_info: []
        },
        created: function () {
            apiready = function () {
                app.getUserIndexInfo();
                app.getRongYunToken();
                app.openSever();
            }
        },
        methods: {
            close: function () {
                api.closeFrame();
            },
            getRongYunToken: function () {
                var header = {
                    "XX-Device-Type": getDevice(),
                    'XX-Token': getToken()
                };
                getRequest('post', 'portal/RongYun/index', null, header).then(function (res) {
                    if (res.data.code == 1) {
                        app.rongYunToken = res.data.data.token;
                        app.userId = res.data.data.userId;
                        app.rongyunInit();
                    } else {
                        toastMsg(res.data.msg)
                    }
                })
            },
            getUserIndexInfo: function () {
                var header = {
                    "XX-Device-Type": getDevice(),
                    'XX-Token': getToken()
                };
                getRequest('post', 'user/index/getUserIndexInfo', null, header).then(function (res) {
                    if (res.data.code == 1) {
                        app.user_info = res.data.data;
                        // alert(JSON.stringify(app.user_info))
                    } else {
                        toastMsg(res.data.msg)
                    }
                })
            },
            openSever: function () {
                app.img_active = false;
                app.getRongYunToken();
                function callBack(ret, err) {
                    // alert("ret.type="+ret.type+"value="+ret.value+"ret.desc="+ret.desc);
                    if (ret.type == 1) {
                        api.closeWin();
                    }
                }
                var param = {
                    appkey: "1da38c74bc3746cea6b767727683ca83",
                    titleImgId: '#dbb25f',
                    themeColor: '#dbb25f',
                    backgroundColor: '#f8f9f8',
                    userId: app.userId,
                    customBannerColor: '#dbb25f',
                    nickName: "",
                    phone: "",
                    email: "",
                    customInfo: {"uname": app.user_info.name, 'avatarUrl': app.user_info.avatar},
                    transferKeyWord: '人工服务,人工,电话',
                    isShowEvaluate: true,
                    isSettingSkillSet: false,
                    skillSetId: "",
                    customUserOutWord: '欢迎再次咨询',
                    customAdminTipWord: '请稍等... 正在查询资料',
                    customAdminNonelineTitle: '人工客服忙~',
                    isShowTansfer: true,
                    titleFont: 18.0,
                    bottomLineColor: '#dbb25f',
                    goodsTitle: '56870',
                    goodsLabel: '123456',
                    goodsImage: '../../assets/image/head.png',
                    goodsFromUrl: 'http://www.baidu.com',
                    isDebugMode: 'YES'
                };
                var zhichi = api.require('zhiChiSobot');
                zhichi.startZhiChiSobot(param, callBack);
            },
            rongyunInit: function () {
                var rong = api.require('rongCloud2');
                rong.init(function (ret, err) {
                    if (ret.status == 'error') {
                    } else {
                        rong.connect({
                            token: app.rongYunToken
                        }, function (ret_connect, err_connect) {
                            if (ret_connect.status == 'success') {
                                // app.userId = ret_connect.result.userId
                            }
                            else {
                            }
                        });
                    }
                });
            },
//             sendMsg: function () {
//                 var rong = api.require('rongCloud2');
//
// // 之前调用 init 和 connect 的代码省略
//                 rong.sendTextMessage({
//                     conversationType: 'CUSTOMER_SERVICE',
//                     targetId: app.userId,
//                     text: app.textContent,
//                     extra: ''
//                 }, function (ret, err) {
//                     if (ret.status == 'prepare')
//                         api.toast({msg: JSON.stringify(ret.result.message)});
//                     else if (ret.status == 'success')
//                         api.toast({msg: ret.result.message.messageId});
//                     else if (ret.status == 'error')
//                         api.toast({msg: err.code});
//                 });
//             }
        }
    })
</script>