detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="onemain">
  5. <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem"
  6. @scroll="handleScroll">
  7. <view class="list-scroll-view" id="top">
  8. <view class="one">
  9. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
  10. indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
  11. <swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
  12. <image class="image" :src="item.url" mode="">
  13. </image>
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. <view class="two">
  18. <view class="two_1">
  19. <view class="money_1">
  20. <text>¥</text>
  21. <text>{{specs&&specs.length>0?specs[0].sell_money:''}}</text>
  22. </view>
  23. <view class="money_2">
  24. <text>¥</text>
  25. <text>{{specs&&specs.length>0?specs[0].flow_money:''}}</text>
  26. </view>
  27. </view>
  28. <view class="two_2">{{info.name}}</view>
  29. <view class="two_3">{{info.shot_brief}}</view>
  30. <view class="two_4">
  31. <text>运费{{specs&&specs.length>0?specs[0].freight:''}}元</text>
  32. <text>{{info.send_time}}内发货</text>
  33. </view>
  34. </view>
  35. <view class="thr">
  36. <view class="thr_1" @click="toChoose">
  37. <view class="title">选择规格</view>
  38. <text class="iconfont icon-jiantouyou"></text>
  39. </view>
  40. <view class="thr_1">
  41. <view class="title">商品评价({{info.comment||0}})</view>
  42. <text class="iconfont icon-jiantouyou"></text>
  43. </view>
  44. </view>
  45. <view class="four">
  46. <view class="four_1">
  47. <image class="image" :src="shop.logo&&shop.logo.length>0?shop.logo[0].url:''"></image>
  48. <view class="other">
  49. <view class="name">{{shop.name}}</view>
  50. <view class="other_1"><text>宝贝数</text>{{shop.num||0}}</view>
  51. </view>
  52. </view>
  53. <view class="four_2">
  54. <view class="grade">商品:<text>{{shop.grade||'5.00'}}</text></view>|
  55. <view class="grade">发货:<text>{{shop.grade||'5.00'}}</text></view>|
  56. <view class="grade">服务:<text>{{shop.grade||'5.00'}}</text></view>
  57. </view>
  58. <view class="four_2">
  59. <view class="btn">进入店铺</view>
  60. <view class="btn">关注</view>
  61. </view>
  62. </view>
  63. <view class="five">
  64. <view class="five_1">{{info.brief}}</view>
  65. <view class="five_2" v-for="(item,index) in bannerList" :key="index">
  66. <image class="image" :src="item.url"></image>
  67. </view>
  68. </view>
  69. </view>
  70. </scroll-view>
  71. </view>
  72. <view class="foot">
  73. <uni-goods-nav :options="options" :button-group="buttonGroup" @click="onClick"
  74. @buttonClick="buttonClick" />
  75. </view>
  76. </view>
  77. <view class="collect">
  78. <text v-if="!collection" @click="toCollect" class="iconfont icon-yduishoucangkongxin"></text>
  79. <text v-else @click="toCollect" class="iconfont icon-yduishoucangshixin"></text>
  80. </view>
  81. <view class="menu">
  82. <text @click="toMenu" class="iconfont icon-gengduo"></text>
  83. </view>
  84. <view class="menu_1" v-if="menu">
  85. <view class="title" v-for="(item,index) in barList" :key="index" @click="toPath(item)">
  86. <image class="image" :src="item.normal"></image>
  87. <view class="name">{{item.name}}</view>
  88. </view>
  89. </view>
  90. <view class="backTop" v-if="isShow==true">
  91. <text @click="backTop" class="iconfont icon-fanhuidingbu"></text>
  92. </view>
  93. <uni-popup ref="popup" background-color="#fff" type="bottom">
  94. <view class="content">
  95. <view class="one">
  96. <image class="image" :src="info.file&&info.file.length>0?info.file[0].url:''"></image>
  97. <view class="other">
  98. <view class="money">
  99. <text>¥</text>
  100. <text>{{money}}</text>
  101. </view>
  102. <view class="other_1">
  103. 已选: <text>{{Selected}}</text>
  104. </view>
  105. </view>
  106. <view class="btn">
  107. <text @click="toClose" class="iconfont icon-shanchu"></text>
  108. </view>
  109. </view>
  110. <view class="two">
  111. <view class="two_1">规格</view>
  112. <view class="two_2">
  113. <text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)"
  114. :class="{ 'style': isActive==index}">{{item.name}}</text>
  115. </view>
  116. </view>
  117. <view class="thr">
  118. <text>数量</text>
  119. <view class="count">
  120. <uni-number-box :min="1" :max="max" :disabled="disabled" v-model="num" @change="toCount">
  121. </uni-number-box>
  122. </view>
  123. <text>库存{{max}}</text>
  124. </view>
  125. <view @click="toBuy" class="button">{{type=='0'?'加入购物车':'立即购买'}}</view>
  126. </view>
  127. </uni-popup>
  128. </mobile-frame>
  129. </template>
  130. <script>
  131. export default {
  132. data() {
  133. return {
  134. barList: [{
  135. name: '首页',
  136. route: 'pages/home/index',
  137. normal: require('@/static/shouye.png'),
  138. },
  139. {
  140. name: '微店',
  141. route: 'pages/store/index',
  142. normal: require('@/static/store.png'),
  143. },
  144. {
  145. name: '周边',
  146. route: 'pages/week/index',
  147. normal: require('@/static/week.png'),
  148. },
  149. {
  150. name: '购物车',
  151. route: 'pages/market/index',
  152. normal: require('@/static/market.png'),
  153. },
  154. {
  155. name: '我的',
  156. route: 'pages/my/index',
  157. normal: require('@/static/my.png'),
  158. },
  159. ],
  160. options: [{
  161. icon: 'shop',
  162. text: '店铺',
  163. },
  164. {
  165. icon: 'cart',
  166. text: '购物车',
  167. }, {
  168. icon: 'chat',
  169. text: '客服',
  170. }
  171. ],
  172. buttonGroup: [{
  173. text: '加入购物车',
  174. backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
  175. color: '#fff',
  176. type: '0'
  177. },
  178. {
  179. text: '立即购买',
  180. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  181. color: '#fff',
  182. type: '1'
  183. }
  184. ],
  185. id: '',
  186. bannerList: [],
  187. // 详情
  188. info: {},
  189. shop: {},
  190. specs: [],
  191. // 已选
  192. Selected: '',
  193. // 是否显示返回顶部
  194. isShow: false,
  195. topItem: '',
  196. // 收藏
  197. collection: false,
  198. // 菜单显示
  199. menu: false,
  200. disabled: true,
  201. // 显示文字判断
  202. type: '0',
  203. // 选择规格
  204. isActive: -1,
  205. money: 0,
  206. // 计数器
  207. num: 1,
  208. max: 0
  209. };
  210. },
  211. onLoad: async function(e) {
  212. const that = this;
  213. that.$set(that, `id`, e.id || '');
  214. that.search();
  215. },
  216. onShow: function() {},
  217. methods: {
  218. onClick(e) {
  219. uni.showToast({
  220. title: `点击${e.content.text}`,
  221. icon: 'none'
  222. })
  223. },
  224. toPath(e) {
  225. if (e && e.route) uni.reLaunch({
  226. url: `/${e.route}`
  227. })
  228. },
  229. buttonClick(e) {
  230. const that = this;
  231. if (e && e.content) that.type = e.content.type;
  232. that.$refs.popup.open();
  233. },
  234. // 选择规格
  235. toChoose() {
  236. const that = this;
  237. that.type = '1';
  238. that.$refs.popup.open();
  239. },
  240. // 关闭弹框
  241. toClose() {
  242. const that = this;
  243. that.$refs.popup.close()
  244. },
  245. // 修改样式
  246. toStyle(e, index) {
  247. const that = this;
  248. that.$set(that, `isActive`, index)
  249. that.$set(that, `Selected`, e.name)
  250. that.$set(that, `max`, e.num)
  251. that.$set(that, `money`, e.sell_money)
  252. that.disabled = false;
  253. },
  254. // 计数器
  255. toCount(e) {
  256. const that = this;
  257. that.num = e;
  258. },
  259. // 收藏
  260. toCollect() {
  261. const that = this;
  262. that.collection = !that.collection;
  263. if (that.collection == true) {
  264. uni.showToast({
  265. title: `收藏成功`,
  266. icon: 'none'
  267. })
  268. } else {
  269. uni.showToast({
  270. title: `取消成功`,
  271. icon: 'none'
  272. })
  273. }
  274. },
  275. // 菜单展开
  276. toMenu() {
  277. const that = this;
  278. that.menu = !that.menu
  279. },
  280. // 立即购买
  281. toBuy() {
  282. const that = this;
  283. if (that.Selected) {
  284. uni.navigateTo({
  285. url: `/pagesHome/order/order`
  286. })
  287. } else {
  288. uni.showModal({
  289. title: '提示',
  290. content: '请选择规格',
  291. confirmColor: '#ff0000',
  292. showCancel: false,
  293. success: function(res) {}
  294. });
  295. }
  296. },
  297. // 计算高度
  298. handleScroll(e) {
  299. const that = this;
  300. let scrollTop = e.detail.scrollTop;
  301. that.isShow = scrollTop > 500;
  302. that.topItem = '';
  303. },
  304. // 返回顶部
  305. backTop() {
  306. const that = this;
  307. that.topItem = 'top'
  308. },
  309. async search() {
  310. const that = this;
  311. let res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  312. id: that.id
  313. });
  314. if (res.errcode == '0') {
  315. that.$set(that, `info`, res.data.goods)
  316. that.$set(that, `specs`, res.data.specs)
  317. that.$set(that, `shop`, res.data.shop)
  318. if (res.data.specs.length > 0) that.$set(that, `money`, res.data.specs[0].sell_money)
  319. that.$set(that, `bannerList`, res.data.goods.file)
  320. }
  321. },
  322. }
  323. }
  324. </script>
  325. <style lang="scss">
  326. .scrollView {
  327. height: 100vh;
  328. }
  329. .main {
  330. display: flex;
  331. flex-direction: column;
  332. width: 100vw;
  333. height: 100vh;
  334. .onemain {
  335. position: relative;
  336. flex-grow: 1;
  337. background-color: var(--f9Color);
  338. .one {
  339. swiper {
  340. height: 70vw;
  341. }
  342. .list {
  343. border-radius: 5px;
  344. .image {
  345. width: 100%;
  346. height: 100%;
  347. border-radius: 5px;
  348. }
  349. }
  350. }
  351. .two {
  352. padding: 0 0 2vw 0;
  353. background-color: var(--mainColor);
  354. .two_1 {
  355. display: flex;
  356. align-items: center;
  357. border-bottom: 0.5vw solid var(--f9Color);
  358. padding: 2vw;
  359. .money_1 {
  360. color: var(--ff0Color);
  361. text {
  362. margin: 0 1vw 0 0;
  363. }
  364. text:last-child {
  365. font-size: var(--font20Szie);
  366. font-weight: bold;
  367. }
  368. }
  369. .money_2 {
  370. text-decoration: line-through;
  371. color: var(--f99Color);
  372. text {
  373. margin: 0 1vw 0 0;
  374. }
  375. text:last-child {
  376. font-size: var(--font16Size);
  377. }
  378. }
  379. }
  380. .two_2 {
  381. font-size: var(--font18Szie);
  382. font-weight: bold;
  383. padding: 1vw 2vw;
  384. }
  385. .two_3 {
  386. font-size: var(--font16Szie);
  387. color: var(--f85Color);
  388. padding: 1vw 2vw;
  389. }
  390. .two_4 {
  391. font-size: var(--font12Size);
  392. color: var(--fcColor);
  393. padding: 1vw 2vw;
  394. text {
  395. margin: 0 2vw 0 0;
  396. }
  397. }
  398. }
  399. .thr {
  400. .thr_1 {
  401. display: flex;
  402. flex-direction: row;
  403. justify-content: space-between;
  404. margin: 2vw 0 2vw 0;
  405. padding: 2vw;
  406. background-color: var(--mainColor);
  407. }
  408. }
  409. .four {
  410. padding: 2vw;
  411. background-color: var(--mainColor);
  412. .four_1 {
  413. display: flex;
  414. justify-content: space-between;
  415. .image {
  416. width: 15vw;
  417. height: 15vw;
  418. border: 0.1vw solid var(--fcColor);
  419. }
  420. .other {
  421. flex-grow: 1;
  422. margin: 0 0 0 2vw;
  423. .name {
  424. font-size: var(--font16Szie);
  425. }
  426. .other_1 {
  427. font-size: var(--font12Size);
  428. text {
  429. color: var(--fcColor);
  430. margin: 0 2vw 0 0;
  431. }
  432. }
  433. }
  434. }
  435. .four_2 {
  436. display: flex;
  437. flex-direction: row;
  438. justify-content: space-evenly;
  439. padding: 2vw 0;
  440. color: var(--f99Color);
  441. .grade {
  442. font-size: var(--font14Size);
  443. color: var(--f85Color);
  444. text {
  445. color: var(--ff0Color);
  446. }
  447. }
  448. .btn {
  449. border: 0.1vw solid var(--fcColor);
  450. padding: 1vw 6vw;
  451. border-radius: 1vw;
  452. color: var(--f00Color);
  453. }
  454. .btn:last-child {
  455. padding: 1vw 10vw;
  456. }
  457. }
  458. }
  459. .five {
  460. margin: 2vw 0 0 0;
  461. .five_1 {
  462. padding: 2vw;
  463. background-color: var(--mainColor);
  464. font-size: var(--font18Szie);
  465. color: var(--f99Color);
  466. }
  467. .five_2 {
  468. padding: 0 2vw;
  469. background-color: var(--mainColor);
  470. text-align: center;
  471. }
  472. }
  473. }
  474. }
  475. .scroll-view {
  476. position: absolute;
  477. top: 0;
  478. left: 0;
  479. right: 0;
  480. bottom: 0;
  481. .list-scroll-view {
  482. display: flex;
  483. flex-direction: column;
  484. }
  485. }
  486. .scrollView {
  487. height: 100vh;
  488. }
  489. .collect {
  490. position: fixed;
  491. top: 4vw;
  492. right: 5vw;
  493. text {
  494. font-size: 30px;
  495. background-color: #0000005f;
  496. border-radius: 90px;
  497. }
  498. }
  499. .menu {
  500. position: fixed;
  501. bottom: 30vw;
  502. right: 5vw;
  503. text {
  504. font-size: 30px;
  505. background-color: #0000005f;
  506. border-radius: 90px;
  507. }
  508. }
  509. .menu_1 {
  510. position: fixed;
  511. bottom: 40vw;
  512. right: 5vw;
  513. background-color: var(--mainColor);
  514. padding: 2vw;
  515. .title {
  516. display: flex;
  517. padding: 2vw;
  518. border-bottom: 0.1vw solid var(--fcColor);
  519. .image {
  520. width: 7vw;
  521. height: 6vw;
  522. }
  523. .name {
  524. margin: 0 0 0 1vw;
  525. font-size: var(--font14Size);
  526. }
  527. }
  528. }
  529. .backTop {
  530. position: fixed;
  531. bottom: 20vw;
  532. right: 5vw;
  533. text {
  534. font-size: 30px;
  535. background-color: #0000005f;
  536. border-radius: 90px;
  537. }
  538. }
  539. uni-popup {
  540. z-index: 999999 !important;
  541. }
  542. .content {
  543. height: 100vw;
  544. .one {
  545. display: flex;
  546. flex-direction: row;
  547. justify-content: space-between;
  548. margin: 2vw;
  549. padding: 2vw 0;
  550. border-bottom: 1px solid var(--f9Color);
  551. .image {
  552. width: 25vw;
  553. height: 25vw;
  554. margin: 0 2vw 0 0;
  555. }
  556. .other {
  557. display: flex;
  558. flex-direction: column;
  559. flex-grow: 1;
  560. margin: 0 0 0 2vw;
  561. .money {
  562. color: var(--fFB1Color);
  563. font-size: var(--font20Szie);
  564. padding: 2vw 0;
  565. }
  566. .other_1 {
  567. font-size: var(--font14Size);
  568. text {
  569. padding: 0 2vw;
  570. color: var(--f85Color);
  571. }
  572. }
  573. }
  574. }
  575. .two {
  576. margin: 0 2vw;
  577. padding: 2vw 0;
  578. font-size: var(--font12Size);
  579. border-bottom: 1px solid var(--f9Color);
  580. .two_2 {
  581. padding: 1vw;
  582. text {
  583. margin: 0 2vw 0 0;
  584. padding: 1vw;
  585. border-radius: 1vw;
  586. background-color: var(--f9Color);
  587. }
  588. .style {
  589. color: var(--mainColor);
  590. background-color: var(--ff0Color);
  591. }
  592. }
  593. }
  594. .thr {
  595. display: flex;
  596. justify-content: flex-start;
  597. margin: 0 2vw;
  598. padding: 2vw 0;
  599. text {
  600. margin: 0 2vw 0 0;
  601. }
  602. text:last-child {
  603. margin: 0 0 0 2vw;
  604. font-size: var(--font12Size);
  605. color: var(--f85Color);
  606. }
  607. }
  608. .button {
  609. position: fixed;
  610. width: 100vw;
  611. padding: 4vw 0;
  612. background-color: var(--fFB1Color);
  613. bottom: 0;
  614. text-align: center;
  615. font-size: var(--font18Szie);
  616. color: var(--mainColor);
  617. }
  618. }
  619. </style>