productDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="pages">
  3. <!-- head -->
  4. <view class="scrollPage-header">
  5. <view :style="{height:statusBarHeight+'px'}"></view>
  6. <view class="header-title">
  7. <view class="header-left" @click="goBack">
  8. <image style="width: 16px; height: 16px;margin-right:3px;" mode="aspectFit" src="../static/arrow-left.png"></image>
  9. <text>返回</text>
  10. </view>
  11. <view class="header-right"></view>
  12. </view>
  13. </view>
  14. <!-- 内容 -->
  15. <view class="scrollPage-content">
  16. <view class="product-info">
  17. <view :style="{height:statusBarHeight+'px'}"></view>
  18. <u-swiper mode="number" :border-radius="0" bg-color="#000" img-mode="heightFix" :interval="3000" :height="450" :list="imgList"></u-swiper>
  19. <view class="product-info-text">
  20. <view class="product-info-text-title">【新品】Apple iPhone 13 Pro Max (A2644) 256GB 金色 支持移动联通电信5G 双卡双待手机</view>
  21. <view class="product-info-text-attr">
  22. <view class="product-info-price">
  23. ¥<text class="price-red">45.8</text>
  24. </view>
  25. <view class="product-info-nums">
  26. <view class="share">
  27. <button open-type="share"><u-icon :size='24' name="zhuanfa"></u-icon> 分享</button>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <u-divider bg-color="">商品详情</u-divider>
  34. <view class="product-info-guige">
  35. <view class="row">品牌:<text>箭冠</text></view>
  36. <view class="row-ban">原厂编码:<text>128/79 R78 </text></view>
  37. <view class="row-ban">产品编码:<text>Y123</text></view>
  38. <view class="row-ban">单位:<text>箱</text></view>
  39. <view class="row-ban">包装数:<text>5/个</text></view>
  40. <view class="row-ban">尺寸:<text>16cm</text></view>
  41. <view class="row-ban">内盒尺寸:<text>15cm</text></view>
  42. <view class="row-ban">重量:<text>1.5KG</text></view>
  43. <view class="row-ban">颜色:<text>箭冠</text></view>
  44. </view>
  45. <view class="product-info-content"></view>
  46. </view>
  47. <!-- 底部栏 -->
  48. <view class="scrollPage-footer">
  49. <view class="scrollPage-footer-box">
  50. <view class="footer-left">
  51. <view class="footer-left-item" @click="toCart">
  52. <u-icon :size='50' name="shopping-cart"></u-icon>
  53. <text class="footer-left-item-text">购物车</text>
  54. <text class="badge" v-if="totalNum">{{totalNum>99?'99+':totalNum}}</text>
  55. </view>
  56. </view>
  57. <view class="footer-right">
  58. <view class="footer-right-item" @click="addCart">
  59. <text>加入购物车</text>
  60. </view>
  61. <view class="footer-right-item" @click="toBuy">
  62. <text>立即购买</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view :style="{height:safeAreaBottom+'px'}"></view>
  67. </view>
  68. <!-- 立即购买 -->
  69. <page-container
  70. :show="showPopu"
  71. :round="true"
  72. :z-index="100"
  73. position="bottom"
  74. custom-style="height:30%"
  75. @afterleave="closePopu">
  76. <view class="popu-content">
  77. <view class="popu-close" @click="showPopu=false">
  78. <uni-icons size="26" type="closeempty"></uni-icons>
  79. </view>
  80. <view class="pupu-box">
  81. <view class="popu-content-img">
  82. <image style="width: 100px; height: 100px;" mode="aspectFit" src="https://cdn.uviewui.com/uview/swiper/1.jpg"></image>
  83. </view>
  84. <view class="popu-content-info">
  85. <view class="popu-content-info-title">【新品】Apple iPhone 13 Pro Max (A2644) 256GB 金色 支持移动联通电信5G 双卡双待手机</view>
  86. <view class="popu-content-box">
  87. <view class="popu-content-price">¥<text class="price-red">45.8</text></view>
  88. <view class="popu-content-num flex align_center">
  89. <text style="margin-right: 5px;">数量</text>
  90. <uni-number-box :min="1" :max="99"></uni-number-box>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="popu-content-btn">
  96. <view class="popu-content-btn-item" @click="toBuy">确定采购</view>
  97. </view>
  98. <view :style="{height:safeAreaBottom+'px'}"></view>
  99. </view>
  100. </page-container>
  101. </view>
  102. </template>
  103. <script>
  104. import { addCart, getCartCount } from '@/api/cart.js'
  105. export default {
  106. data() {
  107. return {
  108. showPopu: false, // 弹框
  109. statusBarHeight: 0, // 状态栏高度
  110. safeAreaBottom: 0, // 底部安全区域高度
  111. imgList: [
  112. 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  113. 'https://cdn.uviewui.com/uview/swiper/2.jpg',
  114. 'https://cdn.uviewui.com/uview/swiper/3.jpg',
  115. 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  116. 'https://cdn.uviewui.com/uview/swiper/2.jpg',
  117. ],
  118. totalNum: 0 ,// 购物车总数
  119. productSn: null,
  120. detail: null
  121. }
  122. },
  123. onLoad(option) {
  124. // 计算安全区域
  125. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
  126. this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
  127. this.productSn = option.sn
  128. // 购物车数量
  129. this.cartCount()
  130. // 获取产品详情
  131. // this.getDetail()
  132. },
  133. // 分享
  134. onShareAppMessage(e){
  135. return {
  136. title: '产品标题',
  137. path: '/pagesB/shopiing/productDetail?sn='+this.productSn,
  138. imageUrl:'https://cdn.uviewui.com/uview/swiper/1.jpg',
  139. type: '1',
  140. }
  141. },
  142. methods: {
  143. // 返回
  144. goBack(){
  145. uni.navigateBack()
  146. },
  147. // 产品详情
  148. getDetail(){
  149. uni.showLoading({
  150. title: '加载中'
  151. })
  152. // 获取产品详情
  153. getDetail({
  154. productSn: this.productSn
  155. }).then(res => {
  156. if(res.status == 200){
  157. }
  158. uni.hideLoading()
  159. })
  160. },
  161. // 购物车数量
  162. cartCount(){
  163. getCartCount({}).then(res => {
  164. if(res.status == 200){
  165. this.totalNum = res.data?res.data.qty:0
  166. }
  167. })
  168. },
  169. // 加入购物车
  170. addCart(){
  171. addCart({
  172. qty:19,
  173. price: 10,
  174. productSn:13
  175. }).then(res => {
  176. if(res.status == 200){
  177. this.cartCount()
  178. uni.showToast({
  179. title: '加入成功',
  180. icon: 'success'
  181. })
  182. }
  183. })
  184. },
  185. // 打开购物车
  186. toCart(){
  187. uni.switchTab({
  188. url: '/pages/cart/index'
  189. })
  190. },
  191. // 立即购买
  192. toBuy(){
  193. // 打开数量选择弹框
  194. if(!this.showPopu){
  195. this.showPopu = true
  196. }else{
  197. // 提交
  198. this.submitOk = true
  199. }
  200. },
  201. // 关闭后
  202. closePopu(){
  203. this.showPopu = false
  204. uni.hideLoading()
  205. // 提交成功
  206. if(this.submitOk){
  207. uni.navigateTo({
  208. url: "/pagesB/procureOrder"
  209. })
  210. }
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="less">
  216. .pages {
  217. height: 100vh;
  218. display: flex;
  219. flex-direction: column;
  220. .scrollPage-header{
  221. z-index: 1;
  222. width: 100%;
  223. position:fixed;
  224. left: 0;
  225. top: 0;
  226. .header-title{
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. padding: 0 10px;
  231. height: 44px;
  232. .header-left{
  233. display: flex;
  234. align-items: center;
  235. text{
  236. font-size: 14px;
  237. color: #333333;
  238. }
  239. background-color: rgba(255,255,255,0.6);
  240. box-shadow: 0px 1px 0px 0px #E6E6E6;
  241. border-radius: 50px;
  242. padding: 3px 6px 3px;
  243. }
  244. .header-right{
  245. width: 50px;
  246. }
  247. }
  248. }
  249. .scrollPage-content{
  250. flex: 1;
  251. overflow-y: auto;
  252. .product-info{
  253. background:#fff;
  254. margin-bottom: 10px;
  255. .product-info-text{
  256. padding: 10px;
  257. .product-info-text-title{
  258. font-weight: bold;
  259. color: #333333;
  260. line-height: 22px;
  261. margin-bottom: 5px;
  262. }
  263. .product-info-text-attr{
  264. display: flex;
  265. align-items: center;
  266. justify-content: space-between;
  267. .product-info-price{
  268. font-size: 14px;
  269. color: #FF0000;
  270. .price-red{
  271. font-size: 24px;
  272. }
  273. }
  274. .product-info-nums{
  275. font-size: 12px;
  276. color: #999999;
  277. >view{
  278. display: flex;
  279. align-items: center;
  280. }
  281. .share{
  282. button{
  283. width: auto;
  284. padding: 0;
  285. border: 0;
  286. background: none;
  287. line-height: normal;
  288. margin: 0;
  289. display: inline;
  290. font-size: 12px;
  291. color: #999;
  292. &::after{
  293. border:none;
  294. }
  295. /deep/ .u-icon{
  296. margin-right: 3px;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. .product-info-guige{
  305. display: flex;
  306. flex-wrap: wrap;
  307. justify-content: space-between;
  308. background:#fff;
  309. margin: 10px 0;
  310. padding: 10px;
  311. line-height: 28px;
  312. .row{
  313. width: 100%;
  314. }
  315. .row-ban{
  316. width: 50%;
  317. }
  318. >view{
  319. color: #999;
  320. text{
  321. color: #333333;
  322. }
  323. }
  324. }
  325. .product-info-content{
  326. background:#fff;
  327. margin-bottom: 10px;
  328. padding: 10px;
  329. line-height: 28px;
  330. }
  331. }
  332. .scrollPage-footer{
  333. background-color: #FFFFFF;
  334. width: 100%;
  335. position: fixed;
  336. left: 0;
  337. bottom: 0;
  338. .scrollPage-footer-box{
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-between;
  342. height: 50px;
  343. }
  344. .footer-left{
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-between;
  348. width: 35%;
  349. .footer-left-item{
  350. display: flex;
  351. flex-direction: column;
  352. align-items: center;
  353. justify-content: center;
  354. padding: 0 15px;
  355. position: relative;
  356. .footer-left-item-text{
  357. font-size: 12px;
  358. color: #666666;
  359. }
  360. .badge{
  361. background: #f44336;
  362. color: #fff;
  363. position: absolute;
  364. right: 0;
  365. top: -8px;
  366. font-size: 12px;
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. border-radius: 50rpx;
  371. padding: 0 10rpx;
  372. }
  373. }
  374. }
  375. .footer-right{
  376. width: 60%;
  377. height: 100%;
  378. display: flex;
  379. align-items: center;
  380. .footer-right-item{
  381. height: 100%;
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. justify-content: center;
  386. width: 50%;
  387. font-size: 14px;
  388. color: #FFFFFF;
  389. }
  390. .footer-right-item:first-child{
  391. background-color: #FF9900;
  392. }
  393. .footer-right-item:last-child{
  394. background-color: #FF0000;
  395. }
  396. }
  397. }
  398. .popu-content{
  399. display: flex;
  400. flex-direction: column;
  401. align-items: center;
  402. padding: 10px;
  403. .popu-close{
  404. padding: 10px;
  405. position: absolute;
  406. right: 0;
  407. top: 0;
  408. }
  409. .pupu-box{
  410. display: flex;
  411. align-items: center;
  412. justify-content: space-between;
  413. margin-top: 25px;
  414. }
  415. .popu-content-img{
  416. border-radius: 10px;
  417. border: 1px solid #eee;
  418. }
  419. .popu-content-info{
  420. padding: 0 0 0 10px;
  421. .popu-content-info-title{
  422. font-size: 14px;
  423. font-weight: bold;
  424. }
  425. }
  426. .popu-content-box{
  427. display: flex;
  428. align-items: center;
  429. justify-content: space-between;
  430. margin-top: 10px;
  431. .popu-content-price{
  432. font-size: 14px;
  433. color: #eb0000;
  434. .price-red{
  435. font-size: 24px;
  436. }
  437. }
  438. .popu-content-num{
  439. font-size: 12px;
  440. color: #999999;
  441. padding: 0 10px;
  442. }
  443. }
  444. .popu-content-btn{
  445. width: 100%;
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. margin-top: 20px;
  450. .popu-content-btn-item{
  451. width: 100%;
  452. height: 40px;
  453. background-color: #eb0000;
  454. color: #FFFFFF;
  455. font-size: 14px;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. border-radius: 10px;
  460. }
  461. }
  462. }
  463. }
  464. </style>