detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view>
  3. <view>
  4. <u-swiper :height="750" :interval="5000" :list="swiperList" mode="rect" @click="clickImg"></u-swiper>
  5. </view>
  6. <view class="u-p-l-20 u-p-r-20 u-p-t-20 u-p-b-20">
  7. <view>
  8. <view class="item-title">{{ mallGoods.goodsName }}</view>
  9. <view class="item-bottom">
  10. <view class="item-price">
  11. <view class="new-price">¥{{ mallGoods.newPrice }}</view>
  12. <view class="old-price">¥{{ mallGoods.oldPrice }}</view>
  13. </view>
  14. <view class="right">
  15. 免邮费
  16. </view>
  17. </view>
  18. </view>
  19. <view class="goosMsg">
  20. <view class="tag">销量:100000</view>
  21. <view class="tag">库存:{{ mallGoods.goodsStock }}</view>
  22. <view class="tag">浏览量:{{ mallGoods.goodsView }}</view>
  23. </view>
  24. <view class="cell-list">
  25. <view class="cell" style="background-color: #fff3f5;
  26. margin: 0 -20rpx;
  27. height: 80rpx;line-height: 80rpx;">
  28. <view class="left" style="margin-left: 30rpx;">
  29. <u-icon color="#fa436a" name="star" size="38"></u-icon>
  30. <text class="text" style="color: #ff536f;margin-right: 20rpx;">分享</text>
  31. <text class="text">
  32. 发给好友看看吧~
  33. </text>
  34. </view>
  35. <view class="right" style="color: #ff536f;margin-right: 20rpx;">
  36. 立即分享
  37. <u-icon color="#ff536f" name="arrow-right" size="30"></u-icon>
  38. </view>
  39. </view>
  40. <view class="cell" @click="buyType">
  41. <view class="left">
  42. <text class="text">购买类型</text>
  43. </view>
  44. <view class="right">
  45. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  46. </view>
  47. </view>
  48. <view class="cell" @click="coupon">
  49. <view class="left">
  50. <text class="text">优惠卷</text>
  51. </view>
  52. <view class="right">
  53. 领取优惠卷
  54. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  55. </view>
  56. </view>
  57. <view class="cell">
  58. <view class="left">
  59. <text class="text">服务</text>
  60. </view>
  61. <view class="right" style="color: #666;margin-right: 20rpx;">
  62. 7天无理由退货,假一赔十
  63. </view>
  64. </view>
  65. </view>
  66. <!-- <u-gap height="10" bg-color="#f3f4f6" style="margin: 0 -20rpx;"></u-gap> -->
  67. <!-- 评价 -->
  68. <!-- <view class="comment">
  69. <view class="header">
  70. <view class="left">商品评价(2)</view>
  71. <view class="right">好评率 50.0%
  72. <u-icon name="arrow-right" size="30" color="#ddd" ></u-icon>
  73. </view>
  74. </view>
  75. <view class="body">
  76. <view class="left">
  77. <image class="avatar" src="https://sourcebyte.cn/profile/upload/2022/04/30/366cc314-0dfb-410d-923b-7f547280a2d4.png"></image>
  78. </view>
  79. <view class="right">
  80. <view class="title">
  81. <view class="username">詹Sir</view>
  82. <view class="star">
  83. <u-rate active-color="#ffc454" inactive-color="#b2b2b2" gutter="5" :count="count" v-model="value"></u-rate>
  84. </view>
  85. </view>
  86. <view class="speak">弟弟666</view>
  87. </view>
  88. </view>
  89. <view class="bottom">
  90. <view class="time">2022-05-05 20:36</view>
  91. <view class="desc">购买类型:【美白提亮】 全新...</view>
  92. </view>
  93. </view> -->
  94. </view>
  95. <u-gap bg-color="#f3f4f6" height="10"></u-gap>
  96. <!-- 图文详情 -->
  97. <view class="content">
  98. <u-divider>图文详情</u-divider>
  99. <view class="u-content">
  100. <u-parse :html="mallGoods.articleContent"></u-parse>
  101. </view>
  102. </view>
  103. <view class="navigation">
  104. <view class="left">
  105. <view class="item" @click="callPhoneNumber">
  106. <u-icon :color="$u.color['contentColor']" :size="40" name="server-fill"></u-icon>
  107. <view class="text u-line-1">客服</view>
  108. </view>
  109. <view class="item car" @click="goCart">
  110. <u-icon :color="$u.color['contentColor']" :size="40" name="shopping-cart"></u-icon>
  111. <view class="text u-line-1">购物车</view>
  112. </view>
  113. <!-- <view class="item" @click="heart">
  114. <u-icon name="heart" :size="40" :color="$u.color['contentColor']"></u-icon>
  115. <view class="text u-line-1">收藏</view>
  116. </view> -->
  117. </view>
  118. <view class="right">
  119. <view class="cart btn u-line-1" @click="setCart">加入购物车</view>
  120. <view class="buy btn u-line-1" @click="quote">立即购买</view>
  121. </view>
  122. </view>
  123. <u-popup v-model="buyTypeShow" border-radius="14" height="300px"
  124. mode="bottom">
  125. <view class="popup">
  126. <view class="goods">
  127. <view class="left">
  128. <image class="avatar"
  129. src="https://sourcebyte.cn/profile/upload/2022/04/30/366cc314-0dfb-410d-923b-7f547280a2d4.png"></image>
  130. </view>
  131. <view class="right">
  132. <view class="price">
  133. ¥0.01
  134. </view>
  135. <view class="qty">库存:882</view>
  136. <view class="spec">规格:35g</view>
  137. </view>
  138. </view>
  139. <view class="spec">
  140. <view class="title">规格</view>
  141. <view class="tag">
  142. <view class="item">10g</view>
  143. <view class="item">20g</view>
  144. <view class="item active">35g</view>
  145. <view class="item">10g</view>
  146. <view class="item">20g</view>
  147. <view class="item">10g</view>
  148. <view class="item">20g</view>
  149. <view class="item">10g</view>
  150. <view class="item">20g</view>
  151. <view class="item">10g</view>
  152. <view class="item">20g</view>
  153. <view class="item">10g</view>
  154. <view class="item">20g</view>
  155. </view>
  156. </view>
  157. <view class="num">
  158. <view class="title">数量</view>
  159. <u-number-box></u-number-box>
  160. </view>
  161. <view class="btn">
  162. <view class="cart u-line-1" @click="setCart">加入购物车</view>
  163. <view class="buy u-line-1" @click="quote">立即购买</view>
  164. </view>
  165. </view>
  166. </u-popup>
  167. </view>
  168. </template>
  169. <script>
  170. import config from "@/common/config.js" // 全局配置文件
  171. export default {
  172. data() {
  173. return {
  174. buyTypeShow: false,
  175. count: 5,
  176. value: 5,
  177. mallGoods: {},
  178. swiperList: [],
  179. }
  180. },
  181. onLoad: function (option) {
  182. let goodsId = option.goodsId //上个页面传递的参数。
  183. // 渲染当前房源信息
  184. this.findGoodsById(goodsId);
  185. },
  186. methods: {
  187. callPhoneNumber() {
  188. uni.makePhoneCall({
  189. phoneNumber: "18720989281",
  190. });
  191. },
  192. goCart() {
  193. uni.switchTab({
  194. url: "/pages/cart/cart"
  195. })
  196. },
  197. heart() {
  198. this.$mytip.toast('heart')
  199. },
  200. setCart() {
  201. // 判断Token是否有效
  202. if (!this.vuex_token) {
  203. // 没有token 则跳转到登录
  204. return uni.reLaunch({
  205. url: '../login/login'
  206. })
  207. }
  208. let goods = {
  209. goodsId: this.mallGoods.id,
  210. title: this.mallGoods.goodsName,
  211. desc: this.mallGoods.goodsFeature,
  212. price: this.mallGoods.newPrice,
  213. value: 1,
  214. image: config.staticUrl + this.mallGoods.goodsFaceUrl,
  215. check: false,
  216. show: false,
  217. }
  218. let cartList = this.vuex_cartList
  219. cartList.push(goods)
  220. this.$u.vuex('vuex_cartList', cartList);
  221. uni.switchTab({
  222. url: "/pages/cart/cart"
  223. })
  224. },
  225. quote() {
  226. this.$mytip.toast('购买')
  227. },
  228. findGoodsById(goodsId) {
  229. let url = "api/mallApi/findGoodsById";
  230. this.$u.get(url, {
  231. id: goodsId
  232. }).then(result => {
  233. let mallGoods = result.data
  234. let goodsItem = mallGoods.goodsItemUrl.split(",")
  235. goodsItem.forEach((item, index) => {
  236. //执行代码
  237. this.swiperList.push({
  238. image: config.staticUrl + item,
  239. title: index
  240. })
  241. })
  242. this.mallGoods = mallGoods
  243. });
  244. },
  245. clickImg(index) {
  246. let imgArr = this.swiperList.map(val => {
  247. return val.image
  248. })
  249. // 预览图片
  250. uni.previewImage({
  251. current: index,
  252. urls: imgArr
  253. });
  254. },
  255. buyType() {
  256. this.buyTypeShow = true
  257. },
  258. coupon() {
  259. this.$u.route({
  260. url: 'pages/coupon/coupon',
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style>
  267. /* page不能写带scope的style标签中,否则无效 */
  268. page {
  269. background-color: rgb(255, 255, 255);
  270. }
  271. </style>
  272. <style lang="scss" scoped>
  273. .item-title {
  274. font-size: 20px;
  275. color: $u-main-color;
  276. font-weight: bold;
  277. padding-top: 10 rpx;
  278. padding-left: 10 rpx;
  279. background-color: #fff;
  280. }
  281. .item-bottom {
  282. margin-top: 20 rpx;
  283. background-color: #fff;
  284. display: flex;
  285. align-items: center;
  286. .item-price {
  287. display: flex;
  288. align-items: center;
  289. width: 250 rpx;
  290. max-width: 250 rpx;
  291. text-overflow: ellipsis;
  292. overflow: hidden;
  293. white-space: nowrap;
  294. .new-price {
  295. font-weight: normal;
  296. font-size: 22px;
  297. color: $base-color;
  298. padding: 5px 0 5px 2px;
  299. }
  300. .old-price {
  301. font-weight: normal;
  302. font-size: 14px;
  303. text-decoration: line-through;
  304. color: $u-tips-color;
  305. padding: 5px 0 5px 5px;
  306. }
  307. }
  308. .right {
  309. color: #fff;
  310. background-image: linear-gradient(to left, rgba(#ff536f, 1), rgba(#ff536f, 0.6));
  311. padding: 2 rpx 12 rpx;
  312. border-radius: 30 rpx;
  313. margin-left: 22 rpx;
  314. }
  315. }
  316. .item-desc {
  317. font-weight: normal;
  318. font-size: 26 rpx;
  319. color: $u-tips-color;
  320. padding-bottom: 5 rpx;
  321. padding-left: 10 rpx;
  322. background-color: #fff;
  323. }
  324. .goosMsg {
  325. display: flex;
  326. align-items: center;
  327. font-size: 15px;
  328. color: $u-tips-color;
  329. margin: 20 rpx 0 0 10 rpx;
  330. .tag {
  331. // width: 200rpx;
  332. flex: 1;
  333. }
  334. }
  335. .cell-list {
  336. background-color: #fff;
  337. margin-top: 20 rpx;
  338. padding-top: 20 rpx;
  339. .cell {
  340. padding: 20 rpx 0 rpx 20 rpx 0 rpx;
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. .left {
  345. display: flex;
  346. justify-content: space-between;
  347. align-items: center;
  348. color: $u-main-color;
  349. font-size: 26 rpx;
  350. .text {
  351. color: $u-tips-color;
  352. padding-left: 10 rpx;
  353. }
  354. }
  355. .right {
  356. font-size: 28 rpx;
  357. color: $u-tips-color;
  358. }
  359. }
  360. }
  361. .comment {
  362. margin: 40 rpx 0 20 rpx 0;
  363. .header {
  364. display: flex;
  365. justify-content: space-between;
  366. align-items: center;
  367. .left {
  368. color: $u-main-color;
  369. font-size: 18px;
  370. }
  371. .right {
  372. color: $u-tips-color;
  373. }
  374. }
  375. .body {
  376. display: flex;
  377. margin-top: 50 rpx;
  378. .left {
  379. .avatar {
  380. flex-shrink: 0;
  381. width: 100 rpx;
  382. height: 100 rpx;
  383. border-radius: 100px;
  384. margin-right: 24 rpx;
  385. border: 4 rpx solid #fff;
  386. background-color: #fff;
  387. }
  388. }
  389. .right {
  390. .title {
  391. display: flex;
  392. .username {
  393. font-size: 16px;
  394. margin-right: 50 rpx;
  395. color: #666
  396. }
  397. .star {
  398. font-size: 16px;
  399. }
  400. }
  401. .speak {
  402. font-size: 16px;
  403. height: 100 rpx;
  404. line-height: 100 rpx;
  405. }
  406. }
  407. }
  408. .bottom {
  409. display: flex;
  410. align-items: center;
  411. justify-content: space-between;
  412. font-size: 14px;
  413. margin-left: 60 rpx;
  414. margin-right: 20 rpx;
  415. color: $u-tips-color;
  416. }
  417. }
  418. .content {
  419. margin: 30 rpx 0 100 rpx 0;
  420. .u-content {
  421. margin-top: 30 rpx;
  422. }
  423. }
  424. .navigation {
  425. display: flex;
  426. justify-content: space-between;
  427. position: fixed;
  428. left: 0;
  429. right: 0;
  430. bottom: 0;
  431. padding: 16 rpx 20 rpx;
  432. background-color: #ffffff;
  433. box-shadow: 0 -1px 1px 0 rgba(0, 0, 0, 0.05);
  434. .left {
  435. display: flex;
  436. font-size: 20 rpx;
  437. .item {
  438. margin: 0 18 rpx;
  439. &.car {
  440. text-align: center;
  441. position: relative;
  442. .car-num {
  443. position: absolute;
  444. top: -10rpx;
  445. right: -10rpx;
  446. }
  447. }
  448. }
  449. }
  450. .right {
  451. display: flex;
  452. font-size: 28 rpx;
  453. align-items: center;
  454. .btn {
  455. line-height: 66 rpx;
  456. padding: 0 60 rpx;
  457. color: #ffffff;
  458. }
  459. .cart {
  460. border-radius: 36 rpx 0 0 36 rpx;
  461. background-color: #ff7900;
  462. }
  463. .buy {
  464. border-radius: 0 36 rpx 36 rpx 0;
  465. background-color: $base-color;
  466. }
  467. }
  468. }
  469. .popup {
  470. padding-top: 20 rpx;
  471. padding-left: 20 rpx;
  472. .goods {
  473. display: flex;
  474. .left {
  475. .avatar {
  476. flex-shrink: 0;
  477. width: 140 rpx;
  478. height: 140 rpx;
  479. border-radius: 6px;
  480. margin-right: 24 rpx;
  481. border: 4 rpx solid #fff;
  482. background-color: #fff;
  483. }
  484. }
  485. .right {
  486. .price {
  487. height: 65 rpx;
  488. line-height: 65 rpx;
  489. font-weight: normal;
  490. font-size: 18px;
  491. color: $base-color;
  492. }
  493. .qty {
  494. color: $u-tips-color;
  495. margin: 5 rpx 0;
  496. }
  497. }
  498. }
  499. .spec {
  500. .title {
  501. margin-left: 10 rpx;
  502. font-size: 15px;
  503. font-weight: 800;
  504. margin-top: 10 rpx;
  505. }
  506. .tag {
  507. display: flex;
  508. flex-flow: wrap;
  509. overflow: hidden;
  510. margin-top: 10 rpx;
  511. width: 720 rpx;
  512. max-width: 720 rpx;
  513. height: 140 rpx;
  514. max-height: 140 rpx;
  515. .item {
  516. margin-top: 12 rpx;
  517. padding: 8 rpx 24 rpx;
  518. border-radius: 30 rpx;
  519. margin-left: 22 rpx;
  520. border: 1px solid rgba(#ff536f, 0.1);
  521. }
  522. .active {
  523. color: $base-color;
  524. background-color: rgba(#ff536f, 0.1);
  525. }
  526. }
  527. }
  528. .num {
  529. display: flex;
  530. justify-content: space-between;
  531. margin-right: 20 rpx;
  532. margin-top: 30 rpx;
  533. .title {
  534. margin-left: 10 rpx;
  535. font-size: 15px;
  536. font-weight: 800;
  537. }
  538. }
  539. .btn {
  540. display: flex;
  541. justify-content: space-between;
  542. position: fixed;
  543. left: 0;
  544. right: 0;
  545. bottom: 20 rpx;
  546. padding: 16 rpx 20 rpx;
  547. background-color: #ffffff;
  548. margin: 0 20 rpx;
  549. .cart {
  550. border-radius: 36 rpx 0 0 36 rpx;
  551. background-color: #ff7900;
  552. line-height: 66 rpx;
  553. padding: 0 40 rpx;
  554. color: #ffffff;
  555. width: 370 rpx;
  556. text-align: center;
  557. }
  558. .buy {
  559. border-radius: 0 36 rpx 36 rpx 0;
  560. background-color: $base-color;
  561. line-height: 66 rpx;
  562. padding: 0 40 rpx;
  563. color: #ffffff;
  564. width: 370 rpx;
  565. text-align: center;
  566. }
  567. }
  568. }
  569. </style>