countdown.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. window.onload = function (ev) {
  2. init();
  3. }
  4. init = function () {
  5. getAttributeInfo();
  6. }
  7. getAttributeInfo = function () {
  8. var parameter = urlEncode(["SelectcountDown"]);
  9. $.ajax({
  10. type: "post",
  11. url: "/taiwan/php/index.php",
  12. data: {mode: parameter},
  13. dataType: "json",
  14. success: function (data) {
  15. if (data[0].length == 0 || data == -1) {
  16. var th = '<th colspan="9" scope="col" class="text-c f-20" style="padding: 50px 0;">暂无数据</th>';
  17. $("#warp").html(th);
  18. return;
  19. }
  20. printAttributeInfo(data);
  21. console.log(data);
  22. }
  23. });
  24. }
  25. printAttributeInfo = function (data) {
  26. var warp = $("#warp"),
  27. tr,
  28. href,
  29. title = "'查看商品信息'";
  30. warp.html("");
  31. for (var i = 0; i < data.length; i++) {
  32. href = "'product-add.html?pid=" + data[i].ProductId + "'";
  33. tr = $('<tr class="text-c">' +
  34. '<td>' + data[i].ProductId + '</td>' +
  35. '<td>' + data[i].ProductRemarks + '</td>' +
  36. '<td>' + data[i].ProductName + '</td>' +
  37. '<td>' + data[i].CountDown + '</td>' +
  38. '<td>' +
  39. '<a class="btn btn-primary radius td-button" href="/taiwan/goods.html?pid=' + data[i].ProductId + '">查看H5页面</>' +
  40. '<a class="btn btn-primary radius td-button" onclick="product_add(' + title + ',' + href + ')">查看产品信息</a>' +
  41. '</td></tr>');
  42. warp.append(tr);
  43. }
  44. $("#loading").css({"display": "none"});
  45. $("#warp").css({"display": "table-row-group"});
  46. }
  47. product_add = function (title, url) {
  48. var index = layer.open({
  49. type: 2,
  50. title: title,
  51. content: url
  52. });
  53. layer.full(index);
  54. }
  55. urlEncode = function (arr) {
  56. var i; //循环初始化
  57. for (i = 0; i < arr.length; i++) {
  58. arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
  59. }
  60. return arr.join();
  61. }