store.vue 14 KB

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