亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - When WeChat h5 sends graphic information, some devices do not respond when clicking the "Send" button. The problem is difficult to reproduce. How can I find the possible problem points?
天蓬老師
天蓬老師 2017-06-28 09:23:19
0
2
1051

As shown in the picture above, after entering the content and adding pictures, click "Publish". Some devices do not respond. I have tried it on the test machine in hand and on my colleagues' mobile phones. The problem cannot be reproduced. Most of the mobile phones reported for failure are IOS6 and above. on WeChat

Backend colleagues reported that the frontend did not submit data (no logs were submitted), and the backend factors were temporarily excluded

Now we need to start with the front-end code to find the problem. How do I start testing the code?

Currently we have not added front-end exception monitoring

Approximate implementation ideas:

1. An object is defined to save the information of uploaded images

var uploads = {
    localId: [],
    serverId: []
};

2. When the user selects an image, call wx.chooseImage on the WeChat side, stuff the returned results (res.localIds) into (uploads.localId), cache them, and display the results on the page (Figure 1 above)

wx.chooseImage({
    count: 9,
    success: function (res) {
        for(var i=0; i<res.localIds.length; i++) {
            var _key = res.localIds[i];
            if(!selectedImageMap[_key]) {
                wx_uploads_localIds.push(_key);
                selectedImageMap[_key] = true; //防止圖片重復(fù)
            }
        }
        //頁(yè)面本地緩存,選擇班級(jí)會(huì)跳轉(zhuǎn)到另外一個(gè)頁(yè)面,需要將選擇的圖片信息緩存
        setPageSessionInfo();
        //修改標(biāo)題
        setTitle('動(dòng)態(tài)編輯');
        //再頁(yè)面上展示已選圖片
        _showSelectedPic();
        return false;
    }
});

3. Click "Publish", call wx.uploadImage to upload the image, stuff the returned serverId into (uploads.serverId) and cache it, and then submit uploads.serverIds in batches

//上傳處理
function _uploadProccess() {
    var _localId = uplods.localId.shift();
    wx.uploadImage({
        localId: _localId, // 需要上傳的圖片的本地ID,由chooseImage接口獲得
        isShowProgressTips: 1,// 默認(rèn)為1,顯示進(jìn)度提示
        success : function(res){
            var serverId = res.serverId; // 返回圖片的服務(wù)器端ID
            uplods.serverId.push(serverId);
            if(uplods.localId.length == 0) {
                //上傳隊(duì)列清空, 調(diào)用發(fā)送方法
            } else {
                _uploadProccess(); //成功繼續(xù)上傳且圖片為上傳完成
            }
        },
        fail : function(){
            //提示失敗
            return false;
        }
    });
}
天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~

reply all(2)
代言

If you can try to process the pictures uploaded by users in advance, because some pictures are very large, I have not used WeChat's upload picture API. I made the input tag myself before. If the picture is large in size, the program will die after uploading. Later, after the user uploaded it to the front end, the image was processed and sent to the back end, and there was no problem.

女神的閨蜜愛(ài)上我

Seeing that you are calling the WeChat interface, and the errors reported are all iOS, please pay attention to the WeChat js library version quoted. Generally speaking, it is 1.0.0, but in fact it has been updated to 1.2.0, and the new version The library is updated with content related to the iOS client WKWebview kernel~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template