index.vue 9.3 KB

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