index.vue 7.2 KB

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