\n' + '
\n' + ' ' + info.name + '' + info.size_str + ', ' + info.ext.toUpperCase() + '' } catch (e) { console.error(e); } } else if (row.message_type == 3) { var info = JSON.parse(row.message); inner += '
\n' + '\n' + '
'+username+'' + '
\n' + '
\n' + ' ' + (getLang() == 'cn' ? info.cn : info.en) + '\n' + '
\n' + '
\n' } else if (row.message_type == 2) { try { var jobInfo = JSON.parse(row.message); inner += '
\n' + '
'+username+'' + '
\n' + '\n' + '
\n' + '
' + jobInfo.title + '
\n' + '
\n' + ' ' + jobInfo.salary + '
\n' + ' ' + jobInfo.company_name + '\n' + '
\n' + '
\n' + '
\n' + '
\n' } catch (e) { console.error(e) } } else if (row.message_type == 6) { try { var info = JSON.parse(row.message); var content = {} if (getLang() == 'cn') { content = JSON.parse(info.cn) } else { content = JSON.parse(info.en) } var cont1 = []; content.items.map(function (row) { if (row.url == '') { cont1.push('' + row.title + '') } else { cont1.push('' + row.title + '') } }) inner += '
\n' + '
'+username+'' + '
\n' + '
\n' + '
\n' + '
' + content.title + '
\n' + '
\n' + '
- \n' + '
- \n' + cont1.join('
- ') + ' \n' + '
\n' + '
\n' + '
\n' + '
\n' + '
\n' } catch (e) { console.error(e) } } else if (row.message_type == 7) { try { var info = JSON.parse(row.message); inner += '
\n' + '\n' + '
'+username+'' + '
\n' + '
\n' + ' ' + (getLang() == 'en' ? info.en : info.cn) + '\n' + '
\n' + '
\n' } catch (e) { console.error(e) } } else if (row.message_type == 8) { try { var info = JSON.parse(row.message); var msg = info.en; if (getLang() == 'cn' && info.cn) { msg = info.cn; } inner += '
\n' + '\n' + '
'+username+'' + '
\n' + '
\n' + ' ' + msg + '\n' + '
\n' + '
\n' } catch (e) { console.error(e) } } else { inner += '
\n' + '\n' + '
'+username+'' + '
\n' + '
\n' + ' ' + row.message + '\n' + '
\n' + '
\n' } if (row.is_user && row.message_type != 7) { inner += vueConsumerChat.messageIsRead(row) + '
' } return inner }, showNum: function () { jGet("/api/v1/consumer_chat/lastMessage", function (res) { if (res.code != 200) { $('.consumerChatVueShowBox').hide(); return } $('.consumerChatVueShowBox').show(); if (res.data.message_num > 0) { $('.consumerChatNum').show().text(res.data.message_num) } else { $('.consumerChatNum').hide().text(res.data.message_num) } // if (res.data.room_edit_time > room_edit_time) { // room_edit_time = res.data.room_edit_time // vueConsumerChat.changeChat({chat_id: chatUser.chat_id}, true); // } if (vueConsumerChat.show) { if (res.data.last_read_id != vueConsumerChat.currentChat.last_read_id || res.data.last_message_time != last_message_time) { vueConsumerChat.currentChat.last_read_id = res.data.last_read_id; last_message_time = res.data.last_message_time; vueConsumerChat.loadNewMessage(0, true, function () { }); } if (vueConsumerChat.show) { if (res.data.last_message_time != room_edit_time) { room_edit_time = res.data.last_message_time // vueConsumerChat.changeChat(); vueConsumerChat.loadNewMessage(0, true, function (message) { }); } } } }, function (res) { $.get('/utils/ll') }) }, autoResizableImgid: function (id) { var tmpInterval = setInterval(function () { if (vueConsumerChat.autoResizableImg($('#consumerChatVue .aut-size-img-' + id), $('#consumerChatVue .aut-size-' + id))) { clearInterval(tmpInterval) } }, 100) }, autoResizableImg: function (img, box) { // var objImg = $('.mask-pic-image .content img'); var imgW = parseFloat(img.css('width')) var imgH = parseFloat(img.css('height')) var imgCW = parseFloat(box.css('width')) var imgCH = parseFloat(box.css('height')) var whsize = vueConsumerChat.autoResizable(imgW, imgH, imgCW, imgCH) if (imgW == 0) { return false } $(img).css('width', whsize.w + "px") $(img).css('height', whsize.h + "px") return true; }, autoResizable: function (w, h, maxWidth, maxHeight) { var hRatio; var wRatio; var Ratio = 1; wRatio = maxWidth / w; hRatio = maxHeight / h; if (maxWidth == 0 && maxHeight == 0) { Ratio = 1; } else if (maxWidth == 0) { if (hRatio < 1) Ratio = hRatio; } else if (maxHeight == 0) { if (wRatio < 1) Ratio = wRatio; } else if (wRatio < 1 || hRatio < 1) { Ratio = (wRatio <= hRatio ? wRatio : hRatio); } if (Ratio < 1) { w = w * Ratio; h = h * Ratio; } return { w: Math.round(w), h: Math.round(h), } }, showImage: function (src) { if (src == '') { $('.mask-pic').hide(); $('.mask-pic-image').hide(); $('.mask-pic-image .content img').remove(); } else { $('.mask-pic-image .content').append("") // $('.mask-pic-image img').attr('src', src); $('.mask-pic').show(); $('.mask-pic-image').show(); vueConsumerChat.autoResizableImg($('.mask-pic-image .content img'), $('.mask-pic-image .content')) } }, } }) function get_help_by_key(key) { var data = { message_type: 8, message: '' + key, } vueConsumerChat.sendMesageData(data, function (res) { }); } $(function () { $(document).on('click', '.openConsumerChatHandler',function () { vueConsumerChat.changeChat(true) }) // vueConsumerChat.changeChat(true); $('.mask-pic-close').bind('click', function () { vueConsumerChat.showImage('') }) }) $('#consumerChatVuechatTck').on('hidden.bs.modal', function (e) { if (CHAT_FETCH_NEW_MESSAGE_INTERVAL != null) { clearInterval(CHAT_FETCH_NEW_MESSAGE_INTERVAL) } vueConsumerChat.changeChat(false); })