detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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" @tap="toCommon('pagesHome/shop/index')">进入店铺</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. route: 'pagesHome/shop/index',
  164. },
  165. {
  166. icon: 'cart',
  167. text: '购物车',
  168. }, {
  169. icon: 'chat',
  170. text: '客服',
  171. }
  172. ],
  173. buttonGroup: [{
  174. text: '加入购物车',
  175. backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
  176. color: '#fff',
  177. type: '0'
  178. },
  179. {
  180. text: '立即购买',
  181. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  182. color: '#fff',
  183. type: '1'
  184. }
  185. ],
  186. id: '',
  187. bannerList: [],
  188. // 详情
  189. info: {},
  190. shop: {},
  191. specs: [],
  192. // 已选
  193. Selected: '',
  194. // 是否显示返回顶部
  195. isShow: false,
  196. topItem: '',
  197. // 收藏
  198. collection: false,
  199. // 菜单显示
  200. menu: false,
  201. disabled: true,
  202. // 显示文字判断
  203. type: '0',
  204. // 选择规格
  205. isActive: -1,
  206. money: 0,
  207. // 计数器
  208. num: 1,
  209. max: 0
  210. };
  211. },
  212. onLoad: async function(e) {
  213. const that = this;
  214. that.$set(that, `id`, e.id || '');
  215. that.search();
  216. },
  217. onShow: function() {},
  218. methods: {
  219. onClick(e) {
  220. if (e && e.content.route){
  221. uni.navigateTo({
  222. url: `/${e.content.route}`
  223. })
  224. }
  225. },
  226. // 公共跳转
  227. toCommon(e) {
  228. uni.navigateTo({
  229. url: `/${e}`
  230. })
  231. },
  232. toPath(e) {
  233. if (e && e.route) uni.reLaunch({
  234. url: `/${e.route}`
  235. })
  236. },
  237. buttonClick(e) {
  238. const that = this;
  239. if (e && e.content) that.type = e.content.type;
  240. that.$refs.popup.open();
  241. },
  242. // 选择规格
  243. toChoose() {
  244. const that = this;
  245. that.type = '1';
  246. that.$refs.popup.open();
  247. },
  248. // 关闭弹框
  249. toClose() {
  250. const that = this;
  251. that.$refs.popup.close()
  252. },
  253. // 修改样式
  254. toStyle(e, index) {
  255. const that = this;
  256. that.$set(that, `isActive`, index)
  257. that.$set(that, `Selected`, e.name)
  258. that.$set(that, `max`, e.num)
  259. that.$set(that, `money`, e.sell_money)
  260. that.disabled = false;
  261. },
  262. // 计数器
  263. toCount(e) {
  264. const that = this;
  265. that.num = e;
  266. },
  267. // 收藏
  268. toCollect() {
  269. const that = this;
  270. that.collection = !that.collection;
  271. if (that.collection == true) {
  272. uni.showToast({
  273. title: `收藏成功`,
  274. icon: 'none'
  275. })
  276. } else {
  277. uni.showToast({
  278. title: `取消成功`,
  279. icon: 'none'
  280. })
  281. }
  282. },
  283. // 菜单展开
  284. toMenu() {
  285. const that = this;
  286. that.menu = !that.menu
  287. },
  288. // 立即购买
  289. toBuy() {
  290. const that = this;
  291. if (that.Selected) {
  292. uni.navigateTo({
  293. url: `/pagesHome/order/order`
  294. })
  295. } else {
  296. uni.showModal({
  297. title: '提示',
  298. content: '请选择规格',
  299. confirmColor: '#ff0000',
  300. showCancel: false,
  301. success: function(res) {}
  302. });
  303. }
  304. },
  305. // 计算高度
  306. handleScroll(e) {
  307. const that = this;
  308. let scrollTop = e.detail.scrollTop;
  309. that.isShow = scrollTop > 500;
  310. that.topItem = '';
  311. },
  312. // 返回顶部
  313. backTop() {
  314. const that = this;
  315. that.topItem = 'top'
  316. },
  317. async search() {
  318. const that = this;
  319. let res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  320. id: that.id
  321. });
  322. if (res.errcode == '0') {
  323. that.$set(that, `info`, res.data.goods)
  324. that.$set(that, `specs`, res.data.specs)
  325. that.$set(that, `shop`, res.data.shop)
  326. if (res.data.specs.length > 0) that.$set(that, `money`, res.data.specs[0].sell_money)
  327. that.$set(that, `bannerList`, res.data.goods.file)
  328. }
  329. },
  330. }
  331. }
  332. </script>
  333. <style lang="scss">
  334. .scrollView {
  335. height: 100vh;
  336. }
  337. .main {
  338. display: flex;
  339. flex-direction: column;
  340. width: 100vw;
  341. height: 100vh;
  342. .onemain {
  343. position: relative;
  344. flex-grow: 1;
  345. background-color: var(--f9Color);
  346. .one {
  347. swiper {
  348. height: 70vw;
  349. }
  350. .list {
  351. border-radius: 5px;
  352. .image {
  353. width: 100%;
  354. height: 100%;
  355. border-radius: 5px;
  356. }
  357. }
  358. }
  359. .two {
  360. padding: 0 0 2vw 0;
  361. background-color: var(--mainColor);
  362. .two_1 {
  363. display: flex;
  364. align-items: center;
  365. border-bottom: 0.5vw solid var(--f9Color);
  366. padding: 2vw;
  367. .money_1 {
  368. color: var(--ff0Color);
  369. text {
  370. margin: 0 1vw 0 0;
  371. }
  372. text:last-child {
  373. font-size: var(--font20Szie);
  374. font-weight: bold;
  375. }
  376. }
  377. .money_2 {
  378. text-decoration: line-through;
  379. color: var(--f99Color);
  380. text {
  381. margin: 0 1vw 0 0;
  382. }
  383. text:last-child {
  384. font-size: var(--font16Size);
  385. }
  386. }
  387. }
  388. .two_2 {
  389. font-size: var(--font18Szie);
  390. font-weight: bold;
  391. padding: 1vw 2vw;
  392. }
  393. .two_3 {
  394. font-size: var(--font16Szie);
  395. color: var(--f85Color);
  396. padding: 1vw 2vw;
  397. }
  398. .two_4 {
  399. font-size: var(--font12Size);
  400. color: var(--fcColor);
  401. padding: 1vw 2vw;
  402. text {
  403. margin: 0 2vw 0 0;
  404. }
  405. }
  406. }
  407. .thr {
  408. .thr_1 {
  409. display: flex;
  410. flex-direction: row;
  411. justify-content: space-between;
  412. margin: 2vw 0 2vw 0;
  413. padding: 2vw;
  414. background-color: var(--mainColor);
  415. }
  416. }
  417. .four {
  418. padding: 2vw;
  419. background-color: var(--mainColor);
  420. .four_1 {
  421. display: flex;
  422. justify-content: space-between;
  423. .image {
  424. width: 15vw;
  425. height: 15vw;
  426. border: 0.1vw solid var(--fcColor);
  427. }
  428. .other {
  429. flex-grow: 1;
  430. margin: 0 0 0 2vw;
  431. .name {
  432. font-size: var(--font16Szie);
  433. }
  434. .other_1 {
  435. font-size: var(--font12Size);
  436. text {
  437. color: var(--fcColor);
  438. margin: 0 2vw 0 0;
  439. }
  440. }
  441. }
  442. }
  443. .four_2 {
  444. display: flex;
  445. flex-direction: row;
  446. justify-content: space-evenly;
  447. padding: 2vw 0;
  448. color: var(--f99Color);
  449. .grade {
  450. font-size: var(--font14Size);
  451. color: var(--f85Color);
  452. text {
  453. color: var(--ff0Color);
  454. }
  455. }
  456. .btn {
  457. border: 0.1vw solid var(--fcColor);
  458. padding: 1vw 6vw;
  459. border-radius: 1vw;
  460. color: var(--f00Color);
  461. }
  462. .btn:last-child {
  463. padding: 1vw 10vw;
  464. }
  465. }
  466. }
  467. .five {
  468. margin: 2vw 0 0 0;
  469. .five_1 {
  470. padding: 2vw;
  471. background-color: var(--mainColor);
  472. font-size: var(--font18Szie);
  473. color: var(--f99Color);
  474. }
  475. .five_2 {
  476. padding: 0 2vw;
  477. background-color: var(--mainColor);
  478. text-align: center;
  479. }
  480. }
  481. }
  482. }
  483. .scroll-view {
  484. position: absolute;
  485. top: 0;
  486. left: 0;
  487. right: 0;
  488. bottom: 0;
  489. .list-scroll-view {
  490. display: flex;
  491. flex-direction: column;
  492. }
  493. }
  494. .scrollView {
  495. height: 100vh;
  496. }
  497. .collect {
  498. position: fixed;
  499. top: 4vw;
  500. right: 5vw;
  501. text {
  502. font-size: 30px;
  503. background-color: #0000005f;
  504. border-radius: 90px;
  505. }
  506. }
  507. .menu {
  508. position: fixed;
  509. bottom: 30vw;
  510. right: 5vw;
  511. text {
  512. font-size: 30px;
  513. background-color: #0000005f;
  514. border-radius: 90px;
  515. }
  516. }
  517. .menu_1 {
  518. position: fixed;
  519. bottom: 40vw;
  520. right: 5vw;
  521. background-color: var(--mainColor);
  522. padding: 2vw;
  523. .title {
  524. display: flex;
  525. padding: 2vw;
  526. border-bottom: 0.1vw solid var(--fcColor);
  527. .image {
  528. width: 7vw;
  529. height: 6vw;
  530. }
  531. .name {
  532. margin: 0 0 0 1vw;
  533. font-size: var(--font14Size);
  534. }
  535. }
  536. }
  537. .backTop {
  538. position: fixed;
  539. bottom: 20vw;
  540. right: 5vw;
  541. text {
  542. font-size: 30px;
  543. background-color: #0000005f;
  544. border-radius: 90px;
  545. }
  546. }
  547. uni-popup {
  548. z-index: 999999 !important;
  549. }
  550. .content {
  551. height: 100vw;
  552. .one {
  553. display: flex;
  554. flex-direction: row;
  555. justify-content: space-between;
  556. margin: 2vw;
  557. padding: 2vw 0;
  558. border-bottom: 1px solid var(--f9Color);
  559. .image {
  560. width: 25vw;
  561. height: 25vw;
  562. margin: 0 2vw 0 0;
  563. }
  564. .other {
  565. display: flex;
  566. flex-direction: column;
  567. flex-grow: 1;
  568. margin: 0 0 0 2vw;
  569. .money {
  570. color: var(--fFB1Color);
  571. font-size: var(--font20Szie);
  572. padding: 2vw 0;
  573. }
  574. .other_1 {
  575. font-size: var(--font14Size);
  576. text {
  577. padding: 0 2vw;
  578. color: var(--f85Color);
  579. }
  580. }
  581. }
  582. }
  583. .two {
  584. margin: 0 2vw;
  585. padding: 2vw 0;
  586. font-size: var(--font12Size);
  587. border-bottom: 1px solid var(--f9Color);
  588. .two_2 {
  589. padding: 1vw;
  590. text {
  591. margin: 0 2vw 0 0;
  592. padding: 1vw;
  593. border-radius: 1vw;
  594. background-color: var(--f9Color);
  595. }
  596. .style {
  597. color: var(--mainColor);
  598. background-color: var(--ff0Color);
  599. }
  600. }
  601. }
  602. .thr {
  603. display: flex;
  604. justify-content: flex-start;
  605. margin: 0 2vw;
  606. padding: 2vw 0;
  607. text {
  608. margin: 0 2vw 0 0;
  609. }
  610. text:last-child {
  611. margin: 0 0 0 2vw;
  612. font-size: var(--font12Size);
  613. color: var(--f85Color);
  614. }
  615. }
  616. .button {
  617. position: fixed;
  618. width: 100vw;
  619. padding: 4vw 0;
  620. background-color: var(--fFB1Color);
  621. bottom: 0;
  622. text-align: center;
  623. font-size: var(--font18Szie);
  624. color: var(--mainColor);
  625. }
  626. }
  627. </style>