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

346 lines
7.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
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
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="@/static/image/红烧肉.png" 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.payNum }}
  93. </view>
  94. </view>
  95. <!-- 价格 -->
  96. <view :style="{ color: '#FF2A2A'}">
  97. <text style="font-size: 18rpx;"></text><text style="font-size: 30rpx;">9.9</text>
  98. </view>
  99. <!-- 购买按钮 -->
  100. <view class="" style="display: flex;justify-content: space-between;">
  101. <view @click.stop="purchase(item.id)" 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(id) {
  132. this.$api('getRiceProductDetail', {
  133. id
  134. }, res => {
  135. if (res.code == 200) {
  136. res.result.num = 1
  137. this.$store.commit('setPayOrderProduct', [
  138. res.result
  139. ])
  140. this.$utils.navigateTo('/pages_order/order/createOrder')
  141. }
  142. })
  143. },
  144. // 加入购物车
  145. addCart(item){
  146. this.$api('addCart', {
  147. shopId : item.id,
  148. num : 1,
  149. }, res => {
  150. if(res.code == 200){
  151. uni.showToast({
  152. title: '加入购物车成功',
  153. icon: 'none'
  154. })
  155. }
  156. })
  157. },
  158. //根据角色获取对应价格
  159. getPriceByRole(item) {
  160. let priceFiledList = ['goldPrice','silverPrice','diamondPrice']
  161. let price = item[priceFiledList[this.userInfo.role - 1]]
  162. return price >= 0 ? price : item.price
  163. }
  164. }
  165. }
  166. </script>
  167. <style scoped lang="scss">
  168. .item {
  169. width: 92%;
  170. margin: 20rpx auto;
  171. padding: 20rpx 10rpx;
  172. align-items: center;
  173. display: flex;
  174. box-sizing: border-box;
  175. border-bottom: 1rpx solid #00000012;
  176. background: white;
  177. border-radius: 10rpx;
  178. // margin-bottom: 20rpx;
  179. // box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
  180. // 商品图片
  181. .item-image {
  182. width: 200rpx;
  183. height: 200rpx;
  184. overflow: hidden;
  185. image {
  186. height: 100%;
  187. width: 100%;
  188. }
  189. }
  190. // 商品信息
  191. .info {
  192. // height: 220rpx;
  193. padding: 15rpx 0rpx 15rpx 15rpx;
  194. color: #555;
  195. width: calc(100% - 200rpx);
  196. box-sizing: border-box;
  197. overflow: hidden;
  198. display: flex;
  199. flex-direction: column;
  200. gap: 4rpx;
  201. // 商品标题
  202. .title {
  203. font-size: 30rpx;
  204. font-weight: bold;
  205. overflow: hidden; //超出的文本隐藏
  206. text-overflow: ellipsis; //溢出用省略号显示
  207. white-space: nowrap; //溢出不换行
  208. color: #333;
  209. margin-bottom: 5rpx;
  210. }
  211. .price-section {
  212. display: flex;
  213. flex-direction: column;
  214. gap: 6rpx;
  215. }
  216. // 价格
  217. .price {
  218. display: flex;
  219. align-items: center;
  220. color: #f40;
  221. font-size: 24rpx;
  222. align-items: flex-end;
  223. .money {
  224. font-size: 30rpx;
  225. font-weight: 600;
  226. .unit {
  227. font-size: 18rpx;
  228. font-weight: normal;
  229. margin-left: 2rpx;
  230. }
  231. }
  232. .price-imgs {
  233. display: flex;
  234. flex-wrap: wrap;
  235. align-items: center;
  236. .price-img {
  237. width: 70rpx;
  238. height: 26rpx;
  239. margin-left: 8rpx;
  240. }
  241. }
  242. }
  243. .oldPrice{
  244. color: #999;
  245. font-size: 20rpx;
  246. text-decoration: line-through;
  247. margin-left: 8rpx;
  248. }
  249. .member-price {
  250. display: flex;
  251. flex-direction: column;
  252. gap: 4rpx;
  253. margin-top: 4rpx;
  254. padding-top: 6rpx;
  255. border-top: 1rpx dashed #eee;
  256. .money {
  257. font-size: 26rpx;
  258. .unit {
  259. font-size: 18rpx;
  260. }
  261. }
  262. .price-imgs {
  263. display: flex;
  264. flex-wrap: wrap;
  265. .price-img {
  266. width: 70rpx;
  267. height: 26rpx;
  268. margin-left: 8rpx;
  269. }
  270. }
  271. }
  272. // 销量
  273. .sales-volume {
  274. display: flex;
  275. align-items: center;
  276. flex-wrap: wrap;
  277. margin-top: 2rpx;
  278. .sales-volume-imgbox {
  279. width: 18rpx;
  280. .sales-volume-img {
  281. width: 100%;
  282. }
  283. }
  284. .sales-volume-number {
  285. color: #999;
  286. font-size: 24rpx;
  287. padding-left: 8rpx;
  288. }
  289. }
  290. // 购买按钮
  291. .buy-btn {
  292. background: $uni-color;
  293. color: white;
  294. display: inline-block;
  295. padding: 10rpx 24rpx;
  296. border-radius: 10rpx;
  297. width: fit-content;
  298. font-size: 23rpx;
  299. font-weight: 500;
  300. box-shadow: 0 2rpx 6rpx rgba(255,68,0,0.2);
  301. transition: all 0.3s;
  302. margin-top: 4rpx;
  303. position: relative;
  304. }
  305. .buy-order{
  306. background: inherit;
  307. border: 3rpx solid $uni-color;
  308. color: $uni-color;
  309. }
  310. }
  311. }
  312. </style>