my_gift.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {extend name="public/container"}
  2. {block name="title"}我的赠送{/block}
  3. {block name="head_top"}
  4. <style>
  5. body {
  6. background-color: #f5f5f5;
  7. }
  8. .loading {
  9. font-size: .4rem;
  10. text-align: center;
  11. color: #999;
  12. }
  13. .loaded {
  14. font-size: .28rem;
  15. line-height: .72rem;
  16. text-align: center;
  17. color: #999;
  18. }
  19. .nothing {
  20. position: absolute;
  21. top: 30%;
  22. left: 50%;
  23. width: 4rem;
  24. height: 4rem;
  25. -webkit-transform: translate(-50%, -50%);
  26. transform: translate(-50%, -50%);
  27. }
  28. </style>
  29. {/block}
  30. {block name="content"}
  31. <div v-cloak id="app">
  32. <div class="gift-given">
  33. <div class="main">
  34. <ul v-if="updateGiftList.length" class="list">
  35. <li v-for="(item, index) in updateGiftList" :key="index" class="item">
  36. <div class="head">
  37. <div class="name">{{ item.is_draw ? '赠送成功' : '未赠送' }}</div>
  38. <a :href="item.path" :class="{ button: !item.is_draw }" class="link">
  39. {{ item.is_draw ? '领取人:' + item.gift_user.nickname : '去赠送' }}
  40. </a>
  41. </div>
  42. <div class="content">
  43. <div class="image">
  44. <img :src="item.image" class="img">
  45. </div>
  46. <div class="text">
  47. <div class="name">{{ item.title }} </div>
  48. <div class="money">¥<span class="number">{{ item.money }}</span></div>
  49. </div>
  50. </div>
  51. </li>
  52. </ul>
  53. <template v-if="giftList.length">
  54. <div v-if="loaded && page >= 2" class="loaded">已全部加载</div>
  55. </template>
  56. <template v-else>
  57. <div v-show="loading" class="loading">
  58. <span class="fa fa-spinner"></span>
  59. </div>
  60. <div v-if="!loading">
  61. <img class="nothing" src="/wap/first/zsff/images/no_data_available.png">
  62. </div>
  63. </template>
  64. </div>
  65. </div>
  66. <shortcut></shortcut>
  67. </div>
  68. <script>
  69. require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, store, $h) {
  70. new Vue({
  71. el: '#app',
  72. data: {
  73. appear: true,
  74. giftList: [],
  75. loaded: false,
  76. loading: false,
  77. page: 1,
  78. limit: 10
  79. },
  80. computed: {
  81. updateGiftList: function () {
  82. var that = this;
  83. return this.giftList.map(function (value) {
  84. value.path = value.is_draw ? $h.U({ c: 'special', a: 'gift_receive', p: { orderId: value.order_id } }) : $h.U({ c: 'special', a: 'gift_special', q: { orderId: value.order_id } });
  85. return value;
  86. });
  87. }
  88. },
  89. created: function () {
  90. this.getMyGiftList();
  91. },
  92. mounted: function () {
  93. $h.EventUtil.listenTouchDirection(document, function () {
  94. this.loading == false && this.getMyGiftList();
  95. }.bind(this), false);
  96. },
  97. methods: {
  98. getMyGiftList: function () {
  99. var that = this;
  100. if (this.loading) return;
  101. if (this.loaded) return;
  102. this.loading = true;
  103. store.baseGet($h.U({ c: 'my', a: 'get_order_list', q: { type: 1, page: this.page, limit: this.limit } }), function (res) {
  104. var list = res.data.data.list;
  105. var giftList = $h.SplitArray(list, that.giftList);
  106. that.loaded = list.length < that.limit;
  107. that.page = res.data.data.page;
  108. that.loading = false;
  109. that.$set(that, 'giftList', giftList);
  110. }, function (res) {
  111. that.loading = false;
  112. });
  113. },
  114. }
  115. })
  116. })
  117. </script>
  118. {/block}