多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
>[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; } } });