推拿小程序前端代码仓库
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.

256 lines
5.3 KiB

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