index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div
  3. class="padding-bottom-94">
  4. <!--轮播图-->
  5. <Banner
  6. :arrBanner="goodsCarouselPictures"/>
  7. <!--价格信息-->
  8. <div class="main">
  9. <div class="header">
  10. <div class="price-wrap">
  11. <p class="price">
  12. <span>¥</span>
  13. <span>{{ goodsInfo.price && (goodsInfo.price * 1).toFixed(2) }}</span>
  14. </p>
  15. <p class="origin">券后价</p>
  16. </div>
  17. <div class="income">
  18. <span>预估收益 ¥</span>
  19. <span>{{ goodsInfo.commission && (goodsInfo.commission * 1).toFixed(2) }}</span>
  20. </div>
  21. </div>
  22. <p class="origin-price">原价¥ {{ goodsInfo.market_price && (goodsInfo.market_price * 1).toFixed(2) }}</p>
  23. <div
  24. class="name-wrap">
  25. <p>{{ goodsInfo.goods_name }}</p>
  26. </div>
  27. <div
  28. class="coupon-wrap"
  29. v-if="couponInfo.fav > 0">
  30. <div>
  31. <p class="amount">{{ couponInfo.fav }}元优惠券</p>
  32. <p class="expires">{{
  33. couponInfo.use_begin_time.replace(/\s\d{2}|:\d{2}/g, '').replace('-', '年').replace('-', '月') + '日'
  34. }}-{{
  35. couponInfo.use_end_time.replace(/\s\d{2}|:\d{2}/g, '').replace('-', '年').replace('-', '月') + '日'
  36. }}</p>
  37. </div>
  38. <van-button type="default">立即领券</van-button>
  39. </div>
  40. </div>
  41. <!--商品详情图片-->
  42. <div
  43. class="photo-list">
  44. <img
  45. v-lazy="str"
  46. alt=""
  47. v-for="(str, index) in goodsDetailPictures"
  48. :key="index">
  49. </div>
  50. <!--底部按钮-->
  51. <div class="footer">
  52. <a href="javascript:;">
  53. <span>分享赚</span>
  54. <span>¥{{ goodsInfo.commission }}</span>
  55. </a>
  56. <a href="javascript:;">
  57. <span>自购省</span>
  58. <span>券¥{{ couponInfo.fav }} + ¥{{ goodsInfo.commission }}</span>
  59. </a>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import Banner from './child/banner'
  65. import { Button, Toast } from 'vant'
  66. import { apiGoodsDetail } from './api/api'
  67. export default {
  68. name: 'index',
  69. components: {
  70. Banner,
  71. 'van-button': Button
  72. },
  73. props: {
  74. source: {
  75. type: String,
  76. default: ''
  77. },
  78. goodsId: {
  79. type: [String, Number],
  80. default: ''
  81. }
  82. },
  83. data () {
  84. return {
  85. goodsInfo: {},
  86. couponInfo: {}, // 优惠券相关
  87. goodsCarouselPictures: [], // 商品轮播图
  88. goodsDetailPictures: [] // 商品详情图片
  89. }
  90. },
  91. created () {
  92. this.funInit()
  93. },
  94. methods: {
  95. async funInit () {
  96. try {
  97. const { status, data, msg } = await apiGoodsDetail(this.source, this.goodsId)
  98. if (status) {
  99. this.goodsInfo = data
  100. this.couponInfo = data.coupon_info
  101. if (Array.isArray(data.goods_carousel_pictures)) {
  102. this.goodsCarouselPictures = data.goods_carousel_pictures
  103. }
  104. if (Array.isArray(data.goods_detail_pictures)) {
  105. this.goodsDetailPictures = data.goods_detail_pictures
  106. }
  107. } else {
  108. Toast(msg)
  109. }
  110. } catch (e) {}
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .padding-bottom-94 {
  117. padding-bottom: 94px;
  118. }
  119. .main {
  120. width: 355px;
  121. margin: 0 auto;
  122. }
  123. .header {
  124. display: flex;
  125. align-items: center;
  126. justify-content: space-between;
  127. margin-top: 12px;
  128. }
  129. .price-wrap {
  130. display: flex;
  131. align-items: center;
  132. }
  133. .price {
  134. margin-right: 15px;
  135. font-size: 0;
  136. span {
  137. &:nth-of-type(1) {
  138. margin-right: 3px;
  139. font-size: 16px;
  140. font-weight: bold;
  141. color: #EA483F;
  142. line-height: 24px;
  143. }
  144. &:nth-of-type(2) {
  145. font-size: 21px;
  146. font-weight: 800;
  147. color: #EA483F;
  148. line-height: 24px;
  149. }
  150. }
  151. }
  152. .origin {
  153. font-size: 11px;
  154. font-weight: 500;
  155. color: #EA483F;
  156. line-height: 18px;
  157. }
  158. .income {
  159. display: flex;
  160. align-items: center;
  161. span {
  162. &:nth-of-type(1) {
  163. font-size: 11px;
  164. font-weight: bold;
  165. color: #EA483F;
  166. line-height: 18px;
  167. }
  168. &:nth-of-type(2) {
  169. padding-top: 2px;
  170. font-size: 14px;
  171. font-weight: 500;
  172. color: #EA483F;
  173. line-height: 24px;
  174. }
  175. }
  176. }
  177. .origin-price {
  178. margin-top: 6px;
  179. font-size: 13px;
  180. text-decoration: line-through;
  181. color: #999999;
  182. line-height: 18px;
  183. }
  184. .name-wrap {
  185. margin: 10px 0 14px;
  186. overflow: hidden;
  187. img {
  188. width: 30px;
  189. height: 16px;
  190. margin-right: 4px;
  191. float: left;
  192. }
  193. p {
  194. font-size: 14px;
  195. font-weight: bold;
  196. color: #333333;
  197. line-height: 20px;
  198. }
  199. }
  200. .coupon-wrap {
  201. display: flex;
  202. align-items: center;
  203. justify-content: flex-end;
  204. width: 359px;
  205. height: 84px;
  206. background: url("./image/ic_coupon_big.png") center center/100% 100% no-repeat;
  207. & > div {
  208. width: 227px;
  209. text-align: center;
  210. }
  211. .amount {
  212. font-size: 19px;
  213. font-weight: bold;
  214. color: #000000;
  215. line-height: 31px;
  216. }
  217. .expires {
  218. font-size: 11px;
  219. font-weight: bold;
  220. color: #BCA763;
  221. line-height: 18px;
  222. }
  223. ::v-deep .van-button--default {
  224. width: 86px;
  225. padding: 0;
  226. border: none;
  227. background: transparent;
  228. .van-button__text {
  229. font-size: 18px;
  230. font-weight: bold;
  231. color: #FFFFFF;
  232. }
  233. }
  234. }
  235. .footer {
  236. position: fixed;
  237. left: 0;
  238. right: 0;
  239. bottom: 0;
  240. z-index: 10;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. width: 100%;
  245. padding: 13px 0 30px;
  246. border-top: 1px solid #F1F1F1;
  247. background: #FFFFFF;
  248. a {
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: center;
  252. width: 168px;
  253. height: 50px;
  254. border: none;
  255. border-radius: 25px;
  256. overflow: hidden;
  257. &:nth-of-type(1) {
  258. color: #fff;
  259. background: #000;
  260. }
  261. &:nth-of-type(2) {
  262. margin-left: 14px;
  263. color: #333333;
  264. background: #f8d548;
  265. }
  266. span {
  267. width: 100%;
  268. padding: 0 10px;
  269. font-size: 14px;
  270. font-weight: 500;
  271. overflow: hidden;
  272. white-space: nowrap;
  273. text-overflow: ellipsis;
  274. text-align: center;
  275. }
  276. }
  277. }
  278. .photo-list {
  279. margin-top: 14px;
  280. img {
  281. display: block;
  282. width: 100%;
  283. max-width: 800px;
  284. margin: 0 auto;
  285. }
  286. }
  287. </style>