You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
14 KiB
JavaScript
308 lines
14 KiB
JavaScript
var RIC = RIC || {};
|
|
!function($) {
|
|
var Host = window.location.protocol + '//' + window.location.host + '/', self;
|
|
|
|
$.OrderCommon = function() {
|
|
this.UrlMaps = {
|
|
downloadBrowserPlugin: Host + 'common/overall/downloadBrowserPlugin',
|
|
getMallBrowserPluginAgreement: Host + 'common/overall/getMallBrowserPluginAgreement',
|
|
saveMallBrowserPluginAgreement: Host + 'common/overall/saveMallBrowserPluginAgreement',
|
|
};
|
|
self = this;
|
|
};
|
|
$.OrderCommon.prototype = {
|
|
checkMsOrderPlugin: function() {
|
|
if (parseInt($("#J_requestIsElectron").val())) {
|
|
return true;
|
|
}
|
|
|
|
var appName = $('#J_appName').val();
|
|
if (appName == 'pdddz' || appName == 'pdddzod') {
|
|
var downloadUrl = Host + "app/views/static/dzorder-plugin.crx?t=" + new Date().getTime();
|
|
var installTip = '<div class="p-a-md text-center"><div class="alert alert-warning ft_16 m-b"><i class="fa fa-warning fa-fw"></i>系统检测到您未安装店长一键下单插件,请下载安装最新店长一键下单插件,安装成功后请刷新页面。</div><p clas="ft_14">如果已安装,<a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw"></i>请点击刷新</a></p><a class="btn btn-primary" href="https://pdddz-pub.oss-cn-beijing.aliyuncs.com/plugin/dzorder-plugin.zip"><i class="fa fa-chrome fa-fw"></i>下载谷歌浏览器插件</a><a class="btn btn-primary m-l" href="https://pdddz-pub.oss-cn-beijing.aliyuncs.com/plugin/dzorder-plugin.crx"><i class="fa fa-edge fa-fw"></i>下载360/QQ等浏览器插件</a></div>';
|
|
|
|
var updateTip = '<div class="p-a-md text-center"><div class="alert alert-info ft_16 m-b"><i class="fa fa-info-circle fa-fw fa-lg"></i>店长一键下单插件升级,请下载安装最新版店长一键下单插件,安装成功后请刷新页面。</div><p clas="ft_14">如果已安装,<a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw"></i>请点击刷新</a></p><a class="btn btn-primary" href="https://pdddz-pub.oss-cn-beijing.aliyuncs.com/plugin/dzorder-plugin.zip"><i class="fa fa-chrome fa-fw"></i>下载谷歌浏览器插件</a><a class="btn btn-primary m-l" href="https://pdddz-pub.oss-cn-beijing.aliyuncs.com/plugin/dzorder-plugin.crx"><i class="fa fa-edge fa-fw"></i>下载360/QQ等浏览器插件</a></div>';
|
|
var newVersion = $("#J_newDzOrderChromeExtReady").data('version');
|
|
var newestVersion = $("#J_newestDzOrderPluginVersion").val();
|
|
|
|
if (!newVersion) {
|
|
$.layer({
|
|
type: 1,
|
|
area: ["500px", "180px"],
|
|
title: false,
|
|
closeBtn: [1, true],
|
|
shadeClose: false,
|
|
fix: true,
|
|
skin: "layer-ext-moon",
|
|
page: {
|
|
html: installTip,
|
|
}
|
|
});
|
|
return false
|
|
}
|
|
} else if (appName == 'mspddod') {
|
|
var newVersion = $("#J_newMsOrderChromeExtReady").data('version');
|
|
var pddVersion = $("#J_pddMsOrderChromeExtReady").data('version');
|
|
|
|
var hasInstallPlugin = true;
|
|
if (!newVersion && !pddVersion) {
|
|
hasInstallPlugin = false;
|
|
}
|
|
if (newVersion && !pddVersion) {
|
|
hasInstallPlugin = false;
|
|
}
|
|
if (newVersion && pddVersion) {
|
|
hasInstallPlugin = false;
|
|
}
|
|
let cacheVersionKey = 'currentBrowserPluginVersion';
|
|
let cacheVersion = window.localStorage.getItem(cacheVersionKey) || null;
|
|
if (pddVersion && (!cacheVersion || (cacheVersion != pddVersion))) {
|
|
window.localStorage.setItem(cacheVersionKey, pddVersion);
|
|
self.saveShopBrowserPluginAgreement({'version': self.getPluginVersion()});
|
|
}
|
|
if (!hasInstallPlugin) {
|
|
self.showMsInstallBrowserPluginTip(hasInstallPlugin);
|
|
return hasInstallPlugin;
|
|
}
|
|
self.checkShowBrowserPluginUpdateModal(true);
|
|
} else {
|
|
var downloadUrl = Host + "app/views/static/msorder-plugin.crx?t=" + new Date().getTime();
|
|
var installTip = '<div class="p-a-md text-center"><div class="alert alert-warning ft_16 m-b"><i class="fa fa-warning fa-fw"></i>系统检测到您未安装妙手一键下单插件,请下载安装最新妙手一键下单插件,安装成功后请刷新页面。</div><p clas="ft_14">如果已安装,<a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw"></i>请点击刷新</a></p><a class="btn btn-primary" href="' + downloadUrl + '"><i class="fa fa-cloud-download fa-fw"></i>下载插件</a></div>';
|
|
var updateTip = '<div class="p-a-md text-center"><div class="alert alert-info ft_16 m-b"><i class="fa fa-info-circle fa-fw fa-lg"></i>妙手一键下单插件升级,请下载安装最新版妙手一键下单插件,安装成功后请刷新页面。</div><p clas="ft_14">如果已安装,<a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw"></i>请点击刷新</a></p><a class="btn btn-primary" href="' + downloadUrl + '"><i class="fa fa-cloud-download fa-fw"></i>下载插件</a></div>';
|
|
var newVersion = $("#J_newMsOrderChromeExtReady").data('version');
|
|
var newestVersion = $("#J_newestMsOrderPluginVersion").val();
|
|
|
|
if (!newVersion) {
|
|
$.layer({
|
|
type: 1,
|
|
area: ["500px", "180px"],
|
|
title: false,
|
|
closeBtn: [1, true],
|
|
shadeClose: false,
|
|
fix: true,
|
|
skin: "layer-ext-moon",
|
|
page: {
|
|
html: installTip,
|
|
}
|
|
});
|
|
return false
|
|
}
|
|
}
|
|
|
|
// 暂时不强制升级
|
|
// if (newestVersion > newVersion) {
|
|
// $.layer({
|
|
// type: 1,
|
|
// area: ["500px", "180px"],
|
|
// title: false,
|
|
// closeBtn: 1,
|
|
// shadeClose: false,
|
|
// fix: true,
|
|
// skin: "layer-ext-moon",
|
|
// page: {
|
|
// html: updateTip,
|
|
// }
|
|
// });
|
|
// return false
|
|
// }
|
|
return true
|
|
},
|
|
getMsInstallBrowserPluginModalContentHtml: function(isUpdate, isShowNextBtn) {
|
|
var isUpdate = isUpdate || false, isShowNextBtn = isShowNextBtn || false;
|
|
|
|
var headerHtml = '<div class="p-b text-center">' +
|
|
' <span style="color:#EA9E26">系统检测到您未安装妙手插件,请下载安装最新妙手插件,安装成功后请刷新页面。</span>' +
|
|
' </div>' +
|
|
' <div class="text-center p-t">' +
|
|
' <span>如果已安装,<a href="javascript:void(0);" style="color:#2CBEBD;" onclick="window.location.reload();"><i class="fa fa-refresh m-r-sm"></i>请点击刷新</a></span>' +
|
|
' </div>';
|
|
|
|
if (isUpdate) {
|
|
headerHtml = '<div class="p-b text-center">' +
|
|
' <span style="color:#EA9E26">插件已升级,请卸载旧版插件,下载并安装最新插件后再使用。</span>' +
|
|
' </div>' +
|
|
' <div class="text-center p-t">' +
|
|
' <span>如果插件已升级,<a href="javascript:void(0);" style="color:#2CBEBD;" onclick="window.location.reload();"><i class="fa fa-refresh m-r-sm"></i>请点击刷新</a></span>' +
|
|
' </div>';
|
|
}
|
|
|
|
var nextBtnHtml = '';
|
|
if (isShowNextBtn) {
|
|
nextBtnHtml = '<a class="J_nextAgainTipBtn" href="javascript:void(0);" style="color:#797979;margin-left:15px;">下次再说</a>';
|
|
}
|
|
|
|
var html = '<div class="ft_16">' +
|
|
headerHtml +
|
|
' <div class="text-center" style="padding:30px 20px;">' +
|
|
' <a class="J_downloadBrowserPluginBtn" data-browser-type="chrome" href="javascript:void(0);" style="padding:10px 15px;border-radius:20px;border:2px solid #4ECBCA;text-decoration: none;color:#4ECBCA;cursor: pointer;">' +
|
|
' <img src="/app/views/static/img/browser/chrome.png" style="vertical-align: middle;margin-bottom: 5px;width:24px;margin-right: 5px;">谷歌/QQ等浏览器' +
|
|
' </a>' +
|
|
' <a class="J_downloadBrowserPluginBtn" data-browser-type="360" href="javascript:void(0);" style="margin-left:15px;padding: 10px 15px;border-radius: 20px;border:2px solid #4ECBCA;text-decoration: none;color:#4ECBCA;cursor: pointer;">' +
|
|
' <img src="/app/views/static/img/browser/360.png" style="vertical-align: middle;margin-bottom: 5px;width:24px;margin-right: 5px;">360/搜狗等浏览器' +
|
|
' </a>' +
|
|
nextBtnHtml +
|
|
' </div>' +
|
|
' <div class="text-center" style="padding: 20px;">' +
|
|
' <label class="zc-custom-control zc-custom-control-primary zc-custom-checkbox">' +
|
|
' <input id="J_browserPluginInstallAgreementCheckbox" type="checkbox" class="zc-custom-control-input" name="browserPluginInstallAgreement">' +
|
|
' <span class="zc-custom-control-indicator"></span>' +
|
|
' <span class="zc-custom-control-label">' +
|
|
' 我已阅读并同意<a style="color:#2CBEBD;" href="https://cs-rt-c1.chengji-inc.com/browser-plugin/agreement/user_agreement_v5.html" target="_blank">用户服务协议、</a><a style="color:#2CBEBD;" href="https://cs-rt-c1.chengji-inc.com/browser-plugin/agreement/privacy_policy_v2.html" target="_blank">隐私政策</a>,确定下载并使用插件。' +
|
|
' </span>' +
|
|
' </label>' +
|
|
' </div>' +
|
|
' <div class="text-center" style="padding: 10px 20px 10px 20px;">' +
|
|
' <span>' +
|
|
' <span style="color:#2CBEBD;">请点击您所使用的浏览器,下载对应的插件</span>' +
|
|
' <a href="http://school.91miaoshou.com/" target="_blank" style="color:#797979;">(查看安装教程)</a>' +
|
|
' </span>' +
|
|
' </div>' +
|
|
' </div>';
|
|
|
|
return html;
|
|
},
|
|
showMsInstallBrowserPluginTip: function(hasInstallPlugin) {
|
|
if (hasInstallPlugin) {
|
|
return ;
|
|
}
|
|
self.showBrowserPluginModalDialog(hasInstallPlugin);
|
|
},
|
|
showBrowserPluginModalDialog: async function(hasInstallPlugin) {
|
|
var isUpdate = hasInstallPlugin || false, isShowNextBtn = false;
|
|
if (isUpdate) {
|
|
var agreementInfo = await self.getShopBrowserPluginAgreement();
|
|
agreementInfo.isShowNextBtn && (isShowNextBtn = true);
|
|
}
|
|
|
|
var browserPluginModalDialog = new BootstrapDialog({
|
|
title: '提示',
|
|
size: 'size-large',
|
|
message: self.getMsInstallBrowserPluginModalContentHtml(isUpdate, isShowNextBtn),
|
|
closeByBackdrop: false,
|
|
closeByKeyboard: false,
|
|
onshow: function (browserPluginDialogSelf) {
|
|
browserPluginDialogSelf.getModalDialog().attr({'style': 'width: 700px;'});
|
|
var modalDidalog = browserPluginDialogSelf.getModalDialog();
|
|
|
|
modalDidalog.on('click', '.J_downloadBrowserPluginBtn', function () {
|
|
var $this = $(this),
|
|
browserType = $this.data('browserType'),
|
|
$browserPluginInstallAgreement = modalDidalog.find('#J_browserPluginInstallAgreementCheckbox');
|
|
if (!$browserPluginInstallAgreement.prop('checked')) {
|
|
return layer.alert('请先阅读并勾选同意用户服务协议后再下载');
|
|
}
|
|
if (browserType == 'chrome' && $('#J_appName').val() == 'mspddod') {
|
|
return window.open('https://cs-rt.oss-cn-beijing.aliyuncs.com/browser-plugin/msorder/msorder-pdd-plugin.zip', '_blank');
|
|
} else if (browserType == 'chrome' && $.inArray($('#J_appName').val(), ['pdddz', 'pdddzod']) > -1) {
|
|
return window.open('https://pdddz-pub.oss-cn-beijing.aliyuncs.com/plugin/dzorder-plugin.zip', '_blank');
|
|
}
|
|
|
|
self.saveShopBrowserPluginAgreement({'isSelectedAgreement': 1});
|
|
$.fileDownload(self.UrlMaps.downloadBrowserPlugin, {
|
|
'data': {
|
|
'browserType': browserType,
|
|
'isCheckedAgreement': $browserPluginInstallAgreement.prop('checked') ? 1 : 0
|
|
},
|
|
'httpMethod': 'POST',
|
|
'cookieName': 'browserPluginInstall',
|
|
}).done(function() {
|
|
self.saveShopBrowserPluginAgreement({'isDownload': 1});
|
|
layer.msg('下载成功');
|
|
}).fail(function(retHtml) {
|
|
retHtml = retHtml || '';
|
|
var ret = JSON.parse($(retHtml).text());
|
|
if (ret.result && ret.result == 'fail') {
|
|
layer.alert(ret.reason || '下载失败');
|
|
}
|
|
});
|
|
});
|
|
|
|
modalDidalog.on('click', '.J_nextAgainTipBtn', function () {
|
|
self.saveShopBrowserPluginAgreement({'clickNextBtn': 1});
|
|
browserPluginDialogSelf.close();
|
|
});
|
|
modalDidalog.on('click', '#J_browserPluginInstallAgreementCheckbox', function () {
|
|
if (!this.checked) {
|
|
return ;
|
|
}
|
|
self.saveShopBrowserPluginAgreement({'isSelectedAgreement': 1});
|
|
});
|
|
}
|
|
});
|
|
browserPluginModalDialog.open();
|
|
},
|
|
checkShowBrowserPluginUpdateModal: async function(hasInstall) {
|
|
var isShowUpdateModal = await self.isShowBrowserPluginUpdateModal();
|
|
console.log('isShowUpdateModal', isShowUpdateModal);
|
|
if (!isShowUpdateModal) {
|
|
return ;
|
|
}
|
|
|
|
self.showBrowserPluginModalDialog(hasInstall);
|
|
},
|
|
isShowBrowserPluginUpdateModal: async function() {
|
|
var currentVersion = self.getPluginVersion();
|
|
console.log('currentVersion', currentVersion);
|
|
if (!currentVersion) {
|
|
return true;
|
|
}
|
|
var agreementInfo = await self.getShopBrowserPluginAgreement();
|
|
if (!agreementInfo || !agreementInfo.isShowUpdateModal) {
|
|
return false;
|
|
}
|
|
|
|
currentVersion = parseFloat(currentVersion);
|
|
if (currentVersion < 3.4) {
|
|
return true;
|
|
}
|
|
|
|
if (agreementInfo && agreementInfo.isShowUpdateModal) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
},
|
|
getPluginVersion: function() {
|
|
var appName = $('#J_appName').val();
|
|
if (appName == 'pdddz' || appName == 'pdddzod') {
|
|
var newVersion = $("#J_newDzOrderChromeExtReady").data('version');
|
|
} else if (appName == 'mspddod') {
|
|
var oldVersion = $("#J_newMsOrderChromeExtReady").data('version');
|
|
var pddVersion = $("#J_pddMsOrderChromeExtReady").data('version');
|
|
|
|
var newVersion = pddVersion;
|
|
} else {
|
|
var newVersion = $("#J_newMsOrderChromeExtReady").data('version');
|
|
}
|
|
return newVersion;
|
|
},
|
|
getShopBrowserPluginAgreement: function() {
|
|
return new Promise((resolve, reject) => {
|
|
let version = self.getPluginVersion();
|
|
$.ajax({
|
|
url : self.UrlMaps.getMallBrowserPluginAgreement,
|
|
data : {'version': version || ''},
|
|
dataType : 'json',
|
|
method : 'post'
|
|
}).always(function(){
|
|
}).done(function(ret){
|
|
var isShowUpdateModal = (ret && ret.isShowUpdateModal) ? true : false;
|
|
var isShowNextBtn = (ret && ret.isShowNextBtn) ? true : false;
|
|
resolve({'isShowUpdateModal': isShowUpdateModal, 'isShowNextBtn': isShowNextBtn});
|
|
});
|
|
});
|
|
},
|
|
saveShopBrowserPluginAgreement: function(valueMap) {
|
|
$.ajax({
|
|
url : self.UrlMaps.saveMallBrowserPluginAgreement,
|
|
data : valueMap,
|
|
dataType : 'json',
|
|
method : 'post'
|
|
}).always(function(){
|
|
}).done(function(ret){
|
|
console.log('saveShopBrowserPluginAgreement', ret);
|
|
});
|
|
},
|
|
};
|
|
RIC.OrderCommon = new $.OrderCommon();
|
|
}(jQuery); |