productShowDetails.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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://zkzh-2025.oss-cn-beijing.aliyuncs.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://zkzh-2025.oss-cn-beijing.aliyuncs.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="../../static/logo.jpg"></image>
  84. <text class="text">加载中...</text>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import {getDicts} from '@/api/index'
  90. import {getProductDetails,getCartCount,addCart} from '@/api/product'
  91. export default {
  92. components: {
  93. },
  94. data() {
  95. return {
  96. banner:[],
  97. productId:null,
  98. product:{
  99. price:0,
  100. otPrice:0,
  101. },
  102. // 当前轮播的图片
  103. activeBanner: 0,
  104. loadding:true,
  105. };
  106. },
  107. onLoad(options) {
  108. this.getDicts();
  109. this.productId = options.productId;
  110. },
  111. onShow() {
  112. this.getProductDetails();
  113. },
  114. methods: {
  115. getDicts:function(){
  116. getDicts().then(
  117. res => {
  118. if(res.code==200){
  119. uni.setStorageSync('dicts',JSON.stringify(res));
  120. }
  121. },
  122. rej => {}
  123. );
  124. },
  125. showImg() {
  126. //预览图片
  127. uni.previewImage({
  128. urls: this.banner,
  129. current: this.banner[0]
  130. });
  131. },
  132. getProductDetails(){
  133. let data = {productId:this.productId};
  134. getProductDetails(data).then(
  135. res => {
  136. this.loadding=false;
  137. if(res.code==200){
  138. this.product=res.product;
  139. this.product.otPrice=this.product.otPrice.toFixed(2);
  140. this.product.price=this.product.price.toFixed(2);
  141. if(this.product.sliderImage!=null){
  142. this.banner=this.product.sliderImage.split(',');
  143. }
  144. else{
  145. this.banner=[]
  146. }
  147. }else{
  148. uni.showToast({
  149. icon:'none',
  150. title: res.msg,
  151. });
  152. setTimeout(function(){
  153. uni.reLaunch({
  154. url: '/pages/home/index',
  155. })
  156. },2000)
  157. }
  158. },
  159. rej => {}
  160. );
  161. },
  162. // swiper变化事件
  163. swiperChange(event) {
  164. this.activeBanner = event.detail.current + 1
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. .shop-banner{
  171. height: 756upx;
  172. background-color: #FFFFFF;
  173. position: relative;
  174. .swiper-item{
  175. box-sizing: border-box;
  176. }
  177. .swiper,
  178. .swiper-item,
  179. .swiper-item image{
  180. width: 100%;
  181. height: 100%;
  182. }
  183. .banner-mask{
  184. width: 100%;
  185. height: 44upx;
  186. // background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0));
  187. // opacity: 0.8;
  188. position: absolute;
  189. left: 0;
  190. bottom: 0;
  191. z-index: 9;
  192. background-image: url(https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/black_mask.png);
  193. background-size: 20upx 44upx;
  194. background-repeat: repeat-x;
  195. }
  196. .num-box{
  197. width: 80upx;
  198. height: 44upx;
  199. line-height: 44upx;
  200. text-align: center;
  201. font-size: 24upx;
  202. font-family: PingFang SC;
  203. font-weight: 500;
  204. color: #FFFFFF;
  205. background: rgba(0, 0, 0, .3);
  206. border-radius: 22upx;
  207. position: absolute;
  208. right: 30upx;
  209. bottom: 30upx;
  210. z-index: 10;
  211. }
  212. }
  213. .det-info{
  214. background: #FFFFFF;
  215. padding: 36upx 30upx 25upx;
  216. .price-box{
  217. display: flex;
  218. align-items: center;
  219. justify-content: space-between;
  220. .price{
  221. display: flex;
  222. align-items: flex-end;
  223. .label{
  224. color: #333;
  225. font-size: 28upx;
  226. font-family: PingFang SC;
  227. line-height: 1.3;
  228. margin-right: 5upx;
  229. }
  230. .unit{
  231. font-size: 28upx;
  232. font-family: PingFang SC;
  233. font-weight: bold;
  234. color: #FF6633;
  235. line-height: 1.3;
  236. }
  237. .num{
  238. font-size: 40upx;
  239. font-family: PingFang SC;
  240. font-weight: bold;
  241. color: #FF6633;
  242. margin: 0 20upx 0 10upx;
  243. line-height: 1;
  244. }
  245. .old{
  246. font-size: 28upx;
  247. font-family: PingFang SC;
  248. font-weight: 500;
  249. text-decoration: line-through;
  250. color: #BBBBBB;
  251. line-height: 1.3;
  252. }
  253. }
  254. .share-box{
  255. width: 120upx;
  256. height: 46upx;
  257. border: 1px solid #2BC7B9;
  258. border-radius: 23upx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. position: relative;
  263. .text{
  264. font-size: 26upx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #2BC7B9;
  268. }
  269. image{
  270. margin-left: 2rpx;
  271. width: 25upx;
  272. height: 24upx;
  273. }
  274. .share{
  275. display: inline-block;
  276. position: absolute;
  277. top: 0;
  278. left: 0;
  279. width: 100%;
  280. height: 100%rpx;
  281. opacity: 0;
  282. }
  283. }
  284. .spec{
  285. font-size: 24upx;
  286. font-family: PingFang SC;
  287. font-weight: 500;
  288. color: #999999;
  289. line-height: 36upx;
  290. }
  291. }
  292. .name-box{
  293. font-size: 32upx;
  294. font-family: PingFang SC;
  295. font-weight: bold;
  296. color: #111111;
  297. line-height: 44upx;
  298. margin-top: 32upx;
  299. .tag{
  300. display: inline-block;
  301. padding: 0 6upx;
  302. height: 30upx;
  303. background: linear-gradient(90deg, #66b2ef 0%, #2BC7B9 100%);
  304. border-radius: 4upx;
  305. margin-right: 10upx;
  306. font-size: 22upx;
  307. font-family: PingFang SC;
  308. font-weight: bold;
  309. color: #FFFFFF;
  310. line-height: 30upx;
  311. float: left;
  312. margin-top: 7upx;
  313. }
  314. }
  315. .intro{
  316. font-size: 26upx;
  317. font-family: PingFang SC;
  318. font-weight: 500;
  319. color: #999999;
  320. line-height: 36upx;
  321. padding: 18upx 0 23upx;
  322. border-bottom: 1px solid #f7f7f7;
  323. }
  324. .safe-box{
  325. display: flex;
  326. align-items: center;
  327. padding-top: 24upx;
  328. image{
  329. width: 20upx;
  330. height: 24upx;
  331. margin-right: 20upx;
  332. }
  333. .text{
  334. font-size: 22upx;
  335. font-family: PingFang SC;
  336. font-weight: 500;
  337. color: #999999;
  338. line-height: 1;
  339. }
  340. .line{
  341. width: 1px;
  342. height: 23upx;
  343. background: #EDEEEF;
  344. margin: 0 20upx;
  345. }
  346. }
  347. }
  348. .inventor{
  349. height: 88upx;
  350. padding: 0 39upx 0 30upx;
  351. margin-top: 10upx;
  352. background: #FFFFFF;
  353. display: flex;
  354. align-items: center;
  355. justify-content: space-between;
  356. .left{
  357. display: flex;
  358. align-items: center;
  359. .head-box{
  360. margin-right: 27upx;
  361. display: flex;
  362. align-items: center;
  363. .head{
  364. width: 48upx;
  365. height: 48upx;
  366. border-radius: 50%;
  367. overflow: hidden;
  368. box-shadow: 0 0 0 1px #fff;
  369. margin-right: -10upx;
  370. image{
  371. width: 100%;
  372. height: 100%;
  373. }
  374. }
  375. }
  376. .num-box{
  377. font-size: 24upx;
  378. font-family: PingFang SC;
  379. font-weight: 500;
  380. color: #999999;
  381. .text{
  382. font-size: 24upx;
  383. font-family: PingFang SC;
  384. font-weight: 500;
  385. color: #999999;
  386. }
  387. }
  388. }
  389. .right{
  390. font-size: 24upx;
  391. font-family: PingFang SC;
  392. font-weight: 500;
  393. color: #999999;
  394. .text{
  395. font-size: 24upx;
  396. font-family: PingFang SC;
  397. font-weight: 500;
  398. color: #666666;
  399. }
  400. }
  401. }
  402. .effect{
  403. box-sizing: border-box;
  404. padding: 20upx 30upx;
  405. background: #FFFFFF;
  406. font-size: 28upx;
  407. font-family: PingFang SC;
  408. font-weight: 500;
  409. color: #666666;
  410. line-height: 1.8;
  411. margin-top: 10upx;
  412. display: flex;
  413. flex-direction: row;
  414. align-items: center;
  415. justify-content: space-between;
  416. .label{
  417. font-size: 28upx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #111111;
  421. line-height: 1.8;
  422. }
  423. }
  424. .det-box{
  425. margin-top: 10upx;
  426. padding: 40upx 30upx;
  427. background-color: #FFFFFF;
  428. .title{
  429. font-size: 30upx;
  430. font-family: PingFang SC;
  431. font-weight: bold;
  432. color: #333333;
  433. line-height: 1;
  434. margin-bottom: 25upx;
  435. }
  436. }
  437. .loadding{
  438. background-color: #fff;
  439. display: flex;
  440. flex-direction: column;
  441. align-items: center;
  442. justify-content: center;
  443. position: absolute;
  444. top: 0;
  445. left: 0;
  446. width: 100%;
  447. height: 100%;
  448. z-index: 9999;
  449. image{
  450. border-radius: 50%;
  451. animation: load linear 1s infinite;
  452. width: 120rpx;
  453. height:120rpx;
  454. }
  455. .text{
  456. font-size: 28rpx;
  457. margin-top: 20rpx;
  458. }
  459. }
  460. </style>