index.vue 14 KB

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