珠宝小程序前端代码
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.

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