store.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <!-- v-show="liveId" -->
  3. <view class="content">
  4. <view class="uni-nav-bar" style="background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);">
  5. <view :style="{height: statusBarHeight + 'px',width: '100%'}"></view>
  6. <view class="uni-nav-barbox">
  7. <view class="uni-nav-back">
  8. <u-icon name="arrow-left" color="#1a1a1a" size="20" @click="rightClick"></u-icon>
  9. </view>
  10. <view class="uni-nav-title">
  11. <view class="inputbox" style="background: rgba(255, 255, 255, 0.4)"
  12. @click="toSearch">
  13. <image class="icon-search" src="/static/images/search_white.png"></image>
  14. <view>搜索本店</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- <view class="bg"></view> -->
  20. <!-- <image class="bg" src="/static/images/chu_query.png" mode="widthFix"></image> -->
  21. <view class="content-body">
  22. <view class="store-head" v-show="storeInfo.storeName">
  23. <view class="store-head-top">
  24. <view class="store-head-logo">
  25. <u-image shape="square" :src="storeInfo.logoUrl || logoUrl" width="100rpx" height="100rpx"
  26. radius="6"></u-image>
  27. </view>
  28. <view class="store-head-name">{{storeInfo.storeName || ''}}</view>
  29. </view>
  30. <view class="store-head-desc">
  31. <view>销售{{storeInfo.salesCount }}</view>
  32. <view>24小时营业</view>
  33. <view>支持预订</view>
  34. </view>
  35. </view>
  36. <view class="storebox">
  37. <!-- 商品 -->
  38. <view class="medic-box">
  39. <!-- <view class="cate-list">
  40. <view v-for="(item,index) in cates" :key="index" :class="cateSelect == item.cateId?'item active':'item'" @click="choseCate(item)">
  41. {{item.cateName }}</view>
  42. </view> -->
  43. <view class="medic">
  44. <!-- <u-tabs :list="tabList" lineColor="linear-gradient( 90deg, #FE8227 0%, #FE4E12 100%)"
  45. :activeStyle="{
  46. color: '#222222',
  47. fontWeight: '600',
  48. fontSize: '28rpx'
  49. }" :inactiveStyle="{
  50. color: '#757575',
  51. fontSize: '28rpx',
  52. fontWeight: '400'
  53. }" @click="selectTabList"></u-tabs> -->
  54. <!-- 轮播图 -->
  55. <!-- <view class="banner-box">
  56. <swiper class="swiper" :indicator-dots="true" :circular="true" :autoplay="true"
  57. :interval="3000" :duration="1000" indicator-color="rgba(255, 255, 255, 0.6)"
  58. indicator-active-color="#ffffff">
  59. <swiper-item class="swiper-item" v-for="(item,index) in advs" :key="index" @click="handleAdvClick(item)">
  60. <image :src="item.imageUrl" mode=""></image>
  61. </swiper-item>
  62. </swiper>
  63. </view> -->
  64. <!-- 商品列表 -->
  65. <view class="medic-list">
  66. <view class="inner-list">
  67. <view class="definite" v-for="(subItem,index) in products" :key="index"
  68. @click="showProductList(subItem)">
  69. <view class="img-box">
  70. <image :src="subItem.imgUrl" mode="widthFix"></image>
  71. </view>
  72. <view class="name ellipsis2">{{subItem.productName}}</view>
  73. <view class="price">
  74. <text class="red"><text style="font-size: 20rpx;">¥</text><text
  75. style="font-size: 36rpx;">{{Math.trunc(subItem.price)}}</text>.{{getPureDecimal(subItem.price)?getPureDecimal(subItem.price):'00'}}</text>
  76. <text class="del">¥19.80</text>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 商家信息 -->
  84. <view class="storebox-info" :style="{height: divHeight}" v-show="current == 1">
  85. <view class="storebox-map">
  86. <u-icon name="map" color="#ccc" size="18"></u-icon>
  87. <view style="margin-left: 10rpx;">{{storeInfo.address || "--"}}</view>
  88. </view>
  89. <view class="storebox-map" v-if="storeInfo.phone">
  90. <u-icon name="phone" color="#ccc" size="18"></u-icon>
  91. <view style="margin-left: 10rpx;">{{storeInfo.phone || "--"}}</view>
  92. </view>
  93. <view class="storebox-qualifications" v-if="storeInfo.descs">
  94. <u-icon name="volume" color="#ccc" size="18"></u-icon>
  95. <view style="margin-left: 10rpx;">{{storeInfo.descs || "--"}}</view>
  96. </view>
  97. <view class="storebox-qualifications">
  98. <u-icon name="file-text" color="#ccc" size="18"></u-icon>
  99. <view style="margin-left: 10rpx;">商家资质</view>
  100. </view>
  101. <view class="qualifications">
  102. <view v-for="(img,i) in licenseImagesList" :key="i">
  103. <u-image shape="square" lazyLoad :src="img" width="100%" mode="widthFix" radius="6"
  104. @click="previewImage(i)"></u-image>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import {
  114. searchStore, //查询店铺
  115. liveStore //店铺展示,
  116. } from '@/api/live'
  117. // import {getProductCate} from '@/api/product';
  118. // import {getAdv} from '@/api/adv';
  119. // import { getStoreById } from "@/api/store.js";
  120. export default {
  121. data() {
  122. return {
  123. tabList: [{
  124. name: '推荐',
  125. }, {
  126. name: '分类',
  127. }],
  128. products: [],
  129. liveId: null,
  130. storeId: null,
  131. statusBarHeight: uni.getWindowInfo().statusBarHeight,
  132. // 右侧的胶囊距离右侧屏幕距离-px
  133. menuRight: uni.getStorageSync('menuInfo').menuRight,
  134. // 右侧的胶囊宽度-px
  135. menuWidth: uni.getStorageSync('menuInfo').menuWidth,
  136. opacity: 0,
  137. opacityTxt: 0,
  138. tabbar: [{
  139. name: '商品',
  140. }, {
  141. name: '商家',
  142. }],
  143. current: 0,
  144. storeInfo: {},
  145. // logoUrl: "/static/images/adfd21c004854c9b8997d371d7a0ce8c.jpg",
  146. // 商家资质图片
  147. // licenseImagesList: ["/static/images/sjzz.jpg"],
  148. divHeight: '0px',
  149. allCates: [],
  150. cates: [],
  151. subCates: [],
  152. // 选中药品分类
  153. cateSelect: 0,
  154. // 轮播图
  155. advs: [],
  156. // 'company'表示销售管理的进来的
  157. from: ""
  158. }
  159. },
  160. onLoad(options) {
  161. console.log("接收到的options:", options);
  162. if (options.liveId) {
  163. this.liveId = options.liveId;
  164. this.getliveStore() // 获取小黄车 店铺展示
  165. console.log("接收到的liveId:", this.liveId);
  166. }
  167. if (options.storeId) {
  168. this.storeId = options.storeId || ""
  169. } else {
  170. uni.showToast({
  171. title: "storeId不存在~",
  172. icon: "none"
  173. })
  174. }
  175. },
  176. mounted() {
  177. this.getSearchStore() //查询店铺
  178. },
  179. onShow() {
  180. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`
  181. },
  182. onPageScroll(e) {
  183. if (e.scrollTop <= 44) {
  184. this.opacityTxt = 0
  185. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0
  186. } else if (e.scrollTop > 50) {
  187. this.opacity = 1
  188. this.opacityTxt = 1
  189. }
  190. },
  191. methods: {
  192. getPureDecimal(num, precision = 6) {
  193. const decimalPart = Math.abs(num).toFixed(precision).split('.')[1];
  194. return decimalPart?.replace(/0+$/, '') || ''; // 移除末尾多余的0
  195. },
  196. //店铺展示
  197. getliveStore() {
  198. let data = {
  199. pageSize: 10,
  200. page: 1
  201. }
  202. liveStore(this.liveId, data).then(res => {
  203. if (res.code == 200) {
  204. console.log("小黄车 店铺展示>>>>", res)
  205. this.products = res.data
  206. } else {
  207. uni.showToast({
  208. title: res.msg,
  209. icon: 'none'
  210. });
  211. }
  212. },
  213. rej => {}
  214. );
  215. },
  216. //查询店铺
  217. getSearchStore() {
  218. searchStore(this.storeId).then(res => {
  219. if (res.code == 200) {
  220. console.log("查询店铺>>>>", res)
  221. this.storeInfo = res.data
  222. } else {
  223. uni.showToast({
  224. title: res.msg,
  225. icon: 'none'
  226. });
  227. }
  228. },
  229. rej => {}
  230. );
  231. },
  232. rightClick() {
  233. // 获取页面栈
  234. const pages = getCurrentPages();
  235. // 如果页面栈长度大于1,说明有上一页可以返回
  236. if (pages.length > 1) {
  237. uni.navigateBack();
  238. } else {
  239. // 如果没有上一页,跳转到默认页面(比如首页)
  240. uni.redirectTo({
  241. url: '/pages/home/living' // 替换为你的首页路径
  242. });
  243. }
  244. },
  245. clickTab(item) {
  246. this.current = item.index
  247. },
  248. // 预览图片
  249. previewImage(index) {
  250. uni.previewImage({
  251. current: index,
  252. urls: this.licenseImagesList
  253. });
  254. },
  255. // getStoreInfo() {
  256. // getStoreById({
  257. // storeId: this.storeId
  258. // }).then(
  259. // res => {
  260. // if (res.code == 200) {
  261. // this.storeInfo = res.data || {}
  262. // // this.licenseImagesList = this.storeInfo.licenseImages ? this.storeInfo.licenseImages.split(',') : []
  263. // } else {
  264. // uni.showToast({
  265. // icon: 'none',
  266. // title: res.msg,
  267. // });
  268. // }
  269. // },
  270. // rej => {}
  271. // );
  272. // },
  273. toSearch() {
  274. if (this.from == 'company') {
  275. uni.navigateTo({
  276. url: '/pages_company/order/productList?storeId=' + this.storeId || ''
  277. })
  278. } else {
  279. uni.navigateTo({
  280. url: '/pages/home/productSearch?storeId=' + this.storeId || ''
  281. })
  282. }
  283. },
  284. handleAdvClick(item) {
  285. if (item.showType == 1) {
  286. uni.setStorageSync('url', item.advUrl);
  287. uni.navigateTo({
  288. url: "/pages/home/h5?storeId=" + this.storeId || ""
  289. })
  290. } else if (item.showType == 2) {
  291. uni.navigateTo({
  292. url: item.advUrl
  293. })
  294. } else if (item.showType == 3) {
  295. uni.setStorageSync('content', item.content);
  296. uni.navigateTo({
  297. url: "/pages/home/content?storeId=" + this.storeId || ""
  298. })
  299. }
  300. },
  301. // getAdv() {
  302. // let data = {
  303. // advType: 2
  304. // };
  305. // getAdv(data).then(
  306. // res => {
  307. // if (res.code == 200) {
  308. // this.advs = res.data;
  309. // }
  310. // },
  311. // rej => {}
  312. // );
  313. // },
  314. // getProductCate() {
  315. // let data = {};
  316. // getProductCate(data).then(
  317. // res => {
  318. // if (res.code == 200) {
  319. // this.allCates = res.data;
  320. // this.cates = this.allCates.filter(function(item) {
  321. // return item.pid == 0
  322. // });
  323. // if (this.cates != null && this.cates.length > 0) {
  324. // this.cateSelect = this.cates[0].cateId;
  325. // this.getSubCate()
  326. // }
  327. // } else {
  328. // uni.showToast({
  329. // icon: 'none',
  330. // title: "请求失败",
  331. // });
  332. // }
  333. // },
  334. // rej => {}
  335. // );
  336. // },
  337. // 药品分类选择
  338. choseCate(item) {
  339. this.cateSelect = item.cateId;
  340. this.getSubCate()
  341. },
  342. getSubCate() {
  343. var that = this;
  344. this.subCates = this.allCates.filter(function(item) {
  345. // let subList = that.allCates.filter(child => {
  346. // //返回每一项的子级数组
  347. // return child.pid === item.cateId
  348. // });
  349. // subList.length > 0 ? item.children = subList : [];
  350. return item.pid == that.cateSelect
  351. });
  352. },
  353. // 查看药品详情
  354. showProductList(item) {
  355. uni.navigateTo({
  356. url: '/pages_shop/goods?productId=' + item.productId + '&liveId=' + this.liveId + '&goodsId=' +
  357. item.goodsId+ '&storeId=' + this.storeId
  358. })
  359. }
  360. }
  361. }
  362. </script>
  363. <style scoped lang="scss">
  364. :deep(.u-tabs__wrapper__nav) {
  365. margin: 0 auto;
  366. }
  367. @mixin u-flex($flexD, $alignI, $justifyC) {
  368. display: flex;
  369. flex-direction: $flexD;
  370. align-items: $alignI;
  371. justify-content: $justifyC;
  372. }
  373. .inputbox {
  374. height: 60rpx;
  375. padding: 0 20rpx;
  376. @include u-flex(row, center, flex-start);
  377. border-radius: 40rpx;
  378. line-height: 60rpx;
  379. font-size: 28rpx;
  380. color: #ffffff;
  381. .icon-search {
  382. width: 28rpx;
  383. height: 28rpx;
  384. margin-right: 20rpx;
  385. }
  386. }
  387. .uni-nav-bar {
  388. position: fixed;
  389. top: 0;
  390. left: 0;
  391. width: 100%;
  392. z-index: 999;
  393. overflow: hidden;
  394. font-weight: 500;
  395. .uni-nav-barbox {
  396. width: 100%;
  397. height: 88rpx;
  398. @include u-flex(row, center, flex-start);
  399. position: relative;
  400. font-size: 24rpx;
  401. }
  402. .uni-nav-title {
  403. /* #ifdef APP-PLUS */
  404. font-size: 34rpx;
  405. /* #endif */
  406. /* #ifndef APP-PLUS */
  407. font-size: 14px;
  408. /* #endif */
  409. overflow: hidden;
  410. white-space: nowrap;
  411. width: 100%;
  412. text-overflow: ellipsis;
  413. }
  414. .uni-nav-back {
  415. margin-left: 20rpx;
  416. margin-right: 20rpx;
  417. height: 88rpx;
  418. @include u-flex(row, center, flex-start);
  419. }
  420. }
  421. .content {
  422. width: 100%;
  423. position: relative;
  424. // .bg {
  425. // width: 100%;
  426. // height: auto;
  427. // position: absolute;
  428. // top: 0;
  429. // left: 0;
  430. // height: 388rpx;
  431. // background: #3A1101;
  432. // }
  433. &-body {
  434. position: relative;
  435. padding-top: calc(var(--status-bar-height) + 88rpx);
  436. }
  437. }
  438. .store-head {
  439. margin-top: 40rpx;
  440. padding: 32rpx;
  441. background: linear-gradient(270deg, #FF5C03 0%, #FFAC64 100%);
  442. color: #ffffff;
  443. &-top {
  444. display: flex;
  445. align-items: center;
  446. }
  447. &-logo {
  448. flex-shrink: 0;
  449. margin-right: 24rpx;
  450. }
  451. &-name {
  452. font-weight: 600;
  453. font-size: 32rpx;
  454. }
  455. &-desc {
  456. margin-top: 16rpx;
  457. display: flex;
  458. align-items: center;
  459. flex-wrap: wrap;
  460. gap: 20rpx;
  461. position: relative;
  462. z-index: 2;
  463. view {
  464. padding-right: 20rpx;
  465. font-size: 26rpx;
  466. position: relative;
  467. &::after {
  468. content: "";
  469. width: 0;
  470. height: 28rpx;
  471. border-right: 1rpx solid #eee;
  472. position: absolute;
  473. right: 0;
  474. top: 50%;
  475. transform: translate(0, -50%);
  476. }
  477. &:last-child::after {
  478. border: none;
  479. }
  480. }
  481. }
  482. }
  483. .border_bottom_line {
  484. position: relative;
  485. &::after {
  486. content: "";
  487. position: absolute;
  488. bottom: 0;
  489. left: 0;
  490. border-bottom: 1px solid #F5F7FA;
  491. width: 100%;
  492. transform: scaleY(0.5);
  493. border-top-color: #F5F7FA;
  494. border-right-color: #F5F7FA;
  495. border-left-color: #F5F7FA;
  496. }
  497. }
  498. .storebox {
  499. width: 100%;
  500. background-color: #fff;
  501. position: relative;
  502. z-index: 1;
  503. &-info {
  504. padding: 24rpx 24rpx 0 24rpx;
  505. background-color: #fff;
  506. font-family: PingFang SC, PingFang SC;
  507. font-size: 28rpx;
  508. color: #333333;
  509. position: relative;
  510. border-top: 4px solid #F5F7FA;
  511. }
  512. &-map {
  513. display: flex;
  514. align-items: center;
  515. word-break: break-all;
  516. padding: 24rpx 0;
  517. }
  518. &-qualifications {
  519. display: flex;
  520. align-items: center;
  521. padding: 24rpx 0;
  522. }
  523. .qualifications {
  524. padding: 24rpx 0;
  525. }
  526. }
  527. .medic-box {
  528. display: flex;
  529. .medic {
  530. box-sizing: border-box;
  531. height: 100%;
  532. // .banner-box {
  533. // margin-top: 30rpx;
  534. // width: 100%;
  535. // height: 160upx;
  536. // border-radius: 10upx;
  537. // overflow: hidden;
  538. // .swiper,
  539. // .swiper-item,
  540. // .swiper-item image {
  541. // width: 100%;
  542. // height: 100%;
  543. // }
  544. // }
  545. .medic-list {
  546. padding: 20upx 30upx;
  547. box-sizing: border-box;
  548. overflow-y: auto;
  549. background: #F5F7FA;
  550. height: calc(100% - 220upx);
  551. position: relative;
  552. .inner-list {
  553. display: flex;
  554. flex-wrap: wrap;
  555. .definite {
  556. width: calc(50% - 10upx);
  557. margin-right: 20upx;
  558. margin-bottom: 30upx;
  559. background: #ffffff;
  560. border-radius: 16rpx;
  561. .img-box {
  562. width: 100%;
  563. height: 343upx;
  564. border-radius: 16rpx 16rpx 0rpx 0rpx;
  565. overflow: hidden;
  566. display: flex;
  567. align-items: center;
  568. image {
  569. width: 100%;
  570. }
  571. }
  572. .name {
  573. width: 100%;
  574. margin-top: 12upx;
  575. font-size: 28rpx;
  576. color: #222222;
  577. padding: 0 20rpx;
  578. box-sizing: border-box;
  579. }
  580. .price {
  581. padding: 0 20rpx 32rpx;
  582. box-sizing: border-box;
  583. margin-top: 12rpx;
  584. .red {
  585. font-weight: bold;
  586. font-size: 26rpx;
  587. color: #FF5C03;
  588. }
  589. .del {
  590. margin-left: 16rpx;
  591. text-decoration: line-through;
  592. font-size: 24rpx;
  593. color: #999999;
  594. }
  595. }
  596. &:nth-child(2n) {
  597. margin-right: 0;
  598. }
  599. }
  600. }
  601. }
  602. }
  603. }
  604. </style>