- I wrote an H5 project, which is now online. I found that the callback can be completed normally and then the jump can be performed after sharing with friends by using mobile phones such as ip7 plus ip x. But if you share to the moments, the callback can not be completed normally after sharing (the sharing is successful in the moments). Has anyone encountered this strange problem?!?
- the relevant codes are attached below
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var bodyH = $("body").height();
var candyH = $(".candy").height();
var bottomH = $(".bottom").height();
var h = bodyH - (bodyH - candyH) - bottomH;
$(".candy .container").css("min-height",h+"px");
wx.config({!! $shareConfig["js_sdk_config"] !!});
wx.ready (function () {
//
var shareData = {
"imgUrl" : "{{$shareConfig["imgUrl"]}}", //
"link" : "{{$shareConfig["link"]}}", //
"desc" : "{{$shareConfig["desc"]}}", //
"title" : "{{$shareConfig["title"]}}", //
success : function () {
//
console.log("share success");
var _candy_id = "{{$candy->id ?? false}}";
var _user_id = "{{$user->id ?? false}}";
var _openid = "{{$user->openid ?? false}}";
var _post_json = {candy_id:_candy_id,user_id:_user_id,openid:_openid};
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $("meta[name="csrf-token"]").attr("content")
}
});
$.ajax({
type: "POST",
url: "{{url("/share")}}",
data: _post_json,
dataType: "json",
success: function(data){
if (data.code === "1024"){
document.getElementById("redirect").click();
}
}
});
}
};
wx.onMenuShareTimeline (shareData);
wx.onMenuShareAppMessage (shareData);
});
wx.error(function(res){
// configerror
// configdebugres
//SPA
alert("");
});
});
</script>
Note:
<body>
<a href="{{url("/signUp", array("abbreviation"=>$candy->abbreviation))}}" style="visibility: hidden;" id="redirect"></a>
</body>
document.getElementById("redirect").click();
this line of code is designed to cope with the problem that some phones cannot jump normally, and it is not difficult to use instead of windows.location.href in some scenarios.
Please give me your advice.