>[info] 承接上述配置,我們接著嵌入 WAP版的代碼,只有我們在手機、iPad等移動設備也可以體驗IM了~,趕緊行動起來吧~
### 視圖層
>[success] 目錄文件:shop_wap>js>common.js
##### line:439
刪除:
/**
* 查詢是否有新消息
*/
function getChatCount() {
if ($('#header').find('.message').length > 0) {
var key = getCookie('key');
if (key !== null) {
$.getJSON(ApiUrl+'/index.php?ctl=Buyer_Message&met=getNewMessageNum&typ=json', {k:key,u:getCookie('id')}, function(result){
if (result.data.count > 0) {
$('#header').find('.message').parent().find('sup').show();
$('#header-nav').find('sup').show();
}
});
}
$('#header').find('.message').parent().click(function(){
window.location.href = WapSiteUrl+'/tmpl/member/chat_list.html';
});
}
}
添加:
/**
* 查詢是否有新消息
*
* YF_IM 消息 跳轉IM的方法
*/
function getChatCount() {
if ($('#header').find('.message').length > 0) {
$('#header').find('.message').parent().click(function(){
if (!getCookie("key")) {
window.location.href = ShopWapUrl + "/tmpl/member/login.html";
} else {
window.location.href = ImApiUrl;
}
});
}
}
>[success] 目錄文件:shop_wap>js>product_detail.js
##### line:1200
刪除:
// 聯系客服
$('.kefu').click(function () {
//判斷不是手機號時使用IM
if ($(this).attr('href').indexOf('tel:') == -1) {
if (!getCookie('user_account') || getCookie('user_account') == undefined) {
if (!getCookie("key")) {
$.sDialog({
skin: "red",
content: '您還沒有登錄',
okBtn: true,
okBtnText: '立即登錄',
okFn: function () {
window.location.href = WapSiteUrl + '/tmpl/member/login.html';
},
cancelBtn: true,
cancelBtnText: '取消',
cancelFn: function () {
}
});
return false;
}
}
if (window.chatTo) {
chatTo(result.data.store_info.member_name.toString());
} else {
window.location.href = WapSiteUrl + '/tmpl/im-chatinterface.html?contact_type=C&contact_you=' + result.data.store_info.member_name + '&uname=' + getCookie('user_account');
}
}
});
添加:
/**
* YF_IM 聯系客服 的點擊事件方法
*
* 傳參和跳轉頁面
*
*/
$(".kefu").click(function () {
// 商品參數:
console.log(result.data);
//判斷不是手機號時使用IM
if ($(this).attr("href").indexOf("tel:") == -1) {
if (!getCookie("user_account") && getCookie("user_account") == undefined) {
if (!getCookie("key")) {
$.sDialog({
skin: "red",
content: "您還沒有登錄",
okBtn: true,
okBtnText: "立即登錄",
okFn: function () {
window.location.href = WapSiteUrl + "/tmpl/member/login.html";
},
cancelBtn: true,
cancelBtnText: "取消",
cancelFn: function () {
}
});
return false;
}
} else {
/**
* 需要帶過去的參數
* 商品的第一張圖片 result.data.good_one_image
* 商品名稱:result.data.goods_info.common_name
* 商品價格:當前價格/活動價格 result.data.goods_info.common_price/result.data.goods_info.common_market_price
* 商品鏈接:callback_url
* 店鋪名稱:result.data.store_info.store_name
*
* */
var callback_url = window.location.href,
goods_info = result.data,
shop_name = goods_info.store_info.store_name,
goods_price = goods_info.goods_info.common_price,
goods_market = goods_info.goods_info.common_market_price,
goods_image = goods_info.goods_one_image,
goods_name = goods_info.goods_info.common_name,
shop_logo = goods_info.store_info.store_logo,
seller_name = goods_info.store_info.member_name;
window.location.href = ImApiUrl + "?to_kefu=1&shop_name=" + shop_name + "&callback_url=" + callback_url + "&goods_price=" + goods_price + "&goods_market=" + goods_market + "&goods_image=" + goods_image + "&goods_name=" + goods_name + "&shop_logo=" + shop_logo + "&seller_name=" + seller_name;
}
}
});