goods.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <template>
  2. <view class="">
  3. <view class="content" v-cloak>
  4. <view class="shop-banner">
  5. <view class="shop-banner" @click="showImg()">
  6. <swiper class="swiper" :indicator-dots="false" :circular="true" :autoplay="true" :interval="3000"
  7. :duration="1000" indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#ffffff"
  8. @change="swiperChange">
  9. <swiper-item class="swiper-item" v-for="(item,index) in banner" :key="index">
  10. <image :src="item" mode="aspectFill"></image>
  11. </swiper-item>
  12. </swiper>
  13. <!-- 底部遮罩 -->
  14. <view class="banner-mask"></view>
  15. <!-- 数量 -->
  16. <view class="num-box">{{ activeBanner }}/{{ banner.length }}</view>
  17. </view>
  18. </view>
  19. <!-- 详细信息 -->
  20. <view class="det-info">
  21. <view class="price-box">
  22. <view class="price">
  23. <text class="label">会员价</text>
  24. <text class="unit">¥</text>
  25. <text class="num">{{goosDetail.price}}</text>
  26. <text class="fs24 color-text2">零售价</text>
  27. <text class="old">¥{{goosDetail.otPrice}}</text>
  28. </view>
  29. <text class="fs24 color-text2">月售{{goosDetail.sales}}件</text>
  30. </view>
  31. <view class="name-box">
  32. {{goosDetail.productName}}
  33. </view>
  34. </view>
  35. </view>
  36. <view class="guige">
  37. <view class="safe-box">
  38. <text class="text">服务</text>
  39. <view class="box">
  40. <image class="mr20" src="/static/images/safe.png" mode=""></image>
  41. <view class="mr30" v-for="(item,index) in serviceList" :key="index">
  42. <text>{{item}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 购买人数、库存 -->
  48. <view class="det-box">
  49. <view class="title">图文详情</view>
  50. <view class="inner">
  51. <view v-html="goosDetail.description" style="font-size:0"></view>
  52. </view>
  53. </view>
  54. <!-- 底部按钮 -->
  55. <view class="btn-foot">
  56. <view class="menu-box">
  57. </view>
  58. <view class="btn-box">
  59. <view class="btn buy" @click="addCart('buy')">{{buyText}}</view>
  60. </view>
  61. </view>
  62. <!-- 选择药品规格弹窗 -->
  63. <popupBottom ref="popup" :visible.sync="specVisible" title=" " radius="32" maxHeight="800">
  64. <view class="product-spec">
  65. <view class="pro-info">
  66. <view class="img-box">
  67. <image :src="goosDetail.image ||'/static/images/img.png'" mode="aspectFill"></image>
  68. </view>
  69. <view class="info-text">
  70. <view class="info-title">{{goosDetail.productName}}</view>
  71. <view class="price">
  72. <view class="label">会员价</view>
  73. <text class="unit">¥</text>
  74. <text class="num">{{ goosDetail.price}}</text>
  75. </view>
  76. <view class="desc-box">
  77. <text class="text">月售{{goosDetail.sales}}件</text>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="price-num">
  82. <view class="label">数量</view>
  83. <u-number-box bgColor="#f3f3f3" v-model="goodsNum" @change="goodsNumChange"></u-number-box>
  84. </view>
  85. <view class="sub-btn" @click="submit">确定</view>
  86. </view>
  87. </popupBottom>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. liveGoodsDetail
  93. } from '@/api/living'
  94. import {
  95. liveOrderKey, // 生成订单key
  96. } from "@/api/order.js"
  97. import popupBottom from '@/components/px-popup-bottom/px-popup-bottom.vue'
  98. export default {
  99. components: {
  100. popupBottom
  101. },
  102. data() {
  103. return {
  104. banner: [],
  105. goodsId: null,
  106. totalNum: 1,
  107. orderKey: null,
  108. type: null,
  109. liveId: null,
  110. storeId: null,
  111. serviceList: ['品质保障', '药师服务', '隐私保护'],
  112. productId: null,
  113. goosDetail: {}, //商品详情
  114. loadding: true,
  115. buyText: "立即购买",
  116. goodsNum: 0, //商品选择数量
  117. attrs: [],
  118. values: [],
  119. stores: [],
  120. storeNames: [],
  121. storeIdx: 0,
  122. storeName: "",
  123. product: {
  124. price: 0,
  125. otPrice: 0,
  126. },
  127. showModal: false,
  128. // 当前轮播的图片
  129. activeBanner: 1,
  130. // 购物车数量
  131. cartCount: 0,
  132. // 规格弹窗
  133. specVisible: false,
  134. // // 规格数量
  135. // specNum: 1,
  136. config: null,
  137. showServiceFee: false,
  138. selectVal: "",
  139. // 链接带的storeId
  140. urlStoreId: undefined,
  141. // 所选店铺
  142. storeSelectInfo: {},
  143. // 保存选的规格
  144. choseSpecSubIndex: 0,
  145. choseSpecIndex: 0,
  146. };
  147. },
  148. onLoad(options) {
  149. console.log("商品详情options", options)
  150. if (options.productId) {
  151. this.productId = options.productId;
  152. }
  153. this.liveId = options.liveId
  154. this.goodsId = options.goodsId
  155. if (options.storeId) {
  156. this.storeId = options.storeId || ""
  157. } else {
  158. uni.showToast({
  159. title: "storeId不存在~",
  160. icon: "none"
  161. })
  162. }
  163. },
  164. mounted() {
  165. this.getliveGoods()
  166. var userInfo = uni.getStorageSync("userInfo")
  167. },
  168. methods: {
  169. // swiper变化事件
  170. swiperChange(event) {
  171. this.activeBanner = event.detail.current + 1
  172. },
  173. doAddCart(type) {
  174. if (this.totalNum == 0) {
  175. uni.showToast({
  176. icon: 'none',
  177. title: "库存不足",
  178. });
  179. return;
  180. }
  181. var isBuy = type == "buy" ? 1 : 0;
  182. if (type == "buy") {
  183. this.getKey()
  184. } else {
  185. this.getCartCount()
  186. uni.showToast({
  187. icon: 'success',
  188. title: "添加成功",
  189. });
  190. }
  191. },
  192. // 获得key
  193. getKey() {
  194. liveOrderKey().then(res => {
  195. if (res.code == 200) {
  196. console.log("下订单的key>>>>", res)
  197. this.orderKey = res.orderKey
  198. console.log("key>>>>", this.orderKey)
  199. uni.navigateTo({
  200. url: '/pages_shopping/live/confirmCreateOrder?&orderKey=' + this.orderKey +
  201. '&liveId=' + this.liveId + '&goodsId=' + this.goodsId +
  202. '&productId=' + this.productId + '&totalNum=' + this
  203. .totalNum
  204. })
  205. } else {
  206. uni.showToast({
  207. title: res.msg,
  208. icon: 'none'
  209. });
  210. }
  211. },
  212. rej => {}
  213. );
  214. },
  215. // 选择商品数量
  216. goodsNumChange(e) {
  217. console.log('当前选择商品数量为: ' + e.value)
  218. this.totalNum = e.value
  219. },
  220. // 提交
  221. submit() {
  222. this.specVisible = false
  223. this.doAddCart(this.type);
  224. },
  225. // 加入购物车
  226. addCart(type) {
  227. this.type = type;
  228. this.specVisible = true
  229. },
  230. // 跳转页面
  231. navgetTo(url) {
  232. uni.navigateTo({
  233. url: url
  234. })
  235. },
  236. // openEditMoney() {
  237. // this.editShow = true;
  238. // },
  239. // cancelEditMoney(){
  240. // this.editShow = false;
  241. // },
  242. //商品详情
  243. getliveGoods() {
  244. if (!this.productId) return;
  245. uni.showLoading({
  246. title: '加载中'
  247. });
  248. liveGoodsDetail(this.productId).then(res => {
  249. uni.hideLoading()
  250. if (res.code == 200) {
  251. // console.log("小黄车 商品详情>>>>", res)
  252. this.goosDetail = res.data
  253. this.banner = res.data.sliderImage.split(',');
  254. // console.log("轮播图",this.banner)
  255. } else {
  256. uni.showToast({
  257. title: res.msg,
  258. icon: 'none'
  259. });
  260. }
  261. },
  262. rej => {}
  263. );
  264. },
  265. }
  266. }
  267. </script>
  268. <style lang="scss">
  269. [v-cloak] {
  270. display: none;
  271. }
  272. .content {
  273. font-family: PingFang SC;
  274. }
  275. .shop-banner {
  276. height: 756rpx;
  277. background-color: #FFFFFF;
  278. position: relative;
  279. .swiper-item {
  280. box-sizing: border-box;
  281. position: relative;
  282. }
  283. .swiper,
  284. .swiper-item,
  285. .swiper-item image {
  286. width: 100%;
  287. height: 100%;
  288. }
  289. .banner-mask {
  290. width: 100%;
  291. height: 44rpx;
  292. position: absolute;
  293. left: 0;
  294. bottom: 0;
  295. z-index: 9;
  296. background-size: 20rpx 44rpx;
  297. background-repeat: repeat-x;
  298. }
  299. .num-box {
  300. width: 80rpx;
  301. height: 40rpx;
  302. line-height: 40rpx;
  303. text-align: center;
  304. font-size: 24rpx;
  305. color: #FFFFFF;
  306. background: rgba(0, 0, 0, .7);
  307. border-radius: 20rpx;
  308. position: absolute;
  309. right: 40rpx;
  310. bottom: 34rpx;
  311. z-index: 10;
  312. }
  313. .cf-box {
  314. position: absolute;
  315. z-index: 10;
  316. left: 0;
  317. right: 0;
  318. top: calc(50% - 200rpx);
  319. bottom: calc(50% - 200rpx);
  320. background-color: rgba(0, 0, 0, 0.3);
  321. backdrop-filter: blur(2rpx);
  322. /* 背景模糊度 */
  323. display: flex;
  324. flex-direction: column;
  325. flex: 1;
  326. justify-content: center;
  327. align-items: center;
  328. color: #EDEEEF;
  329. .title {
  330. font-size: 40rpx;
  331. font-weight: bold;
  332. }
  333. .subTitle {
  334. font-size: 28rpx;
  335. font-weight: bold;
  336. margin-top: 10rpx;
  337. }
  338. }
  339. }
  340. .guige {
  341. padding: 24rpx;
  342. border-radius: 16rpx;
  343. background: #fff;
  344. width: auto;
  345. font-size: 24rpx;
  346. color: #222426;
  347. margin: 24rpx;
  348. .guige-gg {
  349. .gg-text {
  350. color: #898E91;
  351. margin-right: 40rpx;
  352. }
  353. }
  354. .safe-box {
  355. display: flex;
  356. align-items: center;
  357. padding-top: 24rpx;
  358. font-size: 24rpx;
  359. color: #222426;
  360. .text {
  361. color: #999999;
  362. margin-right: 40rpx;
  363. }
  364. .box {
  365. display: flex;
  366. align-items: center;
  367. image {
  368. width: 28rpx;
  369. height: 28rpx;
  370. margin-right: 10rpx;
  371. }
  372. view {
  373. display: flex;
  374. align-items: center;
  375. margin-right: 40rpx;
  376. &:last-child {
  377. margin-right: 0;
  378. image {
  379. margin-right: 0;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. .det-info {
  387. background: #FFFFFF;
  388. padding: 24rpx;
  389. margin: 24rpx;
  390. border-radius: 16rpx;
  391. .price-box {
  392. display: flex;
  393. align-items: flex-end;
  394. justify-content: space-between;
  395. .price {
  396. display: flex;
  397. align-items: flex-end;
  398. .label {
  399. font-weight: 500;
  400. font-size: 24rpx;
  401. color: #FF5030;
  402. line-height: 1.3;
  403. margin-right: 10rpx;
  404. }
  405. .unit {
  406. font-size: 26rpx;
  407. font-weight: bold;
  408. color: #FF6633;
  409. line-height: 1.3;
  410. }
  411. .num {
  412. font-size: 48rpx;
  413. font-weight: bold;
  414. color: #FF5030;
  415. margin-right: 20rpx;
  416. line-height: 1;
  417. }
  418. .old {
  419. font-size: 24rpx;
  420. font-family: PingFang SC;
  421. font-weight: 400;
  422. text-decoration: line-through;
  423. color: #898E91;
  424. margin-left: 10rpx;
  425. line-height: 1.3;
  426. }
  427. }
  428. .spec {
  429. font-size: 24rpx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. color: #999999;
  433. line-height: 36rpx;
  434. }
  435. }
  436. .name-box {
  437. font-size: 32rpx;
  438. font-weight: bold;
  439. color: #111111;
  440. line-height: 44rpx;
  441. margin-top: 32rpx;
  442. .tag {
  443. display: inline-block;
  444. padding: 2rpx 8rpx;
  445. height: 32rpx;
  446. background: #F5A623;
  447. border-radius: 4rpx;
  448. margin-right: 10rpx;
  449. font-weight: 400;
  450. font-size: 20rpx;
  451. color: #FFFFFF;
  452. line-height: 30rpx;
  453. float: left;
  454. margin-top: 7rpx;
  455. }
  456. }
  457. .intro {
  458. font-size: 26rpx;
  459. font-weight: 500;
  460. color: #999999;
  461. line-height: 36rpx;
  462. padding: 18rpx 0 23rpx;
  463. }
  464. .safe-box {
  465. display: flex;
  466. align-items: center;
  467. padding-top: 24rpx;
  468. image {
  469. width: 20rpx;
  470. height: 24rpx;
  471. margin-right: 20rpx;
  472. }
  473. .text {
  474. font-size: 22rpx;
  475. font-weight: 500;
  476. color: #999999;
  477. line-height: 1;
  478. }
  479. .line {
  480. width: 1px;
  481. height: 23rpx;
  482. background: #EDEEEF;
  483. margin: 0 20rpx;
  484. }
  485. }
  486. }
  487. .det-box {
  488. margin-top: 10rpx;
  489. background-color: #FFFFFF;
  490. padding: 24rpx;
  491. margin: 24rpx 24rpx 175rpx 24rpx;
  492. border-radius: 16rpx;
  493. .title {
  494. font-size: 32rpx;
  495. font-weight: bold;
  496. color: #333333;
  497. line-height: 60rpx;
  498. margin-bottom: 30rpx;
  499. padding-bottom: 24rpx;
  500. border-bottom: 1px solid #ECECEC;
  501. }
  502. .inner {
  503. margin-bottom: 100rpx;
  504. }
  505. }
  506. .btn-foot {
  507. box-sizing: border-box;
  508. width: 100%;
  509. height: 151rpx;
  510. background: #FFFFFF;
  511. padding: 0 24rpx;
  512. display: flex;
  513. align-items: center;
  514. justify-content: space-between;
  515. position: fixed;
  516. left: 0;
  517. bottom: 0;
  518. z-index: 99;
  519. .menu-box {
  520. display: flex;
  521. align-items: center;
  522. .item {
  523. display: flex;
  524. align-items: center;
  525. flex-direction: column;
  526. margin-right: 48rpx;
  527. &:last-child {
  528. margin-right: 0;
  529. }
  530. image {
  531. width: 40rpx;
  532. height: 40rpx;
  533. margin-bottom: 10rpx;
  534. }
  535. .label {
  536. font-size: 20rpx;
  537. font-weight: 500;
  538. color: #626468;
  539. text-align: center;
  540. }
  541. }
  542. }
  543. .btn-box {
  544. display: flex;
  545. align-items: center;
  546. .btn {
  547. width: 200rpx;
  548. height: 88rpx;
  549. line-height: 88rpx;
  550. text-align: center;
  551. border-radius: 44rpx;
  552. margin-left: 20rpx;
  553. font-size: 28rpx;
  554. font-weight: bold;
  555. color: #FFFFFF;
  556. &:first-child {
  557. margin-left: 0;
  558. }
  559. &.cart {
  560. background: #FF5030;
  561. }
  562. &.buy {
  563. background: #2bc7b9;
  564. }
  565. }
  566. }
  567. }
  568. .product-spec {
  569. padding-bottom: 30rpx;
  570. .pro-info {
  571. display: flex;
  572. align-items: center;
  573. .img-box {
  574. width: 200rpx;
  575. height: 200rpx;
  576. background: #FFFFFF;
  577. border-radius: 16rpx;
  578. overflow: hidden;
  579. margin-right: 30rpx;
  580. image {
  581. width: 100%;
  582. height: 100%;
  583. }
  584. }
  585. .info-text {
  586. height: 200rpx;
  587. display: flex;
  588. flex-direction: column;
  589. justify-content: space-between;
  590. .info-title {
  591. font-family: PingFang SC;
  592. font-weight: 600;
  593. font-size: 28rpx;
  594. color: #222426;
  595. text-align: left;
  596. }
  597. .price {
  598. display: flex;
  599. align-items: flex-end;
  600. .label {
  601. font-weight: 500;
  602. font-size: 24rpx;
  603. color: #FF5030;
  604. line-height: 1.3;
  605. margin-right: 10rpx;
  606. }
  607. .unit {
  608. font-size: 32rpx;
  609. font-weight: bold;
  610. color: #FF6633;
  611. line-height: 1.2;
  612. margin-right: 10rpx;
  613. }
  614. .num {
  615. font-size: 50rpx;
  616. font-weight: bold;
  617. color: #FF6633;
  618. line-height: 1;
  619. }
  620. }
  621. .desc-box {
  622. display: flex;
  623. flex-direction: column;
  624. padding-bottom: 9rpx;
  625. .text {
  626. font-size: 26rpx;
  627. font-weight: 500;
  628. color: #999999;
  629. margin-top: 27rpx;
  630. line-height: 1;
  631. &:first-child {
  632. margin-top: 0;
  633. }
  634. }
  635. }
  636. }
  637. }
  638. .price-num {
  639. display: flex;
  640. align-items: center;
  641. justify-content: space-between;
  642. margin-top: 30rpx;
  643. .label {
  644. font-size: 36rpx;
  645. font-weight: bold;
  646. color: #111111;
  647. }
  648. }
  649. .sub-btn {
  650. width: 100%;
  651. height: 88rpx;
  652. line-height: 88rpx;
  653. text-align: center;
  654. font-size: 32rpx;
  655. font-weight: bold;
  656. color: #FFFFFF;
  657. background: #2BC7B9;
  658. border-radius: 44rpx;
  659. margin-top: 30rpx;
  660. }
  661. }
  662. .loadding {
  663. background-color: #fff;
  664. display: flex;
  665. flex-direction: column;
  666. align-items: center;
  667. justify-content: center;
  668. position: absolute;
  669. top: 0;
  670. left: 0;
  671. width: 100%;
  672. height: 100%;
  673. z-index: 9999;
  674. image {
  675. border-radius: 50%;
  676. animation: load linear 1s infinite;
  677. width: 120rpx;
  678. height: 120rpx;
  679. }
  680. .text {
  681. font-size: 28rpx;
  682. margin-top: 20rpx;
  683. }
  684. }
  685. </style>