wanghuidong 4 anos atrás
pai
commit
c9d802d782
2 arquivos alterados com 57 adições e 38 exclusões
  1. 21 4
      static/templates/chooseProduct.html
  2. 36 34
      static/templates/login.html

+ 21 - 4
static/templates/chooseProduct.html

@@ -72,7 +72,12 @@
 
     </style>
     <script>
-        productList()
+
+        var appid = getParam("appId");
+        if (appid!=""){
+            $("#appId").val(appid);
+        }
+        productList();
 
         function productList() {
             $.ajax({
@@ -152,15 +157,27 @@
                 success: function (r) {
                     var a = JSON.stringify(r)
                     if (r.code == 0) {
-                        window.location.reload();
+                        $(".result").html(a);
                         timeoutId = setTimeout(function () {
-                            $(".result").html(a);
-                        }, 300);
+                            window.location.reload();
+                        }, 2000);
                     } else {
                         $(".result").html(a);
                     }
                 }
             })
         }
+
+        // 获取上个页面传来的参数
+        function getParam(name) {
+            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+            var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
+            var context = "";
+            if (r != null)
+                context = r[2];
+            reg = null;
+            r = null;
+            return context == null || context == "" || context == "undefined" ? "" : context;
+        }
     </script>
 {{end}}

+ 36 - 34
static/templates/login.html

@@ -104,18 +104,18 @@
                             $("#tableId").show();
                             for (var i = 0; i < r.data.length; i++) {
                                 var item = r.data[i];
-                                str += '<tr onclick="userProductList(this)">';
-                                str += '<td style="width: 50px">' + (i + 1) + '</td>';
-                                str += '<td style="width: 100px">' + item.name + '</td>';
-                                str += '<td style="width: 200px">' + item.app_id + '</td>';
-                                str += '<td style="width: 100px">' + item.secret_key + '</td>';
-                                str += '<td style="width: 100px">' + item.phone + '</td>';
-                                str += '<td style="width: 100px">' + item.money + '</td>';
-                                str += '<td class="handle" style="width: 100px"><a href="/page/userRecharge?appId='+ item.app_id +'">充值</a><a href="/page/chooseProductPage">购买产品</a></td>';
+                                str += "<tr >";
+                                str += "<td style='width: 50px'>" + (i + 1) + "</td>";
+                                str += "<td style='width: 100px'><a href='javascript:void(0);' style='pointer:hand;' onclick=\"userProductList('" + item.app_id + "','" + item.secret_key + "')\">" + item.name + "</a></td>";
+                                str += "<td style='width: 200px'>" + item.app_id + "</td>";
+                                str += "<td style='width: 100px'>" + item.secret_key + "</td>";
+                                str += "<td style='width: 100px'>" + item.phone + "</td>";
+                                str += "<td style='width: 100px'>" + item.money + "</td>";
+                                str += "<td class='handle' style='width: 100px'><a href=\"/page/userRecharge?appId=" + item.app_id + "\">充值</a><a href=\"/page/chooseProductPage?appId="+item.app_id+"\">购买产品</a></td>";
 
-                                str += '</tr>';
+                                str += "</tr>";
                             }
-                            $('.box').html(str);
+                            $(".box").html(str);
                         } else {
                             $(".tableDiv").html("还没有客户,请添加客户信息");
                         }
@@ -126,13 +126,13 @@
             })
         }
 
-        function userProductList(obj, k) {
-            var appId = $(obj).find("td:eq(2)").text();
-            var key = $(obj).find("td:eq(3)").text();
-            console.log(key)
-            var param = {
+        function userProductList(appId, key) {
+            //var appId = $(obj).find("td:eq(2)").text();
+            //var key = $(obj).find("td:eq(3)").text();
+            console.log(appId, "|", key)
+            let param = {
                 "appId": appId
-            }
+            };
             $.ajax({
                 url: "/manage/user/userProductList",
                 type: "POST",
@@ -141,39 +141,41 @@
                 data: param,
                 success: function (r) {
                     if (r.code === 0) {
-                        var str = ""
+                        var str = "";
                         console.log(r.data)
                         if (r.data.length != 0) {
                             $(".nodata").html("");
                             $(".userProductDiv").show();
-                            $(".userProTbody").html("")
+                            $(".userProTbody").html("");
                             for (var i = 0; i < r.data.length; i++) {
                                 var item = r.data[i];
-                                str += '<tr>';
-                                str += '<td>' + (i + 1) + '</td>';
-                                str += '<td>' + item.product_id + '</td>';
-                                str += '<td>' + item.app_id + '</td>';
-                                str += '<td>' + item.left_num + '</td>';
+                                str += "<tr>";
+                                str += "<td>" + (i + 1) + "</td>";
+                                str += "<td>" + item.product_id + "</td>";
+                                str += "<td>" + item.app_id + "</td>";
+                                str += "<td>" + item.left_num + "</td>";
                                 if (item.cost_model == 0) {
-                                    str += '<td>扣量</td>';
+                                    str += "<td>扣量</td>";
                                 } else {
-                                    str += '<td>扣余额</td>';
+                                    str += "<td>扣余额</td>";
                                 }
                                 if (item.interface_status == 0) {
-                                    str += '<td>开启</td>';
+                                    str += "<td>开启</td>";
                                 } else {
-                                    str += '<td>关闭</td>';
+                                    str += "<td>关闭</td>";
                                 }
-                                str += '<td>' + item.call_times_limit_day + '</td>';
-                                str += '<td>' + item.data_num_limit_one_times + '</td>';
-                                if (item.product_id == 1000 || item.product_id == 1001) {
-                                    str += '<td class="handle" style="width: 100px"><a href="/page/projectListPage?appId=' + appId + '&key=' + key + ' " >测试接口</a></td>';
+                                str += "<td>" + item.call_times_limit_day + "</td>";
+                                str += "<td>" + item.data_num_limit_one_times + "</td>";
+                                if (item.product_id === 1000 || item.product_id === 1001) {
+                                    str += "<td class='handle' style='width: 100px'><a href=\"/page/projectListPage?appId=" + appId + "&key=" + key + "\" >测试接口</a></td>";
                                 } else {
-                                    str += '<td class="handle" style="width: 100px"><a href="/page/projectListDetail?appId=' + appId + '&key=' + key + ' " >测试接口</a></td>';
+                                    str += "<td class='handle' style='width: 100px'><a href=\"/page/projectListDetail?appId=" + appId + "&key=" + key + "\"  >测试接口</a></td>";
                                 }
-                                str += '</tr>';
+                                str += "</tr>";
                             }
-                            $(".userProTbody").html(str);
+                            console.log(str);
+                            let trBody = $(str);
+                            $(".userProTbody").append(trBody);
                         } else {
                             $(".userProductDiv").hide();
                         }