detail.vue 16 KB

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