珠宝小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
3.8 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
1 month ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="list">
  3. <view class="item" v-for="(item, index) in list"
  4. @click="$utils.navigateTo('/pages_order/product/productDetail?id=' + item.id)" :key="index">
  5. <image class="image" :src="item.image &&
  6. item.image.split(',')[0]" mode="aspectFill"></image>
  7. <view class="product-info">
  8. <view class="product-title">
  9. {{ item.title }}
  10. </view>
  11. <view class="tag-list">
  12. <view class="tag"
  13. :key="i"
  14. v-for="(t, i) in item.skuIcon
  15. && item.skuIcon.split(',')">
  16. {{ t }}
  17. </view>
  18. </view>
  19. <view class="product-main">
  20. <view class="sale-information">
  21. <view style="display: flex;align-items: flex-end;">
  22. <view class="price">
  23. <text>{{ item.price }}</text>/
  24. </view>
  25. <view class="oldPrice">
  26. <text>{{ item.oldPrice }}</text>
  27. </view>
  28. </view>
  29. <view class="num">
  30. 已售卖{{ item.payNum }}+ | 库存{{ item.num }}
  31. </view>
  32. </view>
  33. <view @click.stop="item.num > 0 ? purchase(item.id) : ''"
  34. class="btn"
  35. :class="{'disabled-btn': item.num <= 0}">
  36. {{ item.num > 0 ? '购买' : '无库存' }}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view style="width: 700rpx;">
  42. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. name: "productList",
  49. props: {
  50. list: {
  51. default: []
  52. },
  53. },
  54. data() {
  55. return {
  56. };
  57. },
  58. methods: {
  59. // 购买商品(创建订单)
  60. purchase(id) {
  61. this.$api('getRiceProductDetail', {
  62. id
  63. }, res => {
  64. if (res.code == 200) {
  65. res.result.num = 1
  66. this.$store.commit('setPayOrderProduct', [
  67. res.result
  68. ])
  69. this.$utils.navigateTo('/pages_order/order/createOrder')
  70. }
  71. })
  72. },
  73. },
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .list {
  78. display: flex;
  79. flex-wrap: wrap;
  80. .item {
  81. position: relative;
  82. width: 345rpx;
  83. padding: 20rpx;
  84. box-sizing: border-box;
  85. background-color: #fff;
  86. border-radius: 20rpx;
  87. margin-left: 20rpx;
  88. margin-bottom: 20rpx;
  89. .image {
  90. width: 300rpx;
  91. height: 300rpx;
  92. border-radius: 20rpx;
  93. }
  94. .tag-list{
  95. display: flex;
  96. flex-wrap: wrap;
  97. padding: 6rpx 0;
  98. .tag{
  99. padding: 6rpx 12rpx;
  100. border-radius: 14rpx;
  101. background-color: rgba($uni-color, 0.1);
  102. color: $uni-color;
  103. border: 1rpx solid $uni-color;
  104. font-size: 20rpx;
  105. margin: 6rpx;
  106. }
  107. }
  108. .product-info {
  109. font-size: 24rpx;
  110. .product-title {
  111. font-weight: bold;
  112. display: -webkit-box;
  113. /* 兼容WebKit内核浏览器 */
  114. -webkit-line-clamp: 2;
  115. /* 显示最大3行 */
  116. -webkit-box-orient: vertical;
  117. /* 设置垂直方向上的排列方式 */
  118. overflow: hidden;
  119. /* 隐藏溢出内容 */
  120. text-overflow: ellipsis;
  121. /* 当文本溢出时显示省略号 */
  122. }
  123. .product-main {
  124. display: flex;
  125. align-items: flex-end;
  126. .sale-information {
  127. width: 75%;
  128. .title {
  129. font-size: 28rpx;
  130. overflow: hidden; //超出的文本隐藏
  131. text-overflow: ellipsis; //溢出用省略号显示
  132. white-space: nowrap; //溢出不换行
  133. }
  134. .price {
  135. color: $uni-color;
  136. margin-top: 6rpx;
  137. text {
  138. font-size: 30rpx;
  139. font-weight: 900;
  140. }
  141. }
  142. .oldPrice {
  143. color: #888;
  144. text-decoration: line-through;
  145. }
  146. .num {
  147. margin-top: 6rpx;
  148. font-size: 22rpx;
  149. color: #888;
  150. }
  151. }
  152. .btn {
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. border-radius: 10rpx;
  157. font-size: 24rpx;
  158. height: 60rpx;
  159. width: 25%;
  160. color: #fff;
  161. background-color: $uni-color;
  162. }
  163. .disabled-btn {
  164. background-color: #cccccc;
  165. cursor: not-allowed;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>