敢为人鲜小程序前端代码仓库
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.

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