Here you'll review and document some of the issues you've encountered in your app project, and what you need to be aware of. If there are errors please point out, humbly ask for advice!
First, we use PhoneGap (Cordova) to invoke the underlying plug-in to implement Ios,android's set of compatibility.
1.
As a mobile-based adaptation of the issue on a focus, ios,android DPR different display of content is different, so the use of the flexible solution, using REM to adapt.
;(function(Win, Lib) {varDoc =win.document; varDocel =doc.documentelement; varMetael = Doc.queryselector (' meta[name= "viewport"]); varFlexibleel = Doc.queryselector (' meta[name= "flexible"]); varDPR = 0; varScale = 0; varTid; varFlexible = Lib.flexible | | (lib.flexible = {}); if(Metael) {Console.warn (' Scaling is set according to the existing META tag '); varMatch = Metael.getattribute (' content '). Match (/initial\-scale= ([\d\.] +)/); if(match) { scale= Parsefloat (match[1]); DPR= parseint (1/Scale ); } } Else if(flexibleel) {varContent = Flexibleel.getattribute (' content '); if(content) {varINITIALDPR = Content.match (/initial\-dpr= ([\d\.] +)/); varMAXIMUMDPR = Content.match (/maximum\-dpr= ([\d\.] +)/); if(INITIALDPR) {DPR= Parsefloat (initialdpr[1]); Scale= Parsefloat ((1/DPR). toFixed (2)); } if(MAXIMUMDPR) {DPR= Parsefloat (maximumdpr[1]); Scale= Parsefloat ((1/DPR). toFixed (2)); } } } if(!DPR &&!)Scale ) { varIsandroid = Win.navigator.appVersion.match (/android/gi); varIsiphone = Win.navigator.appVersion.match (/iphone/gi); varDevicepixelratio =Win.devicepixelratio; if(isiphone) {//iOS, for 2 and 3 screen, with twice times the scheme, the remaining 1 time times the scheme if(Devicepixelratio >= 3 && (!DPR | | DPR >= 3) ) {DPR= 3; } Else if(Devicepixelratio >= 2 && (!DPR | | DPR >= 2) ) {DPR= 2; } Else{DPR= 1; } } Else { //Other devices, still using 1 time times the schemeDPR = 1; } Scale= 1/DPR; } docel.setattribute (' DATA-DPR ', DPR); if(!Metael) {Metael= Doc.createelement (' meta '); Metael.setattribute (' Name ', ' viewport '); Metael.setattribute (' Content ', ' initial-scale= ' + scale + ', maximum-scale= ' + scale + ', minimum-scale= ' + scale + ', User-scalable=no '); if(docel.firstelementchild) {docEl.firstElementChild.appendChild (Metael); } Else { varWrap = doc.createelement (' div '); Wrap.appendchild (Metael); Doc.write (wrap.innerhtml); } } functionRefreshrem () {varwidth =docel.getboundingclientrect (). width; if(Width/dpr > 540) {width= 540 *DPR; } varREM = WIDTH/10; DocEl.style.fontSize= rem + ' px '; Flexible.rem= Win.rem =REM; } win.addeventlistener (' Resize ',function() {cleartimeout (TID); Tid= SetTimeout (Refreshrem, 300); }, false); Win.addeventlistener (' Pageshow ',function(e) {if(e.persisted) {cleartimeout (TID); Tid= SetTimeout (Refreshrem, 300); } }, false); if(Doc.readystate = = = ' complete ') {doc.body.style.fontSize= * DPR + ' px '; } Else{Doc.addeventlistener (' Domcontentloaded ',function(e) {doc.body.style.fontSize= * DPR + ' px '; }, false); } refreshrem (); FLEXIBLE.DPR= WIN.DPR =DPR; Flexible.refreshrem=Refreshrem; flexible.rem2px=function(d) {varval = parsefloat (d) * This. rem; if(typeofD = = = ' String ' && d.match (/rem$/) ) {Val+ = ' px '; } returnVal; } Flexible.px2rem=function(d) {varval = parsefloat (d)/ This. rem; if(typeofD = = = ' String ' && d.match (/px$/) ) {Val+ = ' rem '; } returnVal; }}) (Window, window[' Lib ' | | (window[' lib '] = {}));
The following is a reference to find the source code, after a series of calculations, the HTML root node will be added DPR and font-size.
CSS notation: Both use REM, when the design is IP6 as the benchmark, will size/75.
2.
It is sometimes necessary to determine the type of device during the project:
varBrowser ={versions:function() { varU =navigator.useragent, App=navigator.appversion; return{//Mobile Terminal browser version informationTrident:u.indexof (' Trident ') >-1,//IE kernelPresto:u.indexof (' presto ') >-1,//Opera KernelWebkit:u.indexof (' AppleWebKit ') >-1,//Apple, Google kernelGecko:u.indexof (' Gecko ') >-1 && u.indexof (' khtml ') = =-1,//Firefox kernelMobile:!! U.match (/applewebkit.*mobile.*/),//whether it is a mobile terminalIos:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/),//iOS terminalAndroid:u.indexof (' Android ') >-1 | | U.indexof (' Linux ') >-1,//Android Terminal or UC browserIphone:u.indexof (' IPhone ') >-1,//whether it's an iphone or Qqhd browserIpad:u.indexof (' IPad ') >-1,//whether ipadWebapp:u.indexof (' Safari ') = =-1//whether the web should program, no head with the bottom }; } (), Language: (Navigator.browserlanguage||navigator.language). toLowerCase ()}
The Navigator object belongs to the BOM, which identifies the fact criteria for the client browser, each with its own set of properties.
Navigator.useragent: The user agent string for the browser.
Navigator.appversion: Version information for the browser.
3.
1). Since the format for generating the QR code is base64. So when we're going to show the QR code, we need to format it in IMG.
2). Password submission in the background before all need to MD5, it is best to encrypt a bit.
3). There are cross-domain issues on the mobile side.
Using Cors in the background program, set the Access-control-allow-origin header to set the wildcard character, in the permission restrictions.
4.
Using Iscroll4.js to pull up the refresh drop-down load, when the sliding area dynamically add more than one data, sliding the area will be a lag, jitter situation.
My solution is to recalculate the height of the sliding area using Wrapper.refresh () after each dynamic addition of the data to change the DOM.
There is another situation:
is when the finger from the sliding area has been dragged to the outside, there will be stuck in the situation, will not rebound.
The solution is really iscroll.js 490 lines to add a judgment, (if there is a problem please point out, a bit forgot to change the place)
if (point.pagey<0 | | point.pagey>document.body.clientHeight) { this. Options.onscrollend (); This . _end (e); This . _startani (e); That._unbind (Move_ev, window); } Else { }
5.
Before doing a big carousel of activity page, the information of the prize, the picture is obtained by request, the prize picture is placed in each fast area of the big turntable, whether winning or not in which prize is returned by the background interface, and then control the stop position of the big turntable.
My idea is to put the value of the same attribute of each prize into the array. Gets the ID of the single prize, gets its index in the array, and controls the angle of rotation through the index.
Encounter several problems in the process 1. Put the picture on the canvas 2. The picture cannot be displayed all.
1. How to put a picture on the canvas: DrawImage (), which can draw an image, canvas, or video on the canvas.
2. The picture cannot be displayed all the reason is that when the picture is not fully loaded before the depiction, resulting in the display is not, so you need to complete the picture after the completion of the description.
functionDraw () {varCanvas = document.getElementById ("Wheelcanvas"); Canvas.width= 640; Canvas.height= 640; if(canvas.getcontext) {//calculates the circumference angle according to the number of prizes varARC = Math.PI/(TURNPLATE.RESTARAUNTS.LENGTH/2); varCTX = Canvas.getcontext ("2d"); //empties a rectangle within a given rectangleCtx.clearrect (0, 0, 640, 640); Ctx.strokestyle= "#FFBE04"; //Ctx.font = ' 30px Microsoft yahei ';$.each (turnplate. Imgurl,function(key, value) {varIMG =NewImage (); IMG.SRC=value; Img.onload=function() {//to perform a depiction after the picture has finished loadingdrawtrails ()}functiondrawtrails () {varAngle = Turnplate.startangle + key *arc; Ctx.fillstyle=Turnplate.colors[key]; Ctx.beginpath (); //Arc (x,y,r, start angle, end angle, drawing direction) method to create an arc/curve (for creating a circle or part of a circle)Ctx.arc (Turnplate.outsideradius, angle, angle + arc,false); Ctx.arc (Turnplate.insideradius, angle + arc, angle,true); Ctx.stroke (); Ctx.fill (); //lock Canvas (in order to save the previous canvas state)Ctx.save (); //Ctx.fillstyle = "#FFFFFF";//Font Color //var text = turnplate.restaraunts[i]; //var line_height = 17;//font line spacing //Translate method remap the (0,0) position on the canvasCtx.translate (+ math.cos (angle + arc/2) * Turnplate.textradius, + math.sin (angle + ARC/2) *Turnplate.textradius); //rotate method to rotate the current drawingCtx.rotate (angle + ARC/2 + MATH.PI/2); Ctx.drawimage (IMG,-35,-20, 80, 80)//set the position and size of the pictureCtx.restore (); } }); }}
Front-end issues with mobile