detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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-dayufuhao"></text>
  38. </view>
  39. <view class="thr_1">
  40. <view class="title">商品评价({{info.comment||0}})</view>
  41. <text class="iconfont icon-dayufuhao"></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-kongxin"></text>
  78. <text v-else @click="toCollect" class="iconfont icon-shixin"></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"
  112. :style="{color:color,background:background}">{{info.specs.flavor}}</text></view>
  113. </view>
  114. <view class="thr">
  115. <text>数量:</text>
  116. <view class="count">
  117. <uni-number-box :disabled="disabled" v-model="info.specs.num" @change="toCount">
  118. </uni-number-box>
  119. </view>
  120. </view>
  121. <view @click="toBuy" class="button">{{type=='0'?'加入购物车':'立即购买'}}</view>
  122. </view>
  123. </uni-popup>
  124. </mobile-frame>
  125. </template>
  126. <script>
  127. export default {
  128. data() {
  129. return {
  130. barList: [{
  131. name: '首页',
  132. route: 'pages/home/index',
  133. normal: require('@/static/shouye.png'),
  134. active: require('@/static/shouye_1.png')
  135. },
  136. {
  137. name: '微店',
  138. route: 'pages/store/index',
  139. normal: require('@/static/store.png'),
  140. active: require('@/static/store_1.png')
  141. },
  142. {
  143. name: '周边',
  144. route: 'pages/week/index',
  145. normal: require('@/static/week.png'),
  146. active: require('@/static/week_1.png')
  147. },
  148. {
  149. name: '购物车',
  150. route: 'pages/market/index',
  151. normal: require('@/static/market.png'),
  152. active: require('@/static/market_1.png')
  153. },
  154. {
  155. name: '我的',
  156. route: 'pages/my/index',
  157. normal: require('@/static/my.png'),
  158. active: require('@/static/my_1.png')
  159. },
  160. ],
  161. options: [{
  162. icon: 'shop',
  163. text: '店铺',
  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. bannerList: [ // 轮播图
  187. {
  188. url: require('@/static/test.png')
  189. },
  190. {
  191. url: require('@/static/test.png')
  192. },
  193. {
  194. url: require('@/static/test.png')
  195. },
  196. {
  197. url: require('@/static/test.png')
  198. },
  199. ],
  200. // 详情
  201. info: {
  202. file: require('@/static/test.png'),
  203. name: '大红门无淀粉果木熏火腿360g',
  204. sell_money: 28.8,
  205. flow_money: 35,
  206. shot_brief: '果木熏制 传统技法',
  207. freight: 8.00,
  208. send_time: '24h',
  209. specs: {
  210. flavor: '果木熏火腿',
  211. num: 0
  212. },
  213. brief: '简介',
  214. },
  215. shop: {
  216. file: require('@/static/test.png'),
  217. name: '官方自营店',
  218. num: 2,
  219. time: '2022-09-27'
  220. },
  221. // 已选
  222. Selected: '',
  223. // 是否显示返回顶部
  224. isShow: false,
  225. topItem: '',
  226. // 收藏
  227. collection: false,
  228. // 菜单显示
  229. menu: false,
  230. disabled: true,
  231. background: '#f9f9f9',
  232. color: '#000',
  233. // 显示文字判断
  234. type:'0'
  235. };
  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. // 计算高度
  302. handleScroll(e) {
  303. const that = this;
  304. let scrollTop = e.detail.scrollTop;
  305. that.isShow = scrollTop > 500;
  306. that.topItem = '';
  307. },
  308. // 返回顶部
  309. backTop() {
  310. const that = this;
  311. that.topItem = 'top'
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss">
  317. .scrollView {
  318. height: 100vh;
  319. }
  320. .main {
  321. display: flex;
  322. flex-direction: column;
  323. width: 100vw;
  324. height: 100vh;
  325. .onemain {
  326. position: relative;
  327. flex-grow: 1;
  328. background-color: var(--f9Color);
  329. .one {
  330. swiper {
  331. height: 80vw;
  332. }
  333. .list {
  334. border-radius: 5px;
  335. .image {
  336. width: 100%;
  337. height: 100%;
  338. border-radius: 5px;
  339. }
  340. }
  341. }
  342. .two {
  343. padding: 0 0 2vw 0;
  344. background-color: var(--mainColor);
  345. .two_1 {
  346. display: flex;
  347. align-items: center;
  348. border-bottom: 0.5vw solid var(--f9Color);
  349. padding: 2vw;
  350. .money_1 {
  351. color: var(--ff0Color);
  352. text {
  353. margin: 0 1vw 0 0;
  354. }
  355. text:last-child {
  356. font-size: var(--font20Szie);
  357. font-weight: bold;
  358. }
  359. }
  360. .money_2 {
  361. text-decoration: line-through;
  362. color: var(--f99Color);
  363. text {
  364. margin: 0 1vw 0 0;
  365. }
  366. text:last-child {
  367. font-size: var(--font16Size);
  368. }
  369. }
  370. }
  371. .two_2 {
  372. font-size: var(--font18Szie);
  373. font-weight: bold;
  374. padding: 1vw 2vw;
  375. }
  376. .two_3 {
  377. font-size: var(--font16Szie);
  378. color: var(--f85Color);
  379. padding: 1vw 2vw;
  380. }
  381. .two_4 {
  382. font-size: var(--font12Size);
  383. color: var(--fcColor);
  384. padding: 1vw 2vw;
  385. text {
  386. margin: 0 2vw 0 0;
  387. }
  388. }
  389. }
  390. .thr {
  391. .thr_1 {
  392. display: flex;
  393. flex-direction: row;
  394. justify-content: space-between;
  395. margin: 2vw 0 2vw 0;
  396. padding: 2vw;
  397. background-color: var(--mainColor);
  398. }
  399. }
  400. .four {
  401. padding: 2vw;
  402. background-color: var(--mainColor);
  403. .four_1 {
  404. display: flex;
  405. justify-content: space-between;
  406. .image {
  407. width: 15vw;
  408. height: 15vw;
  409. border: 0.1vw solid var(--fcColor);
  410. }
  411. .other {
  412. flex-grow: 1;
  413. margin: 0 0 0 2vw;
  414. .name {
  415. font-size: var(--font16Szie);
  416. }
  417. .other_1 {
  418. font-size: var(--font12Size);
  419. text {
  420. color: var(--fcColor);
  421. margin: 0 2vw 0 0;
  422. }
  423. }
  424. }
  425. }
  426. .four_2 {
  427. display: flex;
  428. flex-direction: row;
  429. justify-content: space-evenly;
  430. padding: 2vw 0;
  431. color: var(--f99Color);
  432. .grade {
  433. font-size: var(--font14Size);
  434. color: var(--f85Color);
  435. text {
  436. color: var(--ff0Color);
  437. }
  438. }
  439. .btn {
  440. border: 0.1vw solid var(--fcColor);
  441. padding: 1vw 6vw;
  442. border-radius: 1vw;
  443. color: var(--f00Color);
  444. }
  445. .btn:last-child {
  446. padding: 1vw 10vw;
  447. }
  448. }
  449. }
  450. .five {
  451. margin: 2vw 0 0 0;
  452. .five_1 {
  453. padding: 2vw;
  454. background-color: var(--mainColor);
  455. font-size: var(--font18Szie);
  456. color: var(--f99Color);
  457. }
  458. .five_2 {
  459. padding: 0 2vw;
  460. background-color: var(--mainColor);
  461. text-align: center;
  462. }
  463. }
  464. }
  465. }
  466. .scroll-view {
  467. position: absolute;
  468. top: 0;
  469. left: 0;
  470. right: 0;
  471. bottom: 0;
  472. .list-scroll-view {
  473. display: flex;
  474. flex-direction: column;
  475. }
  476. }
  477. .scrollView {
  478. height: 100vh;
  479. }
  480. .collect {
  481. position: fixed;
  482. top: 15vw;
  483. right: 5vw;
  484. text {
  485. font-size: 30px;
  486. background-color: #0000005f;
  487. border-radius: 90px;
  488. }
  489. }
  490. .menu {
  491. position: fixed;
  492. bottom: 30vw;
  493. right: 5vw;
  494. text {
  495. font-size: 30px;
  496. background-color: #0000005f;
  497. border-radius: 90px;
  498. }
  499. }
  500. .menu_1 {
  501. position: fixed;
  502. bottom: 40vw;
  503. right: 5vw;
  504. background-color: var(--mainColor);
  505. padding: 2vw;
  506. .title {
  507. display: flex;
  508. padding: 2vw;
  509. border-bottom: 0.1vw solid var(--fcColor);
  510. .image {
  511. width: 7vw;
  512. height: 6vw;
  513. }
  514. .name {
  515. margin: 0 0 0 1vw;
  516. font-size: var(--font14Size);
  517. }
  518. }
  519. }
  520. .backTop {
  521. position: fixed;
  522. bottom: 20vw;
  523. right: 5vw;
  524. text {
  525. font-size: 30px;
  526. background-color: #0000005f;
  527. border-radius: 90px;
  528. }
  529. }
  530. uni-popup {
  531. z-index: 999999 !important;
  532. }
  533. .content {
  534. height: 100vw;
  535. .one {
  536. display: flex;
  537. flex-direction: row;
  538. justify-content: space-between;
  539. margin: 2vw;
  540. padding: 2vw 0;
  541. border-bottom: 1px solid var(--f9Color);
  542. .image {
  543. width: 25vw;
  544. height: 25vw;
  545. margin: 0 2vw 0 0;
  546. }
  547. .other {
  548. display: flex;
  549. flex-direction: column;
  550. flex-grow: 1;
  551. margin: 0 0 0 2vw;
  552. .money {
  553. color: var(--fFB1Color);
  554. font-size: var(--font20Szie);
  555. padding: 2vw 0;
  556. }
  557. .other_1 {
  558. font-size: var(--font14Size);
  559. text {
  560. padding: 0 2vw;
  561. color: var(--f85Color);
  562. }
  563. }
  564. }
  565. }
  566. .two {
  567. margin: 0 2vw;
  568. padding: 2vw 0;
  569. font-size: var(--font12Size);
  570. border-bottom: 1px solid var(--f9Color);
  571. .two_2 {
  572. padding: 1vw;
  573. text {
  574. padding: 1vw;
  575. border-radius: 1vw;
  576. background-color: var(--f9Color);
  577. }
  578. }
  579. }
  580. .thr {
  581. display: flex;
  582. justify-content: space-between;
  583. margin: 0 2vw;
  584. padding: 2vw 0;
  585. text {
  586. margin: 1vw 0 0 0;
  587. }
  588. .count {
  589. margin: 0 2vw;
  590. flex-grow: 1;
  591. }
  592. }
  593. .button {
  594. position: fixed;
  595. width: 100vw;
  596. padding: 4vw 0;
  597. background-color: var(--fFB1Color);
  598. bottom: 0;
  599. text-align: center;
  600. font-size: var(--font18Szie);
  601. color: var(--mainColor);
  602. }
  603. }
  604. </style>