productShowDetails.vue 9.2 KB

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