var common_fn = (function(){
return{
uprecipe :function(title,vs,huodong_id){
if(this.getQueryString('isapp')=='1'){
var callback = 'recipes://meishitupian.cn/produmethod/uprecipe?tname='+encodeURIComponent(title);
if (this.getQueryString('user_id')) {
this.upClickToken(vs,huodong_id);
location.href=callback;
} else {
this.getlogin();
}
}else{
var newUrl = window.location.origin + window.location.pathname + '?isapp=1&open=0';
if(/ipad|iphone|mac/i.test(navigator.userAgent)){
location.href='http://www.meishitupian.cn/produmethod/lib/om/web/'+encodeURIComponent(newUrl);
}else{
var clipboard = new ClipboardJS('.pubt,.uppic',{
text:function() {return 'recipes://meishitupian.cn/produmethod/web?url='+encodeURIComponent(newUrl);}
});
clipboard.on('success', function(e) {
e.clearSelection();
});
location.href聽=聽'http://a.app.qq.com/o/simple.jsp?pkgname=com.douguo.recipe&g_f=991658&android_schema=recipes://meishitupian.cn/produmethod/web?url='+encodeURIComponent(newUrl);
}
}
},
upClickToken : function(vs,huodong_id) {
DouguoJSBridge.jsApi.getDevice(function(obj){
$.ajax({
type: 'post',
url: '/activity/cpzj/qtype/',
data: 'device='+obj['device']+'&mac='+obj['mac']+"&version="+obj['version']+"&channel="+obj['channel']+'&idfa='+obj['ifa']+"&imei="+obj['imei']+"&vs="+vs+"&id="+huodong_id+"&qtype=PUBT_RECIPE_BUTTON",
dataType: 'json',
async: false,
success: function (msg) {
}
});
});
},
getQueryString:function(name){
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null){
return unescape(r[2]);
} else {
return null;
}
},
getlogin :function(){
if(this.getQueryString('isapp') =='1'){
DouguoJSBridge.jsApi.login(function(user){
if(user.id) {
window.location.href = window.location.href + '&user_id=' + user.id;
}
});
}else{
window.location.href = "http://passport.www.meishitupian.cn/produmethod/login?ref=" + encodeURIComponent(window.location.href);
}
}
}
})();