IntegralGoodsDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <u-navbar :is-back="false" title-color="#000000" :title-bold="true" title-size="36" :title="goods_detail.title">
  4. <view class="back-icon ibonfont ibonfanhui" @click="back"></view>
  5. </u-navbar>
  6. <block v-if="goods_detail.id">
  7. <!-- 底部菜单 -->
  8. <view class="footer">
  9. <view class="icons">
  10. <view class="box" @click="goPage('/pages/index/index', 'switchTab')">
  11. <view class="icon ibonfont ibonhome"></view>
  12. <view class="text">首页</view>
  13. </view>
  14. <!-- <view class="box" @click="shareGoods">
  15. <view class="icon ibonfont ibonfenxiang2"></view>
  16. <view class="text">分享</view>
  17. </view> -->
  18. </view>
  19. <view class="btn"><view class="buy primary-bg" @click="openaddcartPop('btn')">立即兑换</view></view>
  20. </view>
  21. <!-- 商品主图轮播 -->
  22. <view class="swiper-box">
  23. <swiper circular="true" autoplay="true" @change="swiperChange">
  24. <swiper-item v-for="(item, index) in imgList" :key="index"><image :src="item" mode="aspectFit" @click="previewImage(index)"></image></swiper-item>
  25. </swiper>
  26. <view class="indicator">{{ currentSwiper + 1 }}/{{ imgList.length }}</view>
  27. </view>
  28. <!-- 标题 价格 -->
  29. <view class="goods-info">
  30. <!-- 商品信息 -->
  31. <view class="price-view primary-bg clearfix">
  32. <view class="float_left">
  33. <view style="display: inline-block;"><rich-text :nodes="$_utils.splitPrice(goods_detail.integral, 12)"></rich-text></view>
  34. <text style="font-size: 24rpx;margin-left: 6rpx;">股权</text>
  35. </view>
  36. <view class="right-view">
  37. <view class="goods-num">
  38. <view class="num-li">已兑换{{ goods_detail.changeNum }}件</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="goods-info-main">
  43. <view class="title">{{ goods_detail.name || '' }}</view>
  44. <view class="desc">{{ goods_detail.desc || '' }}</view>
  45. </view>
  46. </view>
  47. <!-- 详情 -->
  48. <view class="description">
  49. <view class="title">———— 商品详情 ————</view>
  50. <view class="content"><u-parse :html="goods_detail.details"></u-parse></view>
  51. </view>
  52. <u-popup mode="bottom" v-model="sharePop">
  53. <view class="share-tit">分享</view>
  54. <view class="share-ul">
  55. <!-- #ifdef MP -->
  56. <view class="share-li">
  57. <button class="share-btn" open-type="share">
  58. <view class="icon-view"><u-icon name="weixin-fill" top="12" color="#ffffff" size="60"></u-icon></view>
  59. <view class="share-btn-label">分享给好友</view>
  60. </button>
  61. </view>
  62. <!-- #endif -->
  63. <view class="share-li" @click="generatePoster">
  64. <button class="share-btn">
  65. <view class="icon-view"><u-icon name="photo-fill" top="12" color="#ffffff" size="60"></u-icon></view>
  66. <view class="share-btn-label">生成分享海报</view>
  67. </button>
  68. </view>
  69. </view>
  70. <view class="share-cancel" @click="cancelPop">取消分享</view>
  71. </u-popup>
  72. </block>
  73. </view>
  74. </template>
  75. <script>
  76. import webUrl from '../../config.js';
  77. export default {
  78. data() {
  79. return {
  80. //轮播图下标
  81. currentSwiper: 0,
  82. sharePop: false, // 分享弹窗
  83. canvasPop: false, // 海报弹窗
  84. is_poster: false,
  85. buy_num: 1,
  86. activity: [],
  87. indicatorDots: true, //是否显示面板指示点
  88. autoplay: true, //是否自动切换
  89. interval: 2000,
  90. duration: 500,
  91. goods_detail: {},
  92. goods_id: '',
  93. imgList: [],
  94. QrSrc: '',
  95. pageName: '', // 启动页标示
  96. };
  97. },
  98. onShareAppMessage() {
  99. return {
  100. title: this.goods_detail.title,
  101. path: `/pagesT/product/product?id=${this.goods_id}&businessmanId=${this.$store.state.userStatus.id||''}` ,
  102. imageUrl: this.imgList[0],
  103. success: res => {
  104. console.log(res);
  105. }
  106. };
  107. },
  108. // #ifdef MP-WEIXIN
  109. // 分享到朋友圈
  110. onShareTimeline(obj) {
  111. console.log('分享到朋友圈::', obj);
  112. },
  113. // 收藏小程序
  114. onAddToFavorites() {},
  115. // #endif
  116. async onLoad(options) {
  117. if (options.pageName) {
  118. this.pageName = options.pageName || '电饭锅';
  119. }
  120. // #ifdef MP-WEIXIN
  121. // 小程序的原生菜单中显示分享按钮
  122. uni.showShareMenu({
  123. withShareTicket: false,
  124. menus: ['shareAppMessage', 'shareTimeline']
  125. });
  126. // #endif
  127. // 接收传值
  128. if (options.id) {
  129. this.goods_id = options.id;
  130. } else {
  131. // 扫码进入
  132. const scene = decodeURIComponent(options.scene);
  133. this.goods_id = scene;
  134. }
  135. await this.getIntegralGoodsInfo();
  136. // await this.getQrSrc();
  137. },
  138. methods: {
  139. getQrSrc() {
  140. // #ifdef MP-TOUTIAO
  141. let pathT = 'pagesT/product/product?id=' + this.goods_id;
  142. pathT = encodeURIComponent(pathT);
  143. this.$u.api
  144. .byteCreateQRCode({
  145. path: pathT,
  146. params: this.goods_id,
  147. appname: 'toutiao'
  148. })
  149. .then(data => {
  150. this.QrSrc = data.data.indexOf('https') > -1 ? data.data : webUrl.QRC_SRC + data.data;
  151. });
  152. // #endif
  153. // #ifdef MP-WEIXIN || H5
  154. let pathS = 'pagesT/product/product';
  155. this.$u.api
  156. .createwxaqrcode({
  157. path: pathS,
  158. params: this.goods_id
  159. })
  160. .then(data => {
  161. this.QrSrc = data.data.indexOf('https') > -1 ? data.data : webUrl.QRC_SRC + data.data;
  162. console.log(this.QrSrc);
  163. });
  164. // #endif
  165. },
  166. handelImg(url) {
  167. if (url.indexOf('?imageView2/2/w/750/h/750') > -1) {
  168. return url.replace('?imageView2/2/w/750/h/750', '');
  169. } else if (url.indexOf('?imageView2/2/w/750') > -1) {
  170. return url.replace('?imageView2/2/w/750', '');
  171. } else {
  172. return url;
  173. }
  174. },
  175. generatePoster() {
  176. // this.is_poster = true;
  177. // this.canvasPop = true;
  178. // this.sharePop = false;
  179. const pramas = {
  180. id: this.goods_detail.id,
  181. priceShop: '¥' + this.goods_detail.maxMarketPrice,
  182. headImgs: this.goods_detail.images.map(item => this.handelImg(item)),
  183. goodsImg: this.handelImg(this.goods_detail.images[0]),
  184. goodsName: this.goods_detail.title,
  185. goodsPrice: '¥' + this.goods_detail.minSalePrice,
  186. mainLogo: '',
  187. recommendCodeGoods: this.QrSrc,
  188. share: {
  189. shareContent: this.$store.state.baseSet.shop || '',
  190. shareImg: this.handelImg(this.goods_detail.images[0]),
  191. shareTitle: this.goods_detail.title,
  192. shareUrl: this.handelImg(this.goods_detail.images[0])
  193. }
  194. };
  195. console.log(pramas);
  196. uni.navigateTo({
  197. url: '/pagesT/product/goodsPoster?goodsData=' + JSON.stringify(pramas)
  198. });
  199. // this.goPage('/pages/index/goodsPoster?goodsData=' + JSON.stringify(pramas));
  200. },
  201. shareGoods() {
  202. this.sharePop = true;
  203. },
  204. //App分享为微信小程序(App中分享一个内容到微信好友,对方微信中呈现的是一个小程序卡片)
  205. shareFriend() {
  206. const path = '/pagesT/product/product?id=' + this.goods_id;
  207. uni.share({
  208. provider: 'weixin',
  209. scene: 'WXSceneSession',
  210. type: 5,
  211. imageUrl: this.imgList[0],
  212. title: this.goods_detail.title,
  213. miniProgram: {
  214. id: 'gh_16db94f79967', //微信小程序原始ID
  215. path: path,
  216. type: 0,
  217. webUrl: ''
  218. },
  219. success: ret => {
  220. console.log(JSON.stringify(ret));
  221. }
  222. });
  223. },
  224. // 分享弹窗关闭
  225. cancelPop() {
  226. this.sharePop = false;
  227. },
  228. // 请求商品品详情
  229. async getIntegralGoodsInfo() {
  230. this.$u.api.getIntegralGoodsInfo(this.goods_id).then(({ data }) => {
  231. uni.setNavigationBarTitle({
  232. title: data.name
  233. });
  234. this.imgList = data.images;
  235. this.goods_detail = data;
  236. });
  237. },
  238. //分享
  239. share() {
  240. this.$refs.share.toggleMask();
  241. },
  242. openaddcartPop(type) {
  243. this.goPage('/pagesT/pointsMall/ExchangeOrder?id='+this.goods_id)
  244. },
  245. previewImage(index) {
  246. let urls = JSON.parse(JSON.stringify(this.imgList));
  247. if (index > 0) {
  248. urls.unshift(urls[index]);
  249. }
  250. uni.previewImage({
  251. urls: urls,
  252. longPressActions: {
  253. itemList: ['发送给朋友', '保存图片', '收藏'],
  254. success: data => {
  255. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  256. },
  257. fail: err => {
  258. console.log(err.errMsg);
  259. }
  260. }
  261. });
  262. },
  263. //轮播图指示器
  264. swiperChange(event) {
  265. this.currentSwiper = event.detail.current;
  266. },
  267. back() {
  268. if (this.pageName) {
  269. this.goPage('/pages/index/index', 'switchTab');
  270. } else {
  271. uni.navigateBack();
  272. }
  273. }
  274. }
  275. };
  276. </script>
  277. <style lang="scss">
  278. @keyframes showPopup {
  279. 0% {
  280. opacity: 0;
  281. }
  282. 100% {
  283. opacity: 1;
  284. }
  285. }
  286. @keyframes hidePopup {
  287. 0% {
  288. opacity: 1;
  289. }
  290. 100% {
  291. opacity: 0;
  292. }
  293. }
  294. @keyframes showLayer {
  295. 0% {
  296. transform: translateY(0);
  297. }
  298. 100% {
  299. transform: translateY(-100%);
  300. }
  301. }
  302. @keyframes hideLayer {
  303. 0% {
  304. transform: translateY(-100%);
  305. }
  306. 100% {
  307. transform: translateY(0);
  308. }
  309. }
  310. .icon {
  311. font-size: 26upx;
  312. }
  313. .back-icon {
  314. font-size: 36rpx;
  315. padding-left: 24rpx;
  316. color: #2a2a2a;
  317. }
  318. .swiper-box {
  319. background-color: #ffffff;
  320. position: relative;
  321. width: 100%;
  322. height: 100vw;
  323. swiper {
  324. width: 100%;
  325. height: 100vw;
  326. swiper-item {
  327. image {
  328. width: 100%;
  329. height: 100vw;
  330. }
  331. }
  332. }
  333. .indicator {
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. padding: 0 25upx;
  338. height: 40upx;
  339. border-radius: 4upx;
  340. font-size: 22upx;
  341. position: absolute;
  342. bottom: 50upx;
  343. right: 30upx;
  344. color: #fff;
  345. background-color: rgba(0, 0, 0, 0.2);
  346. }
  347. }
  348. .goods-info {
  349. overflow: hidden;
  350. transform: translateY(-36rpx);
  351. .price-view {
  352. padding: 0 30rpx;
  353. height: 152rpx;
  354. background-color: #fa6400;
  355. color: #ffffff;
  356. border-radius: 48rpx 48rpx 0 0;
  357. position: relative;
  358. .float_left {
  359. line-height: 120rpx;
  360. font-size: 48rpx;
  361. font-family: DIN-Medium;
  362. }
  363. .right-view {
  364. position: absolute;
  365. right: 30rpx;
  366. top: calc(50% - 16rpx);
  367. transform: translateY(-50%);
  368. font-size: 24rpx;
  369. .goods-num {
  370. text-align: right;
  371. .num-li {
  372. display: inline-block;
  373. font-weight: 400;
  374. margin-left: 20rpx;
  375. }
  376. }
  377. }
  378. }
  379. .goods-info-main {
  380. transform: translateY(-32rpx);
  381. padding: 30rpx;
  382. background: #ffffff;
  383. border-radius: 32rpx 32rpx 8rpx 8rpx;
  384. .title {
  385. font-size: 32rpx;
  386. letter-spacing: 1px;
  387. color: #2a2a2a;
  388. font-weight: 500;
  389. }
  390. .desc {
  391. padding-top: 10rpx;
  392. font-size: 24rpx;
  393. color: #999999;
  394. }
  395. }
  396. }
  397. .info-box {
  398. padding: 16rpx 30upx;
  399. background-color: #fff;
  400. border-radius: 12upx;
  401. transform: translateY(-48rpx);
  402. margin-top: 16rpx;
  403. .row {
  404. width: 100%;
  405. display: flex;
  406. align-items: center;
  407. position: relative;
  408. line-height: 80rpx;
  409. .text {
  410. font-size: 28upx;
  411. color: #9a9a9a;
  412. margin-right: 40upx;
  413. }
  414. .content {
  415. .no-sel {
  416. color: #9a9a9a;
  417. }
  418. }
  419. .arrow {
  420. position: absolute;
  421. right: 0;
  422. .icon {
  423. color: #afafaf;
  424. }
  425. }
  426. }
  427. }
  428. .description {
  429. padding-bottom: 100upx;
  430. .title {
  431. width: 100%;
  432. height: 80upx;
  433. display: flex;
  434. justify-content: center;
  435. align-items: center;
  436. font-size: 26upx;
  437. color: #999;
  438. }
  439. }
  440. .footer {
  441. position: fixed;
  442. bottom: 0upx;
  443. width: 100%;
  444. padding: 12upx 30rpx;
  445. background-color: #ffffff;
  446. z-index: 2;
  447. display: flex;
  448. justify-content: space-between;
  449. align-items: center;
  450. box-shadow: 0px -3rpx 32rpx 0px rgba(156, 170, 175, 0.16);
  451. .icons {
  452. height: 74upx;
  453. .box {
  454. height: 64upx;
  455. margin-left: 32rpx;
  456. display: inline-block;
  457. text-align: center;
  458. .icon {
  459. font-size: 36upx;
  460. color: #000000;
  461. }
  462. .text {
  463. display: flex;
  464. justify-content: center;
  465. width: 100%;
  466. font-size: 20upx;
  467. color: #3c3c3c;
  468. padding-top: 5rpx;
  469. }
  470. &:first-child {
  471. margin-left: 10rpx;
  472. padding-right: 24rpx;
  473. position: relative;
  474. &::after {
  475. position: absolute;
  476. top: 10rpx;
  477. right: 0;
  478. content: ' ';
  479. display: inline-block;
  480. width: 1px;
  481. height: 48rpx;
  482. background: #d8d8d8;
  483. border-radius: 2rpx;
  484. }
  485. }
  486. }
  487. }
  488. .btn {
  489. overflow: hidden;
  490. .buy {
  491. border-radius: 8upx;
  492. height: 74upx;
  493. width: 480upx;
  494. color: #ffffff;
  495. display: inline-block;
  496. line-height: 74upx;
  497. text-align: center;
  498. font-size: 28upx;
  499. }
  500. }
  501. }
  502. .share {
  503. display: none;
  504. &.show {
  505. display: block;
  506. .mask {
  507. animation: showPopup 0.15s linear both;
  508. }
  509. .layer {
  510. animation: showLayer 0.15s linear both;
  511. }
  512. }
  513. &.hide {
  514. display: block;
  515. .mask {
  516. animation: hidePopup 0.15s linear both;
  517. }
  518. .layer {
  519. animation: hideLayer 0.15s linear both;
  520. }
  521. }
  522. &.none {
  523. display: none;
  524. }
  525. .mask {
  526. background-color: rgba(0, 0, 0, 0.5);
  527. position: fixed;
  528. width: 100%;
  529. height: 100%;
  530. top: 0;
  531. z-index: 11;
  532. }
  533. .layer {
  534. width: 92%;
  535. position: fixed;
  536. z-index: 12;
  537. padding: 0 4%;
  538. top: 100%;
  539. background-color: rgba(255, 255, 255, 0.9);
  540. .list {
  541. width: 100%;
  542. display: flex;
  543. padding: 10upx 0 30upx 0;
  544. .box {
  545. width: 25%;
  546. display: flex;
  547. justify-content: center;
  548. flex-wrap: wrap;
  549. image {
  550. width: 13.8vw;
  551. height: 13.8vw;
  552. }
  553. .title {
  554. margin-top: 10upx;
  555. display: flex;
  556. justify-content: center;
  557. width: 100%;
  558. font-size: 26upx;
  559. }
  560. }
  561. }
  562. .btn {
  563. width: 100%;
  564. height: 100upx;
  565. display: flex;
  566. justify-content: center;
  567. align-items: center;
  568. font-size: 28upx;
  569. border-top: solid 1upx #666666;
  570. }
  571. .h1 {
  572. width: 100%;
  573. height: 80upx;
  574. display: flex;
  575. justify-content: center;
  576. align-items: center;
  577. font-size: 34upx;
  578. }
  579. }
  580. }
  581. .share-tit {
  582. line-height: 80upx;
  583. text-align: center;
  584. font-size: 32upx;
  585. }
  586. .share-cancel {
  587. line-height: 80upx;
  588. text-align: center;
  589. font-size: 28upx;
  590. border-top: 1px solid #f4f4f4;
  591. }
  592. .share-ul {
  593. display: flex;
  594. padding: 50upx 0;
  595. .share-li {
  596. flex: 3;
  597. .share-btn {
  598. background-color: #ffffff;
  599. font-size: 26upx;
  600. &::after {
  601. border: 0 none;
  602. }
  603. .icon-view {
  604. display: inline-block;
  605. width: 100upx;
  606. height: 100upx;
  607. border-radius: 100%;
  608. background-color: #18b566;
  609. line-height: 100upx;
  610. text-align: center;
  611. margin-bottom: 10upx;
  612. }
  613. }
  614. }
  615. }
  616. </style>