productShowDetails.vue 10.0 KB

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