productShowDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view class="content">
  3. <!-- 商品轮播图片 -->
  4. <view class="shop-banner" @click="showImg()">
  5. <swiper
  6. class="swiper"
  7. :indicator-dots="false"
  8. :circular="true"
  9. :autoplay="true"
  10. :interval="3000"
  11. :duration="1000"
  12. indicator-color="rgba(255, 255, 255, 0.6)"
  13. indicator-active-color="#ffffff"
  14. @change="swiperChange"
  15. >
  16. <swiper-item class="swiper-item" v-for="(item,index) in banner" :key="index">
  17. <image :src="item" mode="aspectFill"></image>
  18. </swiper-item>
  19. </swiper>
  20. <!-- 底部遮罩 -->
  21. <view class="banner-mask"></view>
  22. <!-- 数量 -->
  23. <view class="num-box">{{ activeBanner }}/{{ banner.length }}</view>
  24. </view>
  25. <!-- 详细信息 -->
  26. <view class="det-info">
  27. <view class="price-box">
  28. <view class="price">
  29. <text class="label">会员价</text>
  30. <text class="unit">¥</text>
  31. <text class="num" >{{product.price}}</text>
  32. <text class="label">零售价</text>
  33. <text class="old" >¥{{product.otPrice}}</text>
  34. </view>
  35. </view>
  36. <view class="name-box">
  37. <view class="tag">{{utils.getDictLabelName("storeProductType",product.productType)}}</view>{{product.productName}}
  38. </view>
  39. <view class="intro">
  40. {{product.productInfo}}
  41. </view>
  42. <view class="safe-box">
  43. <image src="https://kntobs.jnmyunl.com/shop/images/safe.png" mode=""></image>
  44. <text class="text">免邮发货</text>
  45. <view class="line"></view>
  46. <text class="text">药师服务</text>
  47. <view class="line"></view>
  48. <text class="text">隐私保护</text>
  49. </view>
  50. </view>
  51. <!-- 购买人数、库存 -->
  52. <view class="inventor">
  53. <view class="left">
  54. <!-- <view class="head-box">
  55. <view class="head" v-for="(item,j) in 5" :key="j">
  56. <image src="https://kntobs.jnmyunl.com/shop/images/head.jpg" mode=""></image>
  57. </view>
  58. </view> -->
  59. <view class="num-box">
  60. 已有 <text class="text">{{product.sales}}</text> 人购买
  61. </view>
  62. </view>
  63. <!-- <view class="right">
  64. 库存 <text class="text">{{product.stock}}{{product.unitName}}</text>
  65. </view> -->
  66. <!-- <view class="right">
  67. <text class="text">库存{{product.stock>0?'充足':'售罄'}} </text>
  68. </view> -->
  69. </view>
  70. <!-- 功效 -->
  71. <!-- <view class="effect">
  72. <view class="label">药品说明书</view>
  73. <view class="label">查看</view>
  74. </view> -->
  75. <!-- 图文详情 -->
  76. <view class="det-box">
  77. <view class="title">图文详情</view>
  78. <view class="inner">
  79. <view v-html="product.description" style="font-size:0"></view>
  80. </view>
  81. </view>
  82. <view class="loadding" v-if="loadding==true">
  83. <image :src="logoimg"></image>
  84. <text class="text">加载中...</text>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import {getDicts} from '@/api/index'
  90. import { mapGetters } from 'vuex';
  91. import {getProductDetails,getCartCount,addCart} from '@/api/product'
  92. export default {
  93. components: {
  94. },
  95. data() {
  96. return {
  97. banner:[],
  98. productId:null,
  99. product:{
  100. price:0,
  101. otPrice:0,
  102. },
  103. // 当前轮播的图片
  104. activeBanner: 0,
  105. loadding:true,
  106. };
  107. },
  108. onLoad(options) {
  109. this.getDicts();
  110. this.productId = options.productId;
  111. },
  112. onShow() {
  113. this.getProductDetails();
  114. },
  115. computed: {
  116. ...mapGetters(['logoimg']),
  117. },
  118. watch: {
  119. logoimg: {
  120. immediate: true, // 页面一进入就检查一次
  121. handler(val) {
  122. return val
  123. }
  124. },
  125. },
  126. methods: {
  127. getDicts:function(){
  128. getDicts().then(
  129. res => {
  130. if(res.code==200){
  131. uni.setStorageSync('dicts',JSON.stringify(res));
  132. }
  133. },
  134. rej => {}
  135. );
  136. },
  137. showImg() {
  138. //预览图片
  139. uni.previewImage({
  140. urls: this.banner,
  141. current: this.banner[0]
  142. });
  143. },
  144. getProductDetails(){
  145. let data = {productId:this.productId};
  146. getProductDetails(data).then(
  147. res => {
  148. this.loadding=false;
  149. if(res.code==200){
  150. this.product=res.product;
  151. this.product.otPrice=this.product.otPrice.toFixed(2);
  152. this.product.price=this.product.price.toFixed(2);
  153. if(this.product.sliderImage!=null){
  154. this.banner=this.product.sliderImage.split(',');
  155. }
  156. else{
  157. this.banner=[]
  158. }
  159. }else{
  160. uni.showToast({
  161. icon:'none',
  162. title: res.msg,
  163. });
  164. setTimeout(function(){
  165. uni.reLaunch({
  166. url: '/pages/home/index',
  167. })
  168. },2000)
  169. }
  170. },
  171. rej => {}
  172. );
  173. },
  174. // swiper变化事件
  175. swiperChange(event) {
  176. this.activeBanner = event.detail.current + 1
  177. },
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .shop-banner{
  183. height: 756upx;
  184. background-color: #FFFFFF;
  185. position: relative;
  186. .swiper-item{
  187. box-sizing: border-box;
  188. }
  189. .swiper,
  190. .swiper-item,
  191. .swiper-item image{
  192. width: 100%;
  193. height: 100%;
  194. }
  195. .banner-mask{
  196. width: 100%;
  197. height: 44upx;
  198. // background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0));
  199. // opacity: 0.8;
  200. position: absolute;
  201. left: 0;
  202. bottom: 0;
  203. z-index: 9;
  204. background-image: url(https://kntobs.jnmyunl.com/shop/images/black_mask.png);
  205. background-size: 20upx 44upx;
  206. background-repeat: repeat-x;
  207. }
  208. .num-box{
  209. width: 80upx;
  210. height: 44upx;
  211. line-height: 44upx;
  212. text-align: center;
  213. font-size: 24upx;
  214. font-family: PingFang SC;
  215. font-weight: 500;
  216. color: #FFFFFF;
  217. background: rgba(0, 0, 0, .3);
  218. border-radius: 22upx;
  219. position: absolute;
  220. right: 30upx;
  221. bottom: 30upx;
  222. z-index: 10;
  223. }
  224. }
  225. .det-info{
  226. background: #FFFFFF;
  227. padding: 36upx 30upx 25upx;
  228. .price-box{
  229. display: flex;
  230. align-items: center;
  231. justify-content: space-between;
  232. .price{
  233. display: flex;
  234. align-items: flex-end;
  235. .label{
  236. color: #333;
  237. font-size: 28upx;
  238. font-family: PingFang SC;
  239. line-height: 1.3;
  240. margin-right: 5upx;
  241. }
  242. .unit{
  243. font-size: 28upx;
  244. font-family: PingFang SC;
  245. font-weight: bold;
  246. color: #FF6633;
  247. line-height: 1.3;
  248. }
  249. .num{
  250. font-size: 40upx;
  251. font-family: PingFang SC;
  252. font-weight: bold;
  253. color: #FF6633;
  254. margin: 0 20upx 0 10upx;
  255. line-height: 1;
  256. }
  257. .old{
  258. font-size: 28upx;
  259. font-family: PingFang SC;
  260. font-weight: 500;
  261. text-decoration: line-through;
  262. color: #BBBBBB;
  263. line-height: 1.3;
  264. }
  265. }
  266. .share-box{
  267. width: 120upx;
  268. height: 46upx;
  269. border: 1px solid #2BC7B9;
  270. border-radius: 23upx;
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. position: relative;
  275. .text{
  276. font-size: 26upx;
  277. font-family: PingFang SC;
  278. font-weight: 500;
  279. color: #2BC7B9;
  280. }
  281. image{
  282. margin-left: 2rpx;
  283. width: 25upx;
  284. height: 24upx;
  285. }
  286. .share{
  287. display: inline-block;
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. width: 100%;
  292. height: 100%rpx;
  293. opacity: 0;
  294. }
  295. }
  296. .spec{
  297. font-size: 24upx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #999999;
  301. line-height: 36upx;
  302. }
  303. }
  304. .name-box{
  305. font-size: 32upx;
  306. font-family: PingFang SC;
  307. font-weight: bold;
  308. color: #111111;
  309. line-height: 44upx;
  310. margin-top: 32upx;
  311. .tag{
  312. display: inline-block;
  313. padding: 0 6upx;
  314. height: 30upx;
  315. background: linear-gradient(90deg, #66b2ef 0%, #2BC7B9 100%);
  316. border-radius: 4upx;
  317. margin-right: 10upx;
  318. font-size: 22upx;
  319. font-family: PingFang SC;
  320. font-weight: bold;
  321. color: #FFFFFF;
  322. line-height: 30upx;
  323. float: left;
  324. margin-top: 7upx;
  325. }
  326. }
  327. .intro{
  328. font-size: 26upx;
  329. font-family: PingFang SC;
  330. font-weight: 500;
  331. color: #999999;
  332. line-height: 36upx;
  333. padding: 18upx 0 23upx;
  334. border-bottom: 1px solid #f7f7f7;
  335. }
  336. .safe-box{
  337. display: flex;
  338. align-items: center;
  339. padding-top: 24upx;
  340. image{
  341. width: 20upx;
  342. height: 24upx;
  343. margin-right: 20upx;
  344. }
  345. .text{
  346. font-size: 22upx;
  347. font-family: PingFang SC;
  348. font-weight: 500;
  349. color: #999999;
  350. line-height: 1;
  351. }
  352. .line{
  353. width: 1px;
  354. height: 23upx;
  355. background: #EDEEEF;
  356. margin: 0 20upx;
  357. }
  358. }
  359. }
  360. .inventor{
  361. height: 88upx;
  362. padding: 0 39upx 0 30upx;
  363. margin-top: 10upx;
  364. background: #FFFFFF;
  365. display: flex;
  366. align-items: center;
  367. justify-content: space-between;
  368. .left{
  369. display: flex;
  370. align-items: center;
  371. .head-box{
  372. margin-right: 27upx;
  373. display: flex;
  374. align-items: center;
  375. .head{
  376. width: 48upx;
  377. height: 48upx;
  378. border-radius: 50%;
  379. overflow: hidden;
  380. box-shadow: 0 0 0 1px #fff;
  381. margin-right: -10upx;
  382. image{
  383. width: 100%;
  384. height: 100%;
  385. }
  386. }
  387. }
  388. .num-box{
  389. font-size: 24upx;
  390. font-family: PingFang SC;
  391. font-weight: 500;
  392. color: #999999;
  393. .text{
  394. font-size: 24upx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. color: #999999;
  398. }
  399. }
  400. }
  401. .right{
  402. font-size: 24upx;
  403. font-family: PingFang SC;
  404. font-weight: 500;
  405. color: #999999;
  406. .text{
  407. font-size: 24upx;
  408. font-family: PingFang SC;
  409. font-weight: 500;
  410. color: #666666;
  411. }
  412. }
  413. }
  414. .effect{
  415. box-sizing: border-box;
  416. padding: 20upx 30upx;
  417. background: #FFFFFF;
  418. font-size: 28upx;
  419. font-family: PingFang SC;
  420. font-weight: 500;
  421. color: #666666;
  422. line-height: 1.8;
  423. margin-top: 10upx;
  424. display: flex;
  425. flex-direction: row;
  426. align-items: center;
  427. justify-content: space-between;
  428. .label{
  429. font-size: 28upx;
  430. font-family: PingFang SC;
  431. font-weight: 500;
  432. color: #111111;
  433. line-height: 1.8;
  434. }
  435. }
  436. .det-box{
  437. margin-top: 10upx;
  438. padding: 40upx 30upx;
  439. background-color: #FFFFFF;
  440. .title{
  441. font-size: 30upx;
  442. font-family: PingFang SC;
  443. font-weight: bold;
  444. color: #333333;
  445. line-height: 1;
  446. margin-bottom: 25upx;
  447. }
  448. }
  449. .loadding{
  450. background-color: #fff;
  451. display: flex;
  452. flex-direction: column;
  453. align-items: center;
  454. justify-content: center;
  455. position: absolute;
  456. top: 0;
  457. left: 0;
  458. width: 100%;
  459. height: 100%;
  460. z-index: 9999;
  461. image{
  462. border-radius: 50%;
  463. animation: load linear 1s infinite;
  464. width: 120rpx;
  465. height:120rpx;
  466. }
  467. .text{
  468. font-size: 28rpx;
  469. margin-top: 20rpx;
  470. }
  471. }
  472. </style>