use-hot-goods.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <!-- 热卖产品 -->
  3. <view class="use-hot-goods">
  4. <!-- 列表标题 -->
  5. <use-list-title v-if="hotDatas && hotDatas.length > 0" :title="title" size="32" fwt="600" :type="titleType" color="#333" iconfont="iconremen" @goto="hot"></use-list-title>
  6. <view class="list dflex-b dflex dflex-wrap-w w-full">
  7. <view v-for="(item, index) in hotDatas" :key="index" class="item border-radius-sm padding-bottom-sm" @click="to_detail(item)">
  8. <view class="image-wrapper" v-if="((item.imgs).indexOf(',')) != -1"><image mode="aspectFill" :lazy-load="true" :src="((item.imgs).substring(0, ((item.imgs).indexOf(','))))"></image></view>
  9. <view class="image-wrapper" v-else><image mode="aspectFill" :lazy-load="true" :src="item.imgs"></image></view>
  10. <text class="title clamp padding-sm">{{ item.name }}</text>
  11. <view class="padding-left-sm">
  12. <text class="price">{{ item.price }}</text>
  13. <text class="m-price">{{ item.marketPrice }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 用云版权 -->
  18. <use-copyright></use-copyright>
  19. </view>
  20. </template>
  21. <script>
  22. // import {
  23. // getGoodshot
  24. // } from '@/util/homeJie.js'
  25. import useListTitle from '../../components/use-list-title/use-list-title.vue'
  26. export default {
  27. components:{
  28. useListTitle,
  29. },
  30. props: {
  31. title: {
  32. type: String,
  33. default: '热卖产品'
  34. },
  35. titleType: {
  36. type: String,
  37. default: 'square'
  38. },
  39. autoload: {
  40. type: String,
  41. default: 'auto'
  42. },
  43. datas: {
  44. type: Array,
  45. default: () => []
  46. },
  47. },
  48. data() {
  49. return {
  50. hotDatas: [
  51. ]
  52. };
  53. },
  54. watch: {
  55. datas(){
  56. this.hotDatas = this.datas;
  57. }
  58. },
  59. created() {
  60. if(this.autoload === 'auto'){
  61. // this.loadData();
  62. }
  63. },
  64. methods: {
  65. loadData() {
  66. let _self = this;
  67. _self.hotDatas=[]
  68. var data='?hot=1'
  69. uni.request({
  70. url: common.url2 + '/goods/open/page'+data,
  71. method:'GET',
  72. success(res) {
  73. res = res.data
  74. if(res.success){
  75. var total=res.data.totalCount
  76. data='?hot=1&pageSize='+total
  77. uni.request({
  78. url: common.url2 + '/goods/open/page'+data,
  79. method:'GET',
  80. success(res) {
  81. res = res.data
  82. if(res.success){
  83. res.data.list.forEach(data => {
  84. _self.hotDatas.push(data)
  85. })
  86. }else{
  87. _self.$message.warning('没有符合条件的数据!')
  88. }
  89. }
  90. })
  91. }else{
  92. _self.$message.warning('没有符合条件的数据!')
  93. }
  94. }
  95. })
  96. },
  97. // goto() {
  98. // console.log('goto');
  99. // this.$emit('goto', {
  100. // type: 'goto'
  101. // });
  102. // },
  103. hot() {
  104. this.$api.togoodslist({hot: 1});
  105. },
  106. to_detail(options) {
  107. this.$api.togoods({id: options.id});
  108. }
  109. }
  110. };
  111. </script>
  112. <style lang="scss">
  113. .use-hot-goods {
  114. margin: 15rpx 0 0 30rpx;
  115. width: 690rpx;
  116. opacity: 1;
  117. border-radius: 14rpx;
  118. background-color: rgba(255, 255, 255, 1);
  119. .list{
  120. padding: 0 3vw 20rpx;
  121. }
  122. .item {
  123. width: 40vw;
  124. overflow: hidden;
  125. margin-top: 2vw;
  126. background: #fff;
  127. &:nth-child(2n) {
  128. margin-left: 1vw;
  129. }
  130. &:nth-child(2n + 1) {
  131. margin-right: 1vw;
  132. }
  133. }
  134. .image-wrapper {
  135. width: 100%;
  136. height: 300rpx;
  137. overflow: hidden;
  138. image {
  139. width: 100%;
  140. height: 100%;
  141. opacity: 1;
  142. }
  143. }
  144. }
  145. </style>