Share Configuration Reference Scripts
- Jquery/zepto
- Jweixin-1.0.0.js (//st02.chrstatic.com/themes/event/campaign/pofeng/common/js/jweixin-1.0.0.js)
- Appinteractive.js (//st02.chrstatic.com/themes/event/campaign/pofeng/common/js/appinteractive.js)
How to use
-
The above script is introduced sequentially in the subsequent execution of JS:
window.chrconfig = { "isShare": true, "shares": { "shareTitle": "分享标题", "shareContent": "分享内容", "shareImageUrl": "图片url", "shareUrl": "分享出去的链接" } }; var active = new window.AppInteractive(chrconfig); active.wxShare();
- Precautions
- If your phone is connected to your computer and your computer is configured with host, you won't be able to access the HTTPS protocol link within your phone, and if you need to configure sharing within the app, the image URL must be an HTTPS protocol. Therefore, in the test, the picture loss situation is difficult to avoid.
- In iOS, if the URL protocol for this page is HTTPS, the sharing configuration will not take effect. So the link to the share should be changed to the HTTP protocol.
- This page must be a link to the domain name (cannot be IP, so development should pay attention to avoid stepping on the pit).
App configuration sharing
- Refer to scripts and how to use the same, if you do not need to share, you can delete jweixin-1.0.0.js and
active.wxShare();
- In Android app, if sharing a picture size is too large, it may cause the problem of loading the picture to fail.
- When sharing to QQ, because the QQ version is different, may appear to share out is the picture and the text separates two messages the situation.
Depending on the platform, pull up the native job/company page or Web position/company page implementation
var apitype = 0; Judge the environment if (!! Window.webkit &&!! Window.webkit.messageHandlers &&!! Window.webkit.messageHandlers.chinahr) {apitype = 2;//ios5.4.2+} else {if (!! Window.chinahr) {apitype = 1; Andriod and iOS low version} else {apitype = 0;//non-app Environment}} if (Apitype!== 0) {//app Environment $ (' a '). On (' click ', Function (e) {var] href = $ (this). attr (' href '); E.preventdefault (); if (Href.indexof (' job ') >-1) {//position var id = href.split (' job/') [1].split ('. html ') [0]; var message = "chinahr://customer/job?id=" + ID + ""; if (Apitype = = 2) {window.webkit.messageHandlers.chinahr.postMessage (message); } else if (Apitype = = 1) {window.chinahr.gotoPage_callback (message, ""); } } else if (Href.indexof (' company ') >-1) {//corporate var id = href.split (' Compa ny/') [1].split ('. html ') [0]; var message = "chinahr://customer/company?id=" + ID + ""; if (Apitype = = 2) {window.webkit.messageHandlers.chinahr.postMessage (message); } else if (Apitype = = 1) {window.chinahr.gotoPage_callback (message, ""); } } }); }
In-app WebView development Debug Debugging Method:
- Place the project on the server (local/test), replace the rule with the Fiddler, Charlse, and other grab tools, replacing any of the WebView page requests in the app with the page you want to test. Note: The HTTPS certificate needs to be installed on the mobile side to avoid the replacement rule failure, as described in:
The Grab kit tool configures HTTPS.
- Put the project on the test server, find the mobile QA classmate to configure the app test environment, through the test package portal to enter the Web page.
Precautions:
- The app caches the WebView, can modify the version number, or clears the app cache.
- WebView Adaptive Viewport (viewport) scaling is problematic (can only be zoomed in and not scaled down), and it is not recommended to use the viewport scaling strategy for WebView page development.
Summary of mobile development experience