task.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function initPage() {
  2. initTaskList()
  3. }
  4. function getTaskList(t) {
  5. sendRequest(Server_Url.Task_List, "GET", {devNo: devNo, token: token}, t)
  6. }
  7. function initTaskList() {
  8. getTaskList(function (result) {
  9. var colorList = ["#fff", "#fff", "#fff", "#fff", "#fff"];
  10. resultStatus(result);
  11. for (var html = "", length = result.data.taskList.length, colorIndex = 0, index = 0; length > index; index++) {
  12. var color = "";
  13. var item = result.data.taskList[index];
  14. color = 5 > colorIndex ? colorList[colorIndex] : colorList[colorIndex % 5];
  15. html += '<section class="swiper-slide" style="background-color: ' + color + ';"><div class="swiper-scale show"><div class="bar-wrap" ><div class="bar"><span class="span1">长按识别二维码</span> <span class="span2"><span class="span3"><em class="c-red">' + ( item.word || "") + '</em></span></span></div></div>' +
  16. '<img class="swiper-img" data-id="' + item.id + '" src="' + item.qrcode + '" /></div></section>', colorIndex++
  17. }
  18. if (0 == colorIndex) {
  19. html += '<section class="swiper-slide"><div class="swiper-tips-offline iconfont icon-huanying common-color"></div></section>',
  20. colorIndex++
  21. }
  22. 1 == colorIndex && $("#pagination").addClass("hidden"), $("#taskList").html(html);
  23. var outW = $(".bar").width();
  24. //动态修改动画的时间
  25. $("#taskList .span3").each(function () {
  26. var that = $(this);
  27. var text = that.text();
  28. var time = text.length * 0.5;//一个文字0.5秒
  29. var inW = that.width();
  30. if (inW < outW) {
  31. that.css("animation", "none");
  32. }
  33. else {
  34. that.css("animation-duration", time + "s");
  35. }
  36. });
  37. {
  38. var d, c, p = colorIndex > 1;
  39. new Swiper(".swiper-container", {
  40. speed: 600,
  41. loop: p,
  42. slidesPerView: "auto",
  43. centeredSlides: !0,
  44. spaceBetween: 10,
  45. pagination: {
  46. el: '.swiper-pagination'
  47. },
  48. navigation: {
  49. nextEl: '.swiper-button-next',
  50. prevEl: '.swiper-button-prev',
  51. },
  52. touchRatio: .5
  53. })
  54. }
  55. })
  56. }
  57. function resultStatus(t) {
  58. if (1 != t.result) {
  59. toast(t.description);
  60. }
  61. }
  62. var devNo = getQueryString("devNo"),
  63. token = getQueryString("token");
  64. initPage();