detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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-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. },
  135. {
  136. name: '微店',
  137. route: 'pages/store/index',
  138. normal: require('@/static/store.png'),
  139. },
  140. {
  141. name: '周边',
  142. route: 'pages/week/index',
  143. normal: require('@/static/week.png'),
  144. },
  145. {
  146. name: '购物车',
  147. route: 'pages/market/index',
  148. normal: require('@/static/market.png'),
  149. },
  150. {
  151. name: '我的',
  152. route: 'pages/my/index',
  153. normal: require('@/static/my.png'),
  154. },
  155. ],
  156. options: [{
  157. icon: 'shop',
  158. text: '店铺',
  159. },
  160. {
  161. icon: 'cart',
  162. text: '购物车',
  163. }, {
  164. icon: 'chat',
  165. text: '客服',
  166. }
  167. ],
  168. buttonGroup: [{
  169. text: '加入购物车',
  170. backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
  171. color: '#fff',
  172. type: '0'
  173. },
  174. {
  175. text: '立即购买',
  176. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  177. color: '#fff',
  178. type: '1'
  179. }
  180. ],
  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: 0
  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. onShow: function() {},
  233. methods: {
  234. onClick(e) {
  235. uni.showToast({
  236. title: `点击${e.content.text}`,
  237. icon: 'none'
  238. })
  239. },
  240. toPath(e) {
  241. if (e && e.route) uni.reLaunch({
  242. url: `/${e.route}`
  243. })
  244. },
  245. buttonClick(e) {
  246. const that = this;
  247. if (e && e.content) that.type = e.content.type;
  248. that.$refs.popup.open();
  249. },
  250. // 选择规格
  251. toChoose() {
  252. const that = this;
  253. that.type = '1';
  254. that.$refs.popup.open();
  255. },
  256. // 关闭弹框
  257. toClose() {
  258. const that = this;
  259. that.$refs.popup.close()
  260. },
  261. // 修改样式
  262. toStyle() {
  263. const that = this;
  264. that.color = '#ffffff';
  265. that.background = '#ff0000';
  266. that.Selected = that.info.specs.flavor;
  267. that.disabled = false;
  268. },
  269. // 计数器
  270. toCount(e) {
  271. console.log(e);
  272. },
  273. // 收藏
  274. toCollect() {
  275. const that = this;
  276. that.collection = !that.collection;
  277. if (that.collection == true) {
  278. uni.showToast({
  279. title: `收藏成功`,
  280. icon: 'none'
  281. })
  282. } else {
  283. uni.showToast({
  284. title: `取消成功`,
  285. icon: 'none'
  286. })
  287. }
  288. },
  289. // 菜单展开
  290. toMenu() {
  291. const that = this;
  292. that.menu = !that.menu
  293. },
  294. // 立即购买
  295. toBuy() {},
  296. // 计算高度
  297. handleScroll(e) {
  298. const that = this;
  299. let scrollTop = e.detail.scrollTop;
  300. that.isShow = scrollTop > 500;
  301. that.topItem = '';
  302. },
  303. // 返回顶部
  304. backTop() {
  305. const that = this;
  306. that.topItem = 'top'
  307. }
  308. }
  309. }
  310. </script>
  311. <style lang="scss">
  312. .scrollView {
  313. height: 100vh;
  314. }
  315. .main {
  316. display: flex;
  317. flex-direction: column;
  318. width: 100vw;
  319. height: 100vh;
  320. .onemain {
  321. position: relative;
  322. flex-grow: 1;
  323. background-color: var(--f9Color);
  324. .one {
  325. swiper {
  326. height: 70vw;
  327. }
  328. .list {
  329. border-radius: 5px;
  330. .image {
  331. width: 100%;
  332. height: 100%;
  333. border-radius: 5px;
  334. }
  335. }
  336. }
  337. .two {
  338. padding: 0 0 2vw 0;
  339. background-color: var(--mainColor);
  340. .two_1 {
  341. display: flex;
  342. align-items: center;
  343. border-bottom: 0.5vw solid var(--f9Color);
  344. padding: 2vw;
  345. .money_1 {
  346. color: var(--ff0Color);
  347. text {
  348. margin: 0 1vw 0 0;
  349. }
  350. text:last-child {
  351. font-size: var(--font20Szie);
  352. font-weight: bold;
  353. }
  354. }
  355. .money_2 {
  356. text-decoration: line-through;
  357. color: var(--f99Color);
  358. text {
  359. margin: 0 1vw 0 0;
  360. }
  361. text:last-child {
  362. font-size: var(--font16Size);
  363. }
  364. }
  365. }
  366. .two_2 {
  367. font-size: var(--font18Szie);
  368. font-weight: bold;
  369. padding: 1vw 2vw;
  370. }
  371. .two_3 {
  372. font-size: var(--font16Szie);
  373. color: var(--f85Color);
  374. padding: 1vw 2vw;
  375. }
  376. .two_4 {
  377. font-size: var(--font12Size);
  378. color: var(--fcColor);
  379. padding: 1vw 2vw;
  380. text {
  381. margin: 0 2vw 0 0;
  382. }
  383. }
  384. }
  385. .thr {
  386. .thr_1 {
  387. display: flex;
  388. flex-direction: row;
  389. justify-content: space-between;
  390. margin: 2vw 0 2vw 0;
  391. padding: 2vw;
  392. background-color: var(--mainColor);
  393. }
  394. }
  395. .four {
  396. padding: 2vw;
  397. background-color: var(--mainColor);
  398. .four_1 {
  399. display: flex;
  400. justify-content: space-between;
  401. .image {
  402. width: 15vw;
  403. height: 15vw;
  404. border: 0.1vw solid var(--fcColor);
  405. }
  406. .other {
  407. flex-grow: 1;
  408. margin: 0 0 0 2vw;
  409. .name {
  410. font-size: var(--font16Szie);
  411. }
  412. .other_1 {
  413. font-size: var(--font12Size);
  414. text {
  415. color: var(--fcColor);
  416. margin: 0 2vw 0 0;
  417. }
  418. }
  419. }
  420. }
  421. .four_2 {
  422. display: flex;
  423. flex-direction: row;
  424. justify-content: space-evenly;
  425. padding: 2vw 0;
  426. color: var(--f99Color);
  427. .grade {
  428. font-size: var(--font14Size);
  429. color: var(--f85Color);
  430. text {
  431. color: var(--ff0Color);
  432. }
  433. }
  434. .btn {
  435. border: 0.1vw solid var(--fcColor);
  436. padding: 1vw 6vw;
  437. border-radius: 1vw;
  438. color: var(--f00Color);
  439. }
  440. .btn:last-child {
  441. padding: 1vw 10vw;
  442. }
  443. }
  444. }
  445. .five {
  446. margin: 2vw 0 0 0;
  447. .five_1 {
  448. padding: 2vw;
  449. background-color: var(--mainColor);
  450. font-size: var(--font18Szie);
  451. color: var(--f99Color);
  452. }
  453. .five_2 {
  454. padding: 0 2vw;
  455. background-color: var(--mainColor);
  456. text-align: center;
  457. }
  458. }
  459. }
  460. }
  461. .scroll-view {
  462. position: absolute;
  463. top: 0;
  464. left: 0;
  465. right: 0;
  466. bottom: 0;
  467. .list-scroll-view {
  468. display: flex;
  469. flex-direction: column;
  470. }
  471. }
  472. .scrollView {
  473. height: 100vh;
  474. }
  475. .collect {
  476. position: fixed;
  477. top: 4vw;
  478. right: 5vw;
  479. text {
  480. font-size: 30px;
  481. background-color: #0000005f;
  482. border-radius: 90px;
  483. }
  484. }
  485. .menu {
  486. position: fixed;
  487. bottom: 30vw;
  488. right: 5vw;
  489. text {
  490. font-size: 30px;
  491. background-color: #0000005f;
  492. border-radius: 90px;
  493. }
  494. }
  495. .menu_1 {
  496. position: fixed;
  497. bottom: 40vw;
  498. right: 5vw;
  499. background-color: var(--mainColor);
  500. padding: 2vw;
  501. .title {
  502. display: flex;
  503. padding: 2vw;
  504. border-bottom: 0.1vw solid var(--fcColor);
  505. .image {
  506. width: 7vw;
  507. height: 6vw;
  508. }
  509. .name {
  510. margin: 0 0 0 1vw;
  511. font-size: var(--font14Size);
  512. }
  513. }
  514. }
  515. .backTop {
  516. position: fixed;
  517. bottom: 20vw;
  518. right: 5vw;
  519. text {
  520. font-size: 30px;
  521. background-color: #0000005f;
  522. border-radius: 90px;
  523. }
  524. }
  525. uni-popup {
  526. z-index: 999999 !important;
  527. }
  528. .content {
  529. height: 100vw;
  530. .one {
  531. display: flex;
  532. flex-direction: row;
  533. justify-content: space-between;
  534. margin: 2vw;
  535. padding: 2vw 0;
  536. border-bottom: 1px solid var(--f9Color);
  537. .image {
  538. width: 25vw;
  539. height: 25vw;
  540. margin: 0 2vw 0 0;
  541. }
  542. .other {
  543. display: flex;
  544. flex-direction: column;
  545. flex-grow: 1;
  546. margin: 0 0 0 2vw;
  547. .money {
  548. color: var(--fFB1Color);
  549. font-size: var(--font20Szie);
  550. padding: 2vw 0;
  551. }
  552. .other_1 {
  553. font-size: var(--font14Size);
  554. text {
  555. padding: 0 2vw;
  556. color: var(--f85Color);
  557. }
  558. }
  559. }
  560. }
  561. .two {
  562. margin: 0 2vw;
  563. padding: 2vw 0;
  564. font-size: var(--font12Size);
  565. border-bottom: 1px solid var(--f9Color);
  566. .two_2 {
  567. padding: 1vw;
  568. text {
  569. padding: 1vw;
  570. border-radius: 1vw;
  571. background-color: var(--f9Color);
  572. }
  573. }
  574. }
  575. .thr {
  576. display: flex;
  577. justify-content: space-between;
  578. margin: 0 2vw;
  579. padding: 2vw 0;
  580. text {
  581. margin: 1vw 0 0 0;
  582. }
  583. .count {
  584. margin: 0 2vw;
  585. flex-grow: 1;
  586. }
  587. }
  588. .button {
  589. position: fixed;
  590. width: 100vw;
  591. padding: 4vw 0;
  592. background-color: var(--fFB1Color);
  593. bottom: 0;
  594. text-align: center;
  595. font-size: var(--font18Szie);
  596. color: var(--mainColor);
  597. }
  598. }
  599. </style>