index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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-toast="淘口令复制成功"
  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="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. isFetchLock: false // 是否调用过分享配置
  134. }
  135. },
  136. computed: {
  137. sourceList () {
  138. return this.$store.getters['common/sourceList']
  139. },
  140. businessLogo () {
  141. const result = this.sourceList.filter(item => item.value === this.source)
  142. if (result.length) {
  143. return result[0].logo
  144. }
  145. return ''
  146. },
  147. businessName () {
  148. const result = this.sourceList.filter(item => item.value === this.source)
  149. if (result.length) {
  150. return result[0].name
  151. }
  152. return ''
  153. }
  154. },
  155. created () {
  156. this.funInit()
  157. },
  158. methods: {
  159. async funInit () {
  160. try {
  161. const { status, data, msg } = await apiGoodsDetail(this.source, this.goodsId)
  162. if (status) {
  163. this.goodsInfo = data
  164. this.couponInfo = data.coupon_info
  165. if (Array.isArray(data.goods_carousel_pictures)) {
  166. this.goodsCarouselPictures = data.goods_carousel_pictures
  167. }
  168. if (Array.isArray(data.goods_detail_pictures)) {
  169. this.goodsDetailPictures = data.goods_detail_pictures
  170. }
  171. } else {
  172. Toast(msg)
  173. }
  174. } catch (e) {}
  175. },
  176. showShareTip () {
  177. const id = this.$store.getters['common/userinfo'].id
  178. let coverImg = ''
  179. if (!(Object.keys(this.goodsInfo).length) || id === '') {
  180. Toast('数据加载中,稍后重试')
  181. return
  182. }
  183. if (this.goodsCarouselPictures.length) {
  184. coverImg = this.goodsCarouselPictures[0]
  185. } else if (this.goodsDetailPictures.length) {
  186. coverImg = this.goodsDetailPictures[0]
  187. }
  188. // 处理用户ID未获取成功的场景
  189. if (!this.isFetchLock) {
  190. platform.isWeixin && funWxShare(this.businessName, this.goodsInfo.goods_name, coverImg, this.source === 'taobao' ? `${location.origin}/category/tbLandingPage/${id}/${this.goodsId}` : this.goodsInfo.url)
  191. this.isFetchLock = true
  192. }
  193. this.$refs.fbtShareTipInWechat.init()
  194. },
  195. jumpShops () {
  196. if (!(Object.keys(this.goodsInfo).length)) {
  197. Toast('数据加载中,稍后重试')
  198. return
  199. }
  200. if (this.source === 'taobao') {
  201. this.copyPopup = true
  202. return
  203. }
  204. top.location.href = this.goodsInfo.url
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .padding-bottom-94 {
  211. padding-bottom: 94px;
  212. }
  213. .main {
  214. width: 355px;
  215. margin: 0 auto;
  216. }
  217. .header {
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. margin-top: 12px;
  222. }
  223. .price-wrap {
  224. display: flex;
  225. align-items: center;
  226. }
  227. .price {
  228. margin-right: 15px;
  229. font-size: 0;
  230. span {
  231. &:nth-of-type(1) {
  232. margin-right: 3px;
  233. font-size: 16px;
  234. font-weight: bold;
  235. color: #EA483F;
  236. line-height: 24px;
  237. }
  238. &:nth-of-type(2) {
  239. font-size: 21px;
  240. font-weight: 800;
  241. color: #EA483F;
  242. line-height: 24px;
  243. }
  244. }
  245. }
  246. .origin {
  247. font-size: 11px;
  248. font-weight: 500;
  249. color: #EA483F;
  250. line-height: 18px;
  251. }
  252. .income {
  253. display: flex;
  254. align-items: center;
  255. span {
  256. &:nth-of-type(1) {
  257. font-size: 11px;
  258. font-weight: bold;
  259. color: #EA483F;
  260. line-height: 24px;
  261. }
  262. &:nth-of-type(2) {
  263. font-size: 14px;
  264. font-weight: 500;
  265. color: #EA483F;
  266. line-height: 24px;
  267. }
  268. }
  269. }
  270. .origin-price {
  271. margin-top: 6px;
  272. font-size: 13px;
  273. text-decoration: line-through;
  274. color: #999999;
  275. line-height: 18px;
  276. }
  277. .name-wrap {
  278. position: relative;
  279. left: 0;
  280. top: 0;
  281. margin: 10px 0 14px;
  282. img {
  283. position: absolute;
  284. left: 0;
  285. top: 0;
  286. width: 30px;
  287. height: 16px;
  288. }
  289. p {
  290. font-size: 14px;
  291. font-weight: bold;
  292. color: #333333;
  293. line-height: 20px;
  294. text-indent: 34px;
  295. }
  296. }
  297. .coupon-wrap {
  298. display: flex;
  299. align-items: center;
  300. justify-content: flex-end;
  301. width: 359px;
  302. height: 84px;
  303. background: url("./image/ic_coupon_big.png") center center/100% 100% no-repeat;
  304. & > div {
  305. width: 227px;
  306. text-align: center;
  307. }
  308. .amount {
  309. font-size: 19px;
  310. font-weight: bold;
  311. color: #000000;
  312. line-height: 31px;
  313. }
  314. .expires {
  315. font-size: 11px;
  316. font-weight: bold;
  317. color: #BCA763;
  318. line-height: 18px;
  319. }
  320. ::v-deep .van-button--default {
  321. width: 86px;
  322. padding: 0;
  323. border: none;
  324. background: transparent;
  325. .van-button__text {
  326. font-size: 18px;
  327. font-weight: bold;
  328. color: #FFFFFF;
  329. }
  330. }
  331. }
  332. .footer {
  333. position: fixed;
  334. left: 0;
  335. right: 0;
  336. bottom: 0;
  337. z-index: 10;
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. width: 100%;
  342. padding: 13px 0 30px;
  343. border-top: 1px solid #F1F1F1;
  344. background: #FFFFFF;
  345. a {
  346. display: flex;
  347. flex-direction: column;
  348. justify-content: center;
  349. width: 168px;
  350. height: 50px;
  351. border: none;
  352. border-radius: 25px;
  353. overflow: hidden;
  354. &:nth-of-type(1) {
  355. color: #fff;
  356. background: #000;
  357. }
  358. &:nth-of-type(2) {
  359. margin-left: 14px;
  360. color: #333333;
  361. background: #f8d548;
  362. }
  363. span {
  364. width: 100%;
  365. padding: 0 10px;
  366. font-size: 14px;
  367. font-weight: 500;
  368. overflow: hidden;
  369. white-space: nowrap;
  370. text-overflow: ellipsis;
  371. text-align: center;
  372. }
  373. }
  374. }
  375. .photo-list {
  376. margin-top: 14px;
  377. img {
  378. display: block;
  379. width: 100%;
  380. max-width: 800px;
  381. margin: 0 auto;
  382. }
  383. }
  384. .fbt-van-copy {
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. height: 260px;
  389. .title {
  390. width: 100%;
  391. padding: 30px 0 20px;
  392. font-size: 18px;
  393. font-weight: bold;
  394. color: #333333;
  395. line-height: 28px;
  396. text-align: center;
  397. }
  398. .content {
  399. width: 350px;
  400. padding: 18px 15px;
  401. border-radius: 18px;
  402. font-size: 14px;
  403. color: #959595;
  404. line-height: 20px;
  405. word-break: break-all;
  406. background: #fff;
  407. }
  408. ::v-deep .van-button {
  409. width: 350px;
  410. margin-top: 20px;
  411. }
  412. }
  413. </style>