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

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