waterfall-item.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="waterfall-item-container">
  3. <view class="waterfall-item" @tap="onTap">
  4. <image :src="params.pic||default_img" mode="widthFix" @load="emitHeight" @error="emitHeight" lazy-load>
  5. </image>
  6. <view class="demo-title" :style="goodtitle_style">
  7. {{params.name}}
  8. </view>
  9. <view class="message_bot">
  10. <view class="f_left">
  11. <view class="color_org text-neutral" :style='goodprice_style'>
  12. {{ params.price }}元/{{ params.unit }}
  13. </view>
  14. <view class="old_price" :style='goodoprice_style'>原价:{{ params.oprice }}元</view>
  15. </view>
  16. <view class="f_right">
  17. <u-icon name="shopping-cart-fill" :color="primary" size="30"></u-icon>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: "helang-waterfall",
  26. props: {
  27. params: {
  28. type: Object,
  29. default () {
  30. return {}
  31. }
  32. },
  33. tag: {
  34. type: String | Number,
  35. default: ''
  36. },
  37. index: {
  38. type: Number,
  39. default: -1
  40. },
  41. datas: {
  42. type: Object,
  43. default: ''
  44. }
  45. },
  46. data() {
  47. let siteinfo = getApp().globalData.siteinfo;
  48. const img = siteinfo.root_img + '/static/app/imgs/default-goods.png';
  49. return {
  50. default_img: img,
  51. primary: this.$theme.primary,
  52. };
  53. },
  54. computed: {
  55. /** 副标题内容 */
  56. title() {
  57. return this.datas.title || '';
  58. },
  59. img_style2() {
  60. return `
  61. width:15px;
  62. height:15px;
  63. margin:auto;
  64. `;
  65. },
  66. // 副标题栏样式
  67. title_style() {
  68. const {
  69. text_size,
  70. text_color,
  71. } = this.datas;
  72. return `
  73. font-size: ${text_size}px;
  74. color: ${text_color};
  75. `;
  76. },
  77. // 副标题栏样式
  78. title_style1() {
  79. const {
  80. text_size,
  81. } = this.datas;
  82. return `
  83. color:rgb(96, 98, 102);
  84. font-size: ${text_size}px;
  85. `;
  86. },
  87. // 商品标题
  88. goodtitle_style() {
  89. if (!this.datas.good_text_size) {
  90. this.datas.good_text_size = 15;
  91. }
  92. const {
  93. good_text_size,
  94. good_text_color
  95. } = this.datas;
  96. return `
  97. font-size: ${good_text_size*2}rpx;
  98. line-height: 40rpx;
  99. color: ${good_text_color};
  100. `;
  101. },
  102. // 商品价格
  103. goodprice_style() {
  104. const {
  105. shop_price_color,
  106. } = this.datas;
  107. return `
  108. color: ${shop_price_color};
  109. `;
  110. },
  111. // 商品价格
  112. goodoprice_style() {
  113. const {
  114. market_price_color,
  115. } = this.datas;
  116. return `
  117. color: ${market_price_color};
  118. `;
  119. },
  120. // 商品图标
  121. goodiocn_style() {
  122. const {
  123. buynow_bg_color,
  124. } = this.datas;
  125. return `
  126. font-size: 25px;
  127. color: ${buynow_bg_color};
  128. `;
  129. },
  130. /** 样式 */
  131. wrapper_style() {
  132. const {
  133. padding_top,
  134. padding_bottom,
  135. padding_left,
  136. padding_right,
  137. margin_top,
  138. margin_bottom,
  139. bg_color,
  140. } = this.datas;
  141. return `
  142. width: 100%;
  143. background-color:${bg_color};
  144. padding-top: ${margin_top}px;
  145. padding-bottom: ${margin_bottom}px;
  146. padding-left: ${padding_left}px;
  147. padding-right: ${padding_right}px;
  148. `;
  149. },
  150. // 商品列表
  151. list() {
  152. let list = this.list2;
  153. if (!list || list.length <= 0) {
  154. list = this.datas.goods || [];
  155. }
  156. return list;
  157. },
  158. },
  159. methods: {
  160. // 发出组件高度信息,在此处可以区分正确和错误的加载,给予错误的提示图片
  161. emitHeight(e) {
  162. const query = uni.createSelectorQuery().in(this);
  163. query.select('.waterfall-item-container').boundingClientRect(data => {
  164. let height = Math.floor(data.height);
  165. this.$emit("height", height, this.$props.tag);
  166. }).exec();
  167. },
  168. onTap() {
  169. this.$emit("click", this.$props.index, this.$props.tag);
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .demo-title {
  176. padding: 0rpx 16rpx 0rpx 16rpx;
  177. font-size: 26rpx;
  178. margin-top: 15rpx;
  179. color: $u-main-color;
  180. overflow: hidden;
  181. text-overflow: ellipsis;
  182. display: -webkit-box;
  183. -webkit-line-clamp: 2;
  184. line-height: 40rpx;
  185. -webkit-box-orient: vertical;
  186. }
  187. .message_bot {
  188. padding: 0rpx 16rpx 0rpx 16rpx;
  189. border-top: 1px solid #f3f3f3;
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. padding-top: 10rpx;
  194. margin-top: 5rpx;
  195. .f_left {
  196. .color_org {
  197. font-size: 28rpx;
  198. }
  199. .old_price {
  200. padding: 10rpx 0rpx 10rpx 4rpx;
  201. color: #999;
  202. font-size: 22rpx;
  203. text-decoration: line-through;
  204. }
  205. }
  206. .f_right {}
  207. }
  208. .waterfall-item {
  209. // padding: 16rpx;
  210. background-color: #fff;
  211. border-radius: 4px;
  212. font-size: 28rpx;
  213. color: #666;
  214. image {
  215. display: block;
  216. width: 100%;
  217. height: 350rpx;
  218. border-top-left-radius: 15rpx;
  219. border-top-right-radius: 15rpx;
  220. }
  221. .content {
  222. margin-top: 16rpx;
  223. .money {
  224. color: #fa3534;
  225. margin-top: 8rpx;
  226. }
  227. .label {
  228. background-color: #fa3534;
  229. color: #fff;
  230. font-size: 20rpx;
  231. padding: 4rpx 16rpx;
  232. border-radius: 20rpx;
  233. }
  234. .shop-name {
  235. font-size: 20rpx;
  236. color: #999;
  237. }
  238. }
  239. }
  240. </style>