index.vue 7.1 KB

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