index.vue 14 KB

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