detail.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class='product-con'>
  3. <swiper indicator-dots="true" autoplay="false" circular="true" interval="2500" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff" class="swiper">
  4. <block v-for="(item,index) in product.img" :key="index">
  5. <swiper-item>
  6. <image :src="item" class="slide-image"></image>
  7. </swiper-item>
  8. </block>
  9. </swiper>
  10. <view class="info">
  11. <view class="title">{{product.title}}</view>
  12. <view class="price">¥<text>{{product.price}}</text><span>{{product.wget}}kg/件</span></view>
  13. </view>
  14. <view class="warehouse">
  15. <view class="line">仓库
  16. <view class="express">
  17. <block v-for="(item,index) in product.warehouse" :key="index">
  18. <text>{{item}}</text>
  19. </block>
  20. </view>
  21. </view>
  22. <view class="line">库存<view>{{product.count}}件</view></view>
  23. </view>
  24. <!-- 热卖推荐 -->
  25. <view class="recommend">
  26. <view class="title acea-row row-center-wrapper">
  27. <image src="../../static/images/ling.png"></image>
  28. <view class="titleTxt">热卖推荐</view>
  29. <image src="../../static/images/ling.png"></image>
  30. </view>
  31. <view class="list">
  32. <view class="item" v-for="(item,index) in recommend" :key="index" @click="goDetail(item)">
  33. <image :src="item.img"></image>
  34. <view class="name line1">{{item.title}}</view>
  35. <view class="price">¥{{item.price}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class='product-intro'>
  40. <view class='title'>商品详情</view>
  41. <rich-text :nodes="product.desc" class="conter"></rich-text>
  42. </view>
  43. <navigator class='buy' hover-class='none' url="/pages/users/purchase/index" open-type='switchTab'>立即购买</navigator>
  44. </view>
  45. </template>
  46. <script>
  47. import {
  48. recommend,
  49. productDetail
  50. } from '@/api/api.js';
  51. export default {
  52. data() {
  53. return {
  54. id: 0,
  55. product: {},
  56. recommend: []
  57. }
  58. },
  59. onLoad(options) {
  60. this.id = options.id;
  61. this.getProductDetail();
  62. this.getRecommend();
  63. },
  64. methods: {
  65. getProductDetail: function() {
  66. let that = this;
  67. productDetail({id:that.id}).then(res => {
  68. that.product = res.data;
  69. })
  70. },
  71. getRecommend: function() {
  72. let that = this;
  73. recommend().then(res => {
  74. that.recommend = res.data;
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .swiper{
  82. height:750rpx;
  83. .slide-image{
  84. width:100%;
  85. height:750rpx;
  86. }
  87. }
  88. .info{
  89. padding: 25rpx;
  90. background: #fff;
  91. .title{
  92. font-size: 32rpx;
  93. margin-bottom: 20rpx;
  94. }
  95. .price{
  96. color:#f5222d;
  97. text{
  98. font-size: 52rpx;
  99. font-weight: 600;
  100. }
  101. span{
  102. color:#333;
  103. margin-left: 30rpx;
  104. }
  105. }
  106. }
  107. .warehouse{
  108. margin-top: 20rpx;
  109. background: #fff;
  110. .line{
  111. display: flex;
  112. padding: 0 25rpx;
  113. line-height: 96rpx;
  114. view{
  115. margin-left: 30rpx;
  116. flex-grow:1;
  117. }
  118. .express{
  119. font-size: 24rpx;
  120. color:#ff5c00;
  121. border-bottom: 1px solid #ebedf0;
  122. text{
  123. border: 1rpx solid #ff5c00;
  124. border-radius: 5rpx;
  125. padding: 10rpx;
  126. margin-right: 15rpx;
  127. }
  128. }
  129. }
  130. }
  131. .recommend{
  132. background-color: #fff;
  133. margin-top: 20rpx;
  134. .title{
  135. height:98rpx;
  136. image{
  137. width:30rpx;
  138. height:30rpx;
  139. }
  140. .titleTxt{
  141. margin: 0 20rpx;
  142. font-size: 30rpx;
  143. background-image: linear-gradient(to right, #f57a37 0%, #f21b07 100%);
  144. -webkit-background-clip: text;
  145. -webkit-text-fill-color: transparent;
  146. }
  147. }
  148. .list{
  149. display: flex;
  150. flex-wrap: wrap;
  151. padding-left: 25rpx;
  152. .item{
  153. width:216rpx;
  154. margin-right: 25rpx;
  155. margin-bottom: 25rpx;
  156. image{
  157. width:216rpx;
  158. height:216rpx;
  159. border-radius: 6rpx;
  160. }
  161. .price{
  162. color: #e32721;
  163. }
  164. }
  165. }
  166. }
  167. .product-intro{
  168. margin-bottom: 120rpx;
  169. }
  170. .buy{
  171. background: #ff5c00;
  172. color:#fff;
  173. position: fixed;
  174. bottom: 0;
  175. width:100%;
  176. line-height: 100rpx;
  177. text-align: center;
  178. font-size: 32rpx;
  179. }
  180. </style>