index.vue 9.0 KB

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