Kaynağa Gözat

解决ios页面无法请求问题

huangxiaojing 4 yıl önce
ebeveyn
işleme
1889944c1e
1 değiştirilmiş dosya ile 42 ekleme ve 73 silme
  1. 42 73
      microserviceUserH5/vcloud/invite.html

+ 42 - 73
microserviceUserH5/vcloud/invite.html

@@ -95,84 +95,53 @@
             btnMsg = '复制邀请链接'
         }
         $('#recv_btn').append(btnMsg)
-        if (isiOS) {
-            $.ajax({
-                url: baseUrl + '/api/user/v3/invitation/client/getInvitationInfo',
-                type: 'get',
-                headers: {
-                    'Authorization': id  //id
-                },
-                contentType: "application/json",
-                dataType: 'json',
-                cache: false,
-                success: function (res) {
-                    var jsonStr = JSON.stringify(res.data)
-                    var jsonObj = JSON.parse(jsonStr)
-                    // WKWebView使用
-                    // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
-                    try {
-                        getMessage(jsonObj);
-                    } catch (error) {
-                        console.log(error)
-                    }
-                    try {
-                        window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
-                    } catch (error) {
-                        console.log(error)
-                    }
-                }
-            })
-        } else if (isAndroid) {
-            window.native.onClikWebView()
-        } else {
-            $.ajax({
-                url: baseUrl + '/api/user/v3/invitation/client/getInvitationInfo',
-                type: 'get',
-                headers: {
-                    'Authorization': id  //id
-                },
-                contentType: "application/json",
-                dataType: 'json',
-                cache: false,
-                success: function (res) {
-                    $('#invitationCode').text(res.data.invitationCode)
-                    //加载数据
-                    $('#passwordCopy').val($('#invitationCode').text());
+        $.ajax({
+            url: baseUrl + '/api/user/v3/invitation/client/getInvitationInfo',
+            type: 'get',
+            headers: {
+                'Authorization': id  //id
+            },
+            contentType: "application/json",
+            dataType: 'json',
+            cache: false,
+            success: function (res) {
+                $('#invitationCode').text(res.data.invitationCode)
+                //加载数据
+                $('#passwordCopy').val($('#invitationCode').text());
 
-                    //复制按钮
-                    $('.btn-code-copy').on('click', function () {
-                        var input = document.getElementById("passwordCopy");
-                        // 选中文本
-                        input.select();
-                        // 执行浏览器复制命令
-                        document.execCommand("copy");
-                        toastr.error('复制成功', 0)
-                    });
+                //复制按钮
+                $('.btn-code-copy').on('click', function () {
+                    var input = document.getElementById("passwordCopy");
+                    // 选中文本
+                    input.select();
+                    // 执行浏览器复制命令
+                    document.execCommand("copy");
+                    toastr.error('复制成功', 0)
+                });
 
-                    if (res.data.friendList.length > 0) {
-                        var str = '<ul class="goodFriend-title-list"><li class="tal">被邀请好友帐号</li><li class="tac">获时长数(小时)</li><li class="tar">邀请时间</li></ul>'
-                        for (var i = 0; i < res.data.friendList.length; i++) {
-                            var phone = res.data.friendList[i].newPhone
-                            var inviteMsg = res.data.friendList[i].duration
-                            var registerTime = res.data.friendList[i].createTime
-                            var nPhone = phone.substr(0, 3) + '****' + phone.substring(7, 11)
-                            str += '<div class="goodFriend-item">'
-                            str += '<span class="tal">' + nPhone + '</span>'
-                            str += Number(inviteMsg) && inviteMsg > 0 ? '<span class="tac cF04646">' + inviteMsg + '</span>' : '<span class="tac">' + inviteMsg + '</span>'
-                            str += '<span class="tar">' + registerTime + '</span>'
-                            str += '</div>';
-                        }
-                    } else if (res.data.friendList.length === 0) {
-                        str = '<div class="no-data">还没有邀请到好友哦~</div>'
+                if (res.data.friendList.length > 0) {
+                    var str = '<ul class="goodFriend-title-list"><li class="tal">被邀请好友帐号</li><li class="tac">获时长数(小时)</li><li class="tar">邀请时间</li></ul>'
+                    for (var i = 0; i < res.data.friendList.length; i++) {
+                        var phone = res.data.friendList[i].newPhone
+                        var inviteMsg = res.data.friendList[i].duration
+                        var registerTime = res.data.friendList[i].createTime
+                        var nPhone = phone.substr(0, 3) + '****' + phone.substring(7, 11)
+                        str += '<div class="goodFriend-item">'
+                        str += '<span class="tal">' + nPhone + '</span>'
+                        str += Number(inviteMsg) && inviteMsg > 0 ? '<span class="tac cF04646">' + inviteMsg + '</span>' : '<span class="tac">' + inviteMsg + '</span>'
+                        str += '<span class="tar">' + registerTime + '</span>'
+                        str += '</div>';
                     }
-                    $('#goode').append(str);
-                }, 
-                error: function () {
+                } else if (res.data.friendList.length === 0) {
                     str = '<div class="no-data">还没有邀请到好友哦~</div>'
-                    $('#goode').append(str)
                 }
-            })
-        }
+                $('#goode').append(str);
+            }, 
+            error: function () {
+                str = '<div class="no-data">还没有邀请到好友哦~</div>'
+                $('#goode').append(str)
+            }
+        })
 
         $("#recv_ipt").bind('input propertychange', function (e) {
             var ipt_phones = $('#recv_ipt').val();