shop.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template name="shop">
  2. <view>
  3. <view class="grace-space-between">
  4. <view class="grace-waterfall-item" v-for="(v, k) in productList" :key="k">
  5. <view class="grace-img-card-item" v-for="(v1, k1) in v" :key="k1" @click="view(v1.id)">
  6. <image :src="v1.pic_cover" mode="widthFix" class="grace-waterfall-img" style="height:auto"></image>
  7. <text class="grace-img-card-title">{{v1.name}}</text>
  8. <view class="grace-img-card-more">
  9. <text class="grace-img-card-price">{{v1.price}}</text>
  10. <text class="grace-img-card-btn">购买</text>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. <graceLoading :loadingType="loadingType"></graceLoading>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: "shop",
  21. props: {
  22. content_id : {
  23. type : String,
  24. value : null
  25. },
  26. width : {
  27. type : String,
  28. default : '100%'
  29. },
  30. code : {
  31. type : String,
  32. default : ''
  33. },
  34. param : {},
  35. index : 0
  36. },
  37. data() {
  38. return {
  39. page : 1,
  40. loadingType: 3,
  41. productList : [[],[]]
  42. }
  43. },
  44. mounted() {
  45. this.getData();
  46. },
  47. methods:{
  48. getData : function() {
  49. var self = this;
  50. //避免重复加载
  51. if(this.loadingType != 3){return ;}
  52. this.loadingType = 1;
  53. this.Dever.get(this, 'app/collection/?l=api.getProduct', {code:this.code, content_id:this.content_id,noloading:1,noconcat:1,page:this.page}, function(t) {
  54. if (t && t.product && t.product.length > 0) {
  55. var lArr = [];
  56. var rArr = [];
  57. for (var i = 0; i < t.product.length; i++) {
  58. if (i % 2 == 0) {
  59. lArr.push(t.product[i]);
  60. } else {
  61. rArr.push(t.product[i]);
  62. }
  63. }
  64. self.productList = [lArr, rArr];
  65. self.loadingType = 3;
  66. self.page++;
  67. } else {
  68. self.loadingType = 2;
  69. }
  70. });
  71. },
  72. getInfo : function(t) {
  73. //触底刷新
  74. },
  75. view : function(id) {
  76. this.Dever.location('dream/product?id=' + id + '&table=collection/product&code=' + this.code);
  77. }
  78. },
  79. }
  80. </script>
  81. <style>
  82. .grace-waterfall-item{width:340rpx;}
  83. .grace-waterfall-img{width:340rpx;}
  84. .grace-img-card-item:last-child {
  85. min-height:600rpx;
  86. }
  87. </style>