goodDetails.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view class="container">
  3. <swiper class="swiper" :indicator-dots="true" indicator-color="#9A9A9A" indicator-active-color="#52A63A" :autoplay="true"
  4. :interval="3000" :duration="500">
  5. <swiper-item v-for="(item,index) in goodData.imgs" :key="index">
  6. <cover-image :src="item.imgPath"></cover-image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="good-info">
  10. <text class="good-price">
  11. <text class="sale-icon">¥</text>
  12. <text class="sale-price">{{goodData.bizPrice}}</text>
  13. <text class="price">原价:{{goodData.originalPrice}}</text>
  14. <text class="seller-count">{{goodData.sellCount}}人付款</text>
  15. </text>
  16. <view class="good-name">{{goodData.productName}}</view>
  17. <view class="good-detail">{{goodData.productDescribe}}</view>
  18. </view>
  19. <view class="good-data">
  20. <text class="good-select">选择</text>
  21. <text class="good-unit">{{number}}&nbsp;{{goodData.unit}}</text>
  22. <text class="iconfont iconfangxiang"></text>
  23. </view>
  24. <view class="tab-box">
  25. <view class="tab-col" :class="tabIndex == 1 ? 'tab-col-active' :''" @click="tabIndex = 1">产品介绍</view>
  26. <view class="tab-col" :class="tabIndex == 2 ? 'tab-col-active' :''" @click="tabIndex = 2">用户评价</view>
  27. </view>
  28. <rich-text :nodes="goodData.sellDesc" v-if="tabIndex == 1"></rich-text>
  29. <view class="good-assess" v-else>
  30. <view class="assess-row" v-for="(item,index) in assessList" :key="index">
  31. <cover-image class="assess-head" :src="item.headimg"></cover-image>
  32. <view class="assess-info">
  33. <view class="assess-name">{{item.nickname}}</view>
  34. <view class="assess-date">{{item.replyTime}}</view>
  35. <view class="assess-sore-box">
  36. <view class="sore-col" v-for="site in item.score" :key="site"></view>
  37. </view>
  38. <view class="assess-text">{{item.replyContent}}</view>
  39. <view class="assess-img-box">
  40. <cover-image class="img-col" v-for="site in item.evaluateImgs" :key="site" :src="site.imgUrl"></cover-image>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="assess-more" @click="">显示全部</view>
  45. </view>
  46. <view class="good-recommend">
  47. <view class="recommend-title">为您推荐</view>
  48. <scroll-view class="recommend-box" scroll-x="true">
  49. <view class="good-col" v-for="(item, index) in goodsList" :key="index">
  50. <cover-image class="good-img" :src="item.imgPath"></cover-image>
  51. <view class="good-name">{{item.name}}</view>
  52. <view class="good-price">¥{{item.price}}</view>
  53. </view>
  54. </scroll-view>
  55. </view>
  56. <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="goToShop" @buttonClick="showPopup"
  57. style="width: 100%; position: fixed; bottom: 0px;" />
  58. <uni-popup ref="popup" type="bottom">
  59. <view class="popup-box">
  60. <view class="popup-good-info-box">
  61. <cover-image class="popup-good-img" v-if="goodData.imgs.length" :src="goodData.imgs[0].imgPath"></cover-image>
  62. <view class="popup-good-data">
  63. <view class="popup-good-price"><text style="font-size: 14px;">¥</text>{{goodData.bizPrice}}</view>
  64. <view class="popup-good-number">库存{{goodData.stock}}件</view>
  65. <view class="popup-good-type">已选</view>
  66. </view>
  67. <view class="popup-good-close"></view>
  68. </view>
  69. <view class="popup-good-info">单位</view>
  70. <view class="popup-good-unit">{{goodData.unit}}</view>
  71. <view class="popup-good-info">数量</view>
  72. <view class="popup-good-number-box">
  73. <uni-icons type="minus-filled" size="20" color="#A67A54" @click="number>1?number--:''"></uni-icons>
  74. <text class="good-select">{{number}}</text>
  75. <uni-icons type="plus-filled" size="20" color="#A67A54" @click="number++"></uni-icons>
  76. </view>
  77. <uni-goods-nav :fill="true" :options="[]" :buttonGroup="buttonGroup" @buttonClick="submitData" style="width: 100%; position: absolute; bottom: 0px;left:0px" />
  78. </view>
  79. </uni-popup>
  80. </view>
  81. </template>
  82. <script>
  83. const NET = require('@/utils/request')
  84. const API = require('@/config/api')
  85. export default {
  86. data() {
  87. return {
  88. goodId: '',
  89. goodData: {
  90. bizPrice: '',
  91. originalPrice: '',
  92. sellCount: '',
  93. productName: '',
  94. productDescribe: '',
  95. unit: '',
  96. sellDesc: '',
  97. stock: '',
  98. imgs: [],
  99. },
  100. assessList: [],
  101. goodsList: [],
  102. number: 1,
  103. tabIndex: 1,
  104. options: [{
  105. icon: 'shop',
  106. text: '店铺',
  107. }],
  108. buttonGroup: [{
  109. text: '加入购物车',
  110. backgroundColor: '#75BD60',
  111. color: '#fff'
  112. },
  113. {
  114. text: '立即购买',
  115. backgroundColor: '#52A63A',
  116. color: '#fff'
  117. }
  118. ]
  119. }
  120. },
  121. onLoad(options) {
  122. this.goodId = options.goodId ? options.goodId : ''
  123. this.getGoodsList()
  124. },
  125. onReady() {
  126. if (this.goodId) {
  127. NET.request(API.getCommonGoodDetail + '/' + this.goodId, {}, 'GET').then(res => {
  128. if (res.code == 0) {
  129. this.goodData = res.data
  130. } else {
  131. uni.showToast({
  132. title: "获取商品详情失败",
  133. icon: "none"
  134. })
  135. }
  136. }).catch(res => {})
  137. NET.request(API.getAssessList + '/' + this.goodId + '/1/3', {}, 'GET').then(res => {
  138. if (res.code == 0) {
  139. this.assessList = res.data.list
  140. } else {
  141. uni.showToast({
  142. title: "获取商品评价失败",
  143. icon: "none"
  144. })
  145. }
  146. }).catch(res => {})
  147. }
  148. },
  149. methods: {
  150. // 跳转商铺页
  151. goToShop() {
  152. uni.navigateTo({
  153. url: '/pagesGood/shopDetails?shopId=' + goodData.tenantCode
  154. });
  155. },
  156. // 弹出购物弹窗
  157. showPopup() {
  158. this.$refs.popup.open()
  159. },
  160. // 获取为你推荐
  161. getGoodsList() {
  162. },
  163. // 提交操作
  164. submitData(e) {
  165. if (e.index) {
  166. // 立即购买
  167. uni.setStorage({
  168. key: 'orderData',
  169. data: {
  170. tenantCode: this.goodData.tenantCode,
  171. supplierName: this.goodData.supplierName,
  172. goodsList: [{
  173. bizPrice: this.goodData.bizPrice,
  174. buyNum: this.number,
  175. imgUrl: this.goodData.imgs.length ? this.goodData.imgs[0].imgPath : '',
  176. originalPrice: this.goodData.originalPrice,
  177. productId: this.goodId,
  178. productName: this.goodData.productName,
  179. productType: this.goodData.productType,
  180. tenantCode: this.goodData.tenantCode,
  181. }]
  182. }
  183. });
  184. uni.navigateTo({
  185. url: '/pagesGood/goodDetails?orderType=1'
  186. });
  187. } else {
  188. // 加入购物车
  189. NET.request(API.addCart, {
  190. productId: this.goodId,
  191. buyNum: this.number
  192. }, 'POST').then(res => {
  193. if (res.code == 0) {
  194. uni.showToast({
  195. title: "加入购物车成功",
  196. icon: "success"
  197. })
  198. } else {
  199. uni.showToast({
  200. title: "加入购物车失败",
  201. icon: "none"
  202. })
  203. }
  204. }).catch(res => {})
  205. }
  206. },
  207. },
  208. }
  209. </script>
  210. <style lang="less" scoped>
  211. .container {
  212. background-color: #f7f7f7;
  213. padding-bottom: 50px;
  214. .swiper {
  215. height: 375px;
  216. /deep/.uni-swiper-dot-active {
  217. width: 16px !important;
  218. border-radius: 8px;
  219. }
  220. }
  221. .good-info {
  222. box-sizing: border-box;
  223. padding: 22px 16px;
  224. background-color: #FFFFFF;
  225. .good-price {
  226. height: 26px;
  227. line-height: 26px;
  228. font-family: PingFang SC;
  229. .sale-icon {
  230. font-size: 16px;
  231. color: #52A63A;
  232. margin-left: -2px;
  233. }
  234. .sale-price {
  235. font-size: 24px;
  236. color: #52A63A;
  237. }
  238. .price {
  239. font-size: 12px;
  240. text-decoration: line-through;
  241. color: #A67A54;
  242. margin-left: 6px;
  243. }
  244. .seller-count {
  245. float: right;
  246. font-size: 12px;
  247. color: #666666;
  248. }
  249. }
  250. .good-name {
  251. line-height: 20px;
  252. font-size: 16px;
  253. color: #343434;
  254. font-family: PingFang SC;
  255. margin: 12px 0 8px 0;
  256. }
  257. .good-detail {
  258. line-height: 14px;
  259. font-size: 12px;
  260. color: #666666;
  261. font-family: PingFang SC;
  262. }
  263. }
  264. .good-data {
  265. height: 46px;
  266. margin: 10px 0;
  267. box-sizing: border-box;
  268. background-color: #FFFFFF;
  269. padding: 14px 16px;
  270. font-family: PingFang SC;
  271. font-size: 12px;
  272. line-height: 14px;
  273. .good-select {
  274. color: #666666;
  275. margin-right: 12px;
  276. }
  277. .good-unit {
  278. color: #343434;
  279. }
  280. .iconfont {
  281. float: right;
  282. font-size: 16px;
  283. color: #999999;
  284. }
  285. }
  286. .tab-box {
  287. height: 50px;
  288. background-color: #FFFFFF;
  289. box-sizing: border-box;
  290. padding: 0 16px;
  291. display: flex;
  292. justify-content: space-around;
  293. .tab-col {
  294. height: 49px;
  295. font-size: 13px;
  296. font-family: PingFang SC;
  297. color: #666666;
  298. line-height: 50px;
  299. }
  300. .tab-col-active {
  301. font-size: 15px;
  302. color: #343434;
  303. border-bottom: 1px solid #52A63A;
  304. }
  305. }
  306. .good-assess {
  307. width: 100%;
  308. box-sizing: border-box;
  309. background-color: #FFFFFF;
  310. padding: 12px 16px 18px 16px;
  311. .assess-row {
  312. border-bottom: 1px solid #F6F6F6;
  313. padding-bottom: 18px;
  314. display: flex;
  315. .assess-head {
  316. width: 50px;
  317. height: 50px;
  318. }
  319. .assess-info {
  320. width: calc(100% - 62px);
  321. margin-left: 12px;
  322. .assess-name {
  323. height: 18px;
  324. float: left;
  325. line-height: 18px;
  326. font-size: 15px;
  327. font-family: PingFang SC;
  328. font-weight: bold;
  329. color: #343434;
  330. }
  331. .assess-date {
  332. height: 18px;
  333. float: right;
  334. line-height: 18px;
  335. font-size: 12px;
  336. font-family: PingFang SC;
  337. font-weight: bold;
  338. color: #666666;
  339. }
  340. .assess-sore-box {
  341. height: 16px;
  342. margin-top: 6px;
  343. .sore-col {
  344. margin-right: 4px;
  345. }
  346. }
  347. .assess-text {
  348. font-size: 12px;
  349. font-family: PingFang SC;
  350. font-weight: bold;
  351. color: #666666;
  352. line-height: 16px;
  353. margin: 8px 0 10px 0;
  354. }
  355. .assess-img-box {
  356. display: flex;
  357. .img-col {
  358. height: 60px;
  359. width: 60px;
  360. object-fit: cover;
  361. margin-right: 10px;
  362. }
  363. }
  364. }
  365. }
  366. .assess-row:last-child {
  367. border-bottom: none;
  368. }
  369. .assess-more {
  370. width: 220px;
  371. height: 32px;
  372. position: relative;
  373. left: 50%;
  374. transform: translateX(-50%);
  375. border: 1px solid #52A63A;
  376. border-radius: 16px;
  377. text-align: center;
  378. font-size: 12px;
  379. font-family: PingFang SC;
  380. color: #53A63A;
  381. line-height: 32px;
  382. }
  383. }
  384. .good-recommend {
  385. height: 184px;
  386. background-color: #FFFFFF;
  387. margin: 10px 0;
  388. .recommend-title {
  389. height: 32px;
  390. padding-left: 16px;
  391. font-size: 14px;
  392. font-family: PingFang SC;
  393. color: #343434;
  394. line-height: 32px;
  395. }
  396. .recommend-box {
  397. width: calc(100% - 32px);
  398. .good-col {
  399. width: 108px;
  400. height: 140px;
  401. margin-right: 12px;
  402. .good-img {
  403. width: 108px;
  404. height: 108px;
  405. object-fit: cover;
  406. }
  407. .good-name {
  408. font-size: 10px;
  409. font-family: PingFang SC;
  410. color: #343434;
  411. line-height: 14px;
  412. margin: 4px 0;
  413. }
  414. .good-price {
  415. font-size: 14px;
  416. font-family: PingFang SC;
  417. color: #6CA63A;
  418. line-height: 16px;
  419. }
  420. }
  421. }
  422. }
  423. .popup-box {
  424. width: 100vw;
  425. height: 400px;
  426. background-color: #FFFFFF;
  427. border-radius: 15px 15px 0px 0px;
  428. box-sizing: border-box;
  429. padding: 16px 16px 0 16px;
  430. .popup-good-info-box {
  431. height: 90px;
  432. margin-bottom: 4px;
  433. display: flex;
  434. .popup-good-img {
  435. width: 90px;
  436. height: 90px;
  437. object-fit: cover;
  438. border-radius: 5px;
  439. overflow: hidden;
  440. }
  441. .popup-good-data {
  442. width: calc(100% - 136px);
  443. height: 90px;
  444. margin-left: 22px;
  445. .popup-good-price {
  446. margin-top: 10px;
  447. height: 20px;
  448. line-height: 20px;
  449. font-size: 20px;
  450. font-family: PingFang SC;
  451. color: #52A63A;
  452. }
  453. .popup-good-number {
  454. height: 16px;
  455. font-size: 13px;
  456. font-family: PingFang SC;
  457. color: #9A9A9A;
  458. line-height: 16px;
  459. margin: 12px 0 10px 0;
  460. }
  461. .popup-good-type {
  462. height: 16px;
  463. font-size: 13px;
  464. font-family: PingFang SC;
  465. color: #343434;
  466. line-height: 16px;
  467. }
  468. }
  469. .popup-good-close {
  470. width: 24px;
  471. height: 24px;
  472. }
  473. }
  474. .popup-good-info {
  475. height: 33px;
  476. box-sizing: border-box;
  477. padding-top: 16px;
  478. margin-top: 16px;
  479. border-top: 1px solid #ECECEC;
  480. font-size: 14px;
  481. font-family: PingFang SC;
  482. color: #9A9A9A;
  483. line-height: 16px;
  484. }
  485. .popup-good-unit {
  486. height: 28px;
  487. display: inline-block;
  488. padding: 0 22px;
  489. margin-top: 14px;
  490. background: #52A63A;
  491. border-radius: 14px;
  492. font-size: 14px;
  493. font-family: PingFang SC;
  494. color: #FFFFFF;
  495. line-height: 28px;
  496. }
  497. .popup-good-number-box {
  498. height: 20px;
  499. float: right;
  500. margin-top: -20px;
  501. .good-select {
  502. font-size: 16px;
  503. font-family: PingFang SC;
  504. color: #343434;
  505. margin: 0 12px;
  506. line-height: 20px;
  507. }
  508. }
  509. }
  510. }
  511. </style>