shop.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. param : {},
  31. index : 0
  32. },
  33. data() {
  34. return {
  35. page : 1,
  36. loadingType: 3,
  37. productList : [[],[]]
  38. }
  39. },
  40. mounted() {
  41. this.getData();
  42. },
  43. methods:{
  44. getData : function() {
  45. var self = this;
  46. //避免重复加载
  47. if(this.loadingType != 3){return ;}
  48. this.loadingType = 1;
  49. this.Dever.get(this, 'app/collection/?l=api.getProduct', {code:this.Dever.config.code, content_id:this.content_id,noloading:1,noconcat:1,page:this.page}, function(t) {
  50. if (t && t.product && t.product.length > 0) {
  51. var lArr = [];
  52. var rArr = [];
  53. for (var i = 0; i < t.product.length; i++) {
  54. if (i % 2 == 0) {
  55. lArr.push(t.product[i]);
  56. } else {
  57. rArr.push(t.product[i]);
  58. }
  59. }
  60. self.productList = [lArr, rArr];
  61. self.loadingType = 3;
  62. self.page++;
  63. } else {
  64. self.loadingType = 2;
  65. }
  66. });
  67. },
  68. getInfo : function(t) {
  69. //触底刷新
  70. },
  71. view : function(id) {
  72. this.Dever.location('dream/product?id=' + id + '&table=collection/product&code=' + this.Dever.config.code);
  73. }
  74. },
  75. }
  76. </script>
  77. <style>
  78. .grace-waterfall-item{width:340rpx;}
  79. .grace-waterfall-img{width:340rpx;}
  80. .grace-img-card-item:last-child {
  81. min-height:600rpx;
  82. }
  83. </style>