combination.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. {extend name="public/container"}
  2. {block name="title"}拼团列表{/block}
  3. {extend name="public/container"}
  4. {block name="content"}
  5. <div class="buyspell-list product-sort" id="product-list">
  6. <div class="search-wrapper" style=" padding: 0.12rem 0.2rem;">
  7. <form action="" method="post" @submit.prevent="search">
  8. <input type="text" placeholder="商品搜索: 请输入商品关键词" ref='search'>
  9. </form>
  10. </div>
  11. <div class="price-select flex">
  12. <div class="item" @click='order("default")' :class='{on:where.on=="default"}'>默认</div>
  13. <div class="item"
  14. @click='order("price")'
  15. :class='{"selected-up":where.on=="price" && where.price==1,"selected-down":where.on=="price" && where.price==2,"on":where.on=="price"}'
  16. >价格<i class="icon"></i></div>
  17. <div class="item"
  18. @click='order("sales")'
  19. :class='{"selected-up":where.on=="sales" && where.sales==1,"selected-down":where.on=="sales" && where.sales==2,"on":where.on=="sales"}'
  20. >销量<i class="icon"></i></div>
  21. <div class="item" @click='order("people")' :class="{on:where.on=='people'}">人气</div>
  22. </div>
  23. <div class="bslist-box" v-cloak="">
  24. <div class="bs-item flex" v-for='item in list.data'>
  25. <div class="picture">
  26. <img :src="item.image" :alt="item.title">
  27. </div>
  28. <div class="bs-item-info flex">
  29. <div class="info-title">{{item.title}}</div>
  30. <div class="count-wrapper">
  31. <span class="price">¥{{item.price}}</span>
  32. <span class="old-price">¥{{item.product_price}}</span>
  33. <span class="count">已拼{{item.sales}}单</span>
  34. </div>
  35. <a class="people-num" :href="'combination_detail/id/'+item.id">
  36. <span class="numbers">{{item.people}}人团</span>
  37. <span class="peo-txt">去开团</span>
  38. <i class="index-icon people-icon"></i>
  39. </a>
  40. </div>
  41. </div>
  42. <p class="loading-line" v-show="load == false && list.loading==true"><i></i>正在加载中<i></i></p>
  43. <p class="loading-line" v-show='load == true' @click="getList"><i></i>点击加载<i></i></p>
  44. <p class="loading-line" v-show='load == false && list.loadEnd==true'><i></i>没有更多了<i></i></p>
  45. </div>
  46. </div>
  47. <script type="text/javascript">
  48. var product_list =<?php echo json_encode($list);?>;
  49. requirejs(['vue', 'store', 'helper'], function (Vue, storeApi, $h) {
  50. new Vue({
  51. el: "#product-list",
  52. data: {
  53. load: true,
  54. list: {
  55. loading: false,
  56. loadEnd: false,
  57. data: product_list
  58. },
  59. where: {
  60. page: 1,
  61. search: '',
  62. people: 0,
  63. sales: 0,
  64. price: 0,
  65. default: 0,
  66. on: 'default',
  67. key: false
  68. },
  69. keyorder: ''
  70. },
  71. methods: {
  72. search: function (e) {
  73. e.preventDefault();
  74. this.list.loadEnd = false;
  75. var search = this.$refs.search.value;
  76. if (this.$refs.search.value == '') {
  77. this.order('default');
  78. return;
  79. } else if (this.$refs.search.value == this.keyorder) {
  80. this.list.loadEnd = true;
  81. return;
  82. } else {
  83. this.keyorder = search;
  84. }
  85. if (search != '') {
  86. this.where.search = search;
  87. }
  88. this.where.on = 'search';
  89. this.where.sales = 0;
  90. this.where.price = 0;
  91. this.where.page = 0;
  92. this.where.default = 0;
  93. this.where.people = 0;
  94. this.where.key = true;
  95. this.getList();
  96. },
  97. order: function (info) {
  98. this.list.loadEnd = false;
  99. if (info == 'people') {
  100. if (this.where.people == 1) {
  101. if (this.list.data.length < 4) {
  102. this.list.loadEnd = true;
  103. }
  104. return;
  105. }
  106. this.where.on = info;
  107. this.where.page = 0;
  108. if (this.where.people == 0) {
  109. this.where.people = 1;
  110. } else {
  111. this.where.people = 0;
  112. }
  113. this.where.sales = 0;
  114. this.where.price = 0;
  115. this.where.default = 0;
  116. } else if (info == 'sales') {
  117. this.where.on = info;
  118. this.where.page = 0;
  119. if (this.where.sales == 0 || this.where.sales == 2) {
  120. this.where.sales = 1;
  121. } else {
  122. this.where.sales = 2;
  123. }
  124. this.where.people = 0;
  125. this.where.price = 0;
  126. this.where.default = 0;
  127. } else if (info == 'price') {
  128. this.where.on = info;
  129. this.where.page = 0;
  130. if (this.where.price == 0 || this.where.price == 2) {
  131. this.where.price = 1;
  132. } else {
  133. this.where.price = 2;
  134. }
  135. this.where.people = 0;
  136. this.where.sales = 0;
  137. this.where.default = 0;
  138. } else if (info == 'default') {
  139. if (this.where.default == 1) {
  140. if (this.list.data.length < 4) {
  141. this.list.loadEnd = true;
  142. }
  143. return false;
  144. }
  145. this.$refs.search.value = '';
  146. this.where.search = '';
  147. this.keyorder = '';
  148. this.where.on = info;
  149. this.where.page = 0;
  150. this.where.default = 1;
  151. this.where.search = '';
  152. this.where.people = 0;
  153. this.where.sales = 0;
  154. }
  155. this.where.key = true;
  156. this.getList();
  157. },
  158. getList: function () {
  159. var this_ = this;
  160. this_.list.loading = true;
  161. this_.load = false;
  162. storeApi.basePost('{:url(\'wap/store/get_list\')}',
  163. {
  164. 'where': this_.where
  165. },
  166. function (msg) {
  167. this_.list.loading = false;
  168. var _length = msg.data.data.list.length;
  169. if (_length == 0) {
  170. if (this_.keyorder != '' && this_.where.key == true) {
  171. this_.list.data = [];
  172. } else {
  173. this_.list.loadEnd = true;
  174. }
  175. } else {
  176. if (this_.where.key == true && this_.where.on != '' && this_.where.page == 0) {
  177. this_.list.data = msg.data.data.list;
  178. } else {
  179. for (var i = 0; i < _length; i++) {
  180. this_.list.data.push(msg.data.data.list[i]);
  181. }
  182. }
  183. this_.load = true;
  184. }
  185. if (_length < 4) {
  186. this_.load = false;
  187. this_.list.loadEnd = true;
  188. }
  189. this_.where.page = msg.data.data.page;
  190. },
  191. function (error) {
  192. this_.list.loading = false;
  193. $h.pushMsg('网络异常!');
  194. });
  195. }
  196. },
  197. mounted: function () {
  198. if (this.list.data.length < 4) {
  199. this.load = false;
  200. this.list.loadEnd = true;
  201. }
  202. }
  203. })
  204. })
  205. </script>
  206. {/block}