detail.vue 16 KB

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