store.vue 15 KB

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