detail.vue 14 KB

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