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

198 lines
3.8 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="item" @click="$emit('click')">
  3. <!-- 商品图片 -->
  4. <view class="item-image">
  5. <image :src="item.image &&
  6. item.image.split(',')[0]" mode="aspectFill">
  7. </image>
  8. </view>
  9. <!-- 商品信息 -->
  10. <view class="info">
  11. <!-- 商品标题 -->
  12. <view class="title">
  13. {{ item.title }}
  14. </view>
  15. <!-- 价格 -->
  16. <view class="price">
  17. <view class="money">
  18. <!-- <text>{{ item.vipPrice }}</text> -->
  19. <text>{{ getPriceByRole(item) }}</text>
  20. <text class="unit">/元每件</text>
  21. </view>
  22. <view class="price-imgs">
  23. <image v-if="userInfo.role == 1" :src="configList.vip_money_one" mode="aspectFill" class="price-img">
  24. </image>
  25. <image v-if="userInfo.role == 2" :src="configList.vip_money_two" mode="aspectFill" class="price-img">
  26. </image>
  27. <image v-if="userInfo.role == 3" :src="configList.vip_money_three" mode="aspectFill"
  28. class="price-img"></image>
  29. </view>
  30. </view>
  31. <!-- 销量 -->
  32. <view class="sales-volume">
  33. <view class="sales-volume-imgbox">
  34. <image src="@/static/image/category/sales-volume-icon.png" mode="widthFix" class="sales-volume-img">
  35. </image>
  36. </view>
  37. <view class="sales-volume-number">
  38. 已售出{{ item.payNum }}+
  39. </view>
  40. </view>
  41. <!-- 购买按钮 -->
  42. <view @click.stop="purchase(item.id)" class="buy-btn">
  43. 购买
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState
  51. } from 'vuex'
  52. export default {
  53. props: {
  54. item: {
  55. default: {}
  56. }
  57. },
  58. computed: {
  59. ...mapState(['userInfo'])
  60. },
  61. data() {
  62. return {
  63. }
  64. },
  65. methods: {
  66. // 购买商品(创建订单)
  67. purchase(id) {
  68. this.$api('getRiceProductDetail', {
  69. id
  70. }, res => {
  71. if (res.code == 200) {
  72. res.result.num = 1
  73. this.$store.commit('setPayOrderProduct', [
  74. res.result
  75. ])
  76. this.$utils.navigateTo('/pages_order/order/createOrder')
  77. }
  78. })
  79. },
  80. //根据角色获取对应价格
  81. getPriceByRole(item) {
  82. let priceFiledList = ['goldPrice','silverPrice','diamondPrice']
  83. let price = item[priceFiledList[this.userInfo.role - 1]]
  84. return price >= 0 ? price : item.price
  85. }
  86. }
  87. }
  88. </script>
  89. <style scoped lang="scss">
  90. .item {
  91. width: 100%;
  92. padding: 10rpx 20rpx;
  93. align-items: center;
  94. display: flex;
  95. box-sizing: border-box;
  96. border-bottom: 1rpx solid #00000012;
  97. background: white;
  98. border-radius: 20rpx;
  99. margin-bottom: 20rpx;
  100. // 商品图片
  101. .item-image {
  102. width: 180rpx;
  103. height: 180rpx;
  104. image {
  105. height: 100%;
  106. width: 100%;
  107. }
  108. }
  109. // 商品信息
  110. .info {
  111. padding: 20rpx;
  112. color: #555;
  113. width: calc(100% - 180rpx);
  114. box-sizing: border-box;
  115. overflow: hidden;
  116. // 商品标题
  117. .title {
  118. width: 280rpx;
  119. font-size: 28rpx;
  120. font-weight: bold;
  121. overflow: hidden; //超出的文本隐藏
  122. text-overflow: ellipsis; //溢出用省略号显示
  123. white-space: nowrap; //溢出不换行
  124. }
  125. // 价格
  126. .price {
  127. display: flex;
  128. align-items: center;
  129. color: #f40;
  130. font-size: 26rpx;
  131. .money {
  132. font-size: 30rpx;
  133. .unit {
  134. font-size: 20rpx;
  135. }
  136. }
  137. .price-imgs {
  138. display: flex;
  139. flex-wrap: wrap;
  140. .price-img {
  141. width: 80rpx;
  142. height: 30rpx;
  143. margin-left: 10rpx;
  144. }
  145. }
  146. }
  147. // 销量
  148. .sales-volume {
  149. display: flex;
  150. align-items: center;
  151. flex-wrap: wrap;
  152. .sales-volume-imgbox {
  153. width: 20rpx;
  154. .sales-volume-img {
  155. width: 100%;
  156. }
  157. }
  158. .sales-volume-number {
  159. color: #B8B8B8;
  160. font-size: 26rpx;
  161. padding-left: 10rpx;
  162. }
  163. }
  164. // 购买按钮
  165. .buy-btn {
  166. background: $uni-color;
  167. color: white;
  168. display: inline-block;
  169. padding: 10rpx 20rpx;
  170. border-radius: 10rpx;
  171. }
  172. }
  173. }
  174. </style>