detail.vue 16 KB

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