store.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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)" @click="toSearch">
  12. <image class="icon-search" src="/static/images/search_white.png"></image>
  13. <input placeholder="搜索本店" v-model="inputInfo" @input="handleSearchInput" />
  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. store, //查询店铺
  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. inputInfo: '',
  124. inputno: '',
  125. searchTimer: null,
  126. tabList: [{
  127. name: '推荐',
  128. }, {
  129. name: '分类',
  130. }],
  131. products: [],
  132. liveId: null,
  133. storeId: null,
  134. statusBarHeight: uni.getWindowInfo().statusBarHeight,
  135. // 右侧的胶囊距离右侧屏幕距离-px
  136. menuRight: uni.getStorageSync('menuInfo').menuRight,
  137. // 右侧的胶囊宽度-px
  138. menuWidth: uni.getStorageSync('menuInfo').menuWidth,
  139. opacity: 0,
  140. opacityTxt: 0,
  141. tabbar: [{
  142. name: '商品',
  143. }, {
  144. name: '商家',
  145. }],
  146. current: 0,
  147. storeInfo: {},
  148. // logoUrl: "/static/images/adfd21c004854c9b8997d371d7a0ce8c.jpg",
  149. // 商家资质图片
  150. // licenseImagesList: ["/static/images/sjzz.jpg"],
  151. divHeight: '0px',
  152. allCates: [],
  153. cates: [],
  154. subCates: [],
  155. // 选中药品分类
  156. cateSelect: 0,
  157. // 轮播图
  158. advs: [],
  159. // 'company'表示销售管理的进来的
  160. from: ""
  161. }
  162. },
  163. onLoad(options) {
  164. console.log("接收到的options:", options);
  165. if (options.liveId) {
  166. this.liveId = options.liveId;
  167. this.getliveStore() // 获取小黄车 店铺展示
  168. console.log("接收到的liveId:", this.liveId);
  169. }
  170. if (options.storeId) {
  171. this.storeId = options.storeId || ""
  172. } else {
  173. uni.showToast({
  174. title: "storeId不存在~",
  175. icon: "none"
  176. })
  177. }
  178. },
  179. mounted() {
  180. this.getSearchStore() //查询店铺
  181. },
  182. onShow() {
  183. this.divHeight = `calc(100vh - 44px - 88rpx - ${this.statusBarHeight}px)`
  184. },
  185. onPageScroll(e) {
  186. if (e.scrollTop <= 44) {
  187. this.opacityTxt = 0
  188. this.opacity = e.scrollTop > this.statusBarHeight ? 0.6 : 0
  189. } else if (e.scrollTop > 50) {
  190. this.opacity = 1
  191. this.opacityTxt = 1
  192. }
  193. },
  194. methods: {
  195. handleSearchInput() {
  196. // 使用防抖优化性能,避免频繁请求
  197. clearTimeout(this.searchTimer);
  198. this.searchTimer = setTimeout(() => {
  199. this.getliveStore();
  200. }, 500); // 500毫秒延迟
  201. },
  202. getPureDecimal(num, precision = 6) {
  203. const decimalPart = Math.abs(num).toFixed(precision).split('.')[1];
  204. return decimalPart?.replace(/0+$/, '') || ''; // 移除末尾多余的0
  205. },
  206. //店铺展示
  207. getliveStore() {
  208. let data = {
  209. pageSize: 10,
  210. page: 1
  211. }
  212. liveStore(this.liveId, this.inputInfo, data).then(res => {
  213. if (res.code == 200) {
  214. console.log("小黄车 店铺展示>>>>", res)
  215. this.products = res.data
  216. } else {
  217. uni.showToast({
  218. title: res.msg,
  219. icon: 'none'
  220. });
  221. }
  222. },
  223. rej => {}
  224. );
  225. },
  226. //查询店铺
  227. getSearchStore() {
  228. if (!this.storeId) return;
  229. store(this.storeId, this.inputno).then(res => {
  230. if (res.code == 200) {
  231. console.log("查询店铺>>>>", res)
  232. this.storeInfo = res.data
  233. } else {
  234. uni.showToast({
  235. title: res.msg,
  236. icon: 'none'
  237. });
  238. }
  239. },
  240. rej => {}
  241. );
  242. },
  243. rightClick() {
  244. // 获取页面栈
  245. const pages = getCurrentPages();
  246. // 如果页面栈长度大于1,说明有上一页可以返回
  247. if (pages.length > 1) {
  248. uni.navigateBack();
  249. } else {
  250. // 如果没有上一页,跳转到默认页面(比如首页)
  251. uni.redirectTo({
  252. url: '/pages/home/living' // 替换为你的首页路径
  253. });
  254. }
  255. },
  256. clickTab(item) {
  257. this.current = item.index
  258. },
  259. // 预览图片
  260. previewImage(index) {
  261. uni.previewImage({
  262. current: index,
  263. urls: this.licenseImagesList
  264. });
  265. },
  266. // getStoreInfo() {
  267. // getStoreById({
  268. // storeId: this.storeId
  269. // }).then(
  270. // res => {
  271. // if (res.code == 200) {
  272. // this.storeInfo = res.data || {}
  273. // // this.licenseImagesList = this.storeInfo.licenseImages ? this.storeInfo.licenseImages.split(',') : []
  274. // } else {
  275. // uni.showToast({
  276. // icon: 'none',
  277. // title: res.msg,
  278. // });
  279. // }
  280. // },
  281. // rej => {}
  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. position: relative;
  501. z-index: 1;
  502. &-info {
  503. padding: 24rpx 24rpx 0 24rpx;
  504. background-color: #fff;
  505. font-family: PingFang SC, PingFang SC;
  506. font-size: 28rpx;
  507. color: #333333;
  508. position: relative;
  509. border-top: 4px solid #F5F7FA;
  510. }
  511. &-map {
  512. display: flex;
  513. align-items: center;
  514. word-break: break-all;
  515. padding: 24rpx 0;
  516. }
  517. &-qualifications {
  518. display: flex;
  519. align-items: center;
  520. padding: 24rpx 0;
  521. }
  522. .qualifications {
  523. padding: 24rpx 0;
  524. }
  525. }
  526. .medic-box {
  527. display: flex;
  528. .medic {
  529. box-sizing: border-box;
  530. height: 100%;
  531. // .banner-box {
  532. // margin-top: 30rpx;
  533. // width: 100%;
  534. // height: 160upx;
  535. // border-radius: 10upx;
  536. // overflow: hidden;
  537. // .swiper,
  538. // .swiper-item,
  539. // .swiper-item image {
  540. // width: 100%;
  541. // height: 100%;
  542. // }
  543. // }
  544. .medic-list {
  545. width: 100%;
  546. padding: 20upx 24upx;
  547. box-sizing: border-box;
  548. overflow-y: auto;
  549. height: calc(100% - 220upx);
  550. position: relative;
  551. .inner-list {
  552. display: flex;
  553. flex-wrap: wrap;
  554. .definite {
  555. width: 342rpx;
  556. margin-right: 18upx;
  557. margin-bottom: 30upx;
  558. background: #ffffff;
  559. border-radius: 16rpx;
  560. .img-box {
  561. width: 100%;
  562. height: 343upx;
  563. border-radius: 16rpx 16rpx 0rpx 0rpx;
  564. overflow: hidden;
  565. display: flex;
  566. align-items: center;
  567. image {
  568. width: 100%;
  569. }
  570. }
  571. .name {
  572. width: 100%;
  573. margin-top: 12upx;
  574. font-size: 28rpx;
  575. color: #222222;
  576. padding: 0 20rpx;
  577. box-sizing: border-box;
  578. }
  579. .price {
  580. padding: 0 20rpx 32rpx;
  581. box-sizing: border-box;
  582. margin-top: 12rpx;
  583. .red {
  584. font-weight: bold;
  585. font-size: 26rpx;
  586. color: #FF5C03;
  587. }
  588. .del {
  589. margin-left: 16rpx;
  590. text-decoration: line-through;
  591. font-size: 24rpx;
  592. color: #999999;
  593. }
  594. }
  595. &:nth-child(2n) {
  596. margin-right: 0;
  597. }
  598. }
  599. }
  600. }
  601. }
  602. }
  603. </style>