index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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="../../static/images/search.png" mode=""></image>
  13. <view>搜索店内商品</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <image class="bg" src="../../static/images/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>销售{{utils.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/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/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.setStorageSync('content',item.content);
  235. uni.navigateTo({
  236. url:"/pages/home/content?storeId="+ this.storeId || ""
  237. })
  238. }
  239. },
  240. getAdv(){
  241. let data = {advType:2};
  242. getAdv(data).then(
  243. res => {
  244. if(res.code==200){
  245. this.advs=res.data;
  246. }
  247. },
  248. rej => {}
  249. );
  250. },
  251. getProductCate(){
  252. let data = {};
  253. getProductCate(data).then(
  254. res => {
  255. if(res.code==200){
  256. this.allCates=res.data;
  257. this.cates = this.allCates.filter(function (item) {
  258. return item.pid==0
  259. });
  260. if(this.cates!=null&&this.cates.length>0){
  261. this.cateSelect=this.cates[0].cateId;
  262. this.getSubCate()
  263. }
  264. }else{
  265. uni.showToast({
  266. icon:'none',
  267. title: "请求失败",
  268. });
  269. }
  270. },
  271. rej => {}
  272. );
  273. },
  274. // 商品分类选择
  275. choseCate(item) {
  276. this.cateSelect = item.cateId;
  277. this.getSubCate()
  278. },
  279. getSubCate(){
  280. var that=this;
  281. this.subCates = this.allCates.filter(function (item) {
  282. // let subList = that.allCates.filter(child => {
  283. // //返回每一项的子级数组
  284. // return child.pid === item.cateId
  285. // });
  286. // subList.length > 0 ? item.children = subList : [];
  287. return item.pid==that.cateSelect
  288. });
  289. },
  290. // 查看商品详情
  291. showProductList(item) {
  292. uni.navigateTo({
  293. url: '/pages/shopping/productList?cateId='+item.cateId+"&pid="+item.pid+'&storeId=' + this.storeId + '&from=' + this.from
  294. })
  295. }
  296. }
  297. }
  298. </script>
  299. <style scoped lang="scss">
  300. @mixin u-flex($flexD, $alignI, $justifyC) {
  301. display: flex;
  302. flex-direction: $flexD;
  303. align-items: $alignI;
  304. justify-content: $justifyC;
  305. }
  306. .inputbox {
  307. height: 60rpx;
  308. padding: 0 20rpx;
  309. @include u-flex(row, center, flex-start);
  310. border-radius: 40rpx;
  311. line-height: 60rpx;
  312. font-size:28rpx;
  313. color:#999;
  314. font-family: PingFang SC;
  315. .icon-search{
  316. width: 28rpx;
  317. height: 28rpx;
  318. margin-right: 20rpx;
  319. }
  320. }
  321. .uni-nav-bar {
  322. position: fixed;
  323. top: 0;
  324. left: 0;
  325. width: 100%;
  326. z-index: 999;
  327. overflow: hidden;
  328. font-family: PingFang SC, PingFang SC;
  329. font-weight: 500;
  330. .uni-nav-barbox {
  331. width: 100%;
  332. height: 88rpx;
  333. @include u-flex(row, center, flex-start);
  334. position: relative;
  335. font-size: 24rpx;
  336. }
  337. .uni-nav-title {
  338. /* #ifdef APP-PLUS */
  339. font-size: 34rpx;
  340. /* #endif */
  341. /* #ifndef APP-PLUS */
  342. font-size: 14px;
  343. /* #endif */
  344. overflow: hidden;
  345. overflow: hidden;
  346. white-space: nowrap;
  347. text-overflow: ellipsis;
  348. }
  349. .uni-nav-back {
  350. margin-left: 20rpx;
  351. margin-right: 20rpx;
  352. height: 88rpx;
  353. @include u-flex(row, center, flex-start);
  354. }
  355. }
  356. .content {
  357. width: 100%;
  358. position: relative;
  359. .bg {
  360. width: 100%;
  361. height: auto;
  362. position: absolute;
  363. top: 0;
  364. left: 0;
  365. }
  366. &-body {
  367. position: relative;
  368. padding-top: calc(var(--status-bar-height) + 88rpx);
  369. }
  370. }
  371. .store-head {
  372. position: relative;
  373. z-index: 9;
  374. margin: 0 24rpx 0 24rpx;
  375. padding: 24rpx;
  376. background: #FFFFFF;
  377. border-radius: 16rpx 16rpx 16rpx 16rpx;
  378. font-family: PingFang SC, PingFang SC;
  379. color: #222222;
  380. box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
  381. &-top {
  382. display: flex;
  383. align-items: center;
  384. }
  385. &-logo {
  386. flex-shrink: 0;
  387. margin-right: 24rpx;
  388. }
  389. &-name {
  390. font-weight: 600;
  391. font-size: 32rpx;
  392. }
  393. &-desc {
  394. margin-top: 16rpx;
  395. display: flex;
  396. align-items: center;
  397. flex-wrap: wrap;
  398. gap: 20rpx;
  399. position: relative;
  400. z-index: 2;
  401. view {
  402. padding-right: 20rpx;
  403. font-size: 26rpx;
  404. position: relative;
  405. &::after {
  406. content: "";
  407. width: 0;
  408. height: 28rpx;
  409. border-right: 1rpx solid #eee;
  410. position: absolute;
  411. right: 0;
  412. top: 50%;
  413. transform: translate(0, -50%);
  414. }
  415. &:last-child::after {
  416. border: none;
  417. }
  418. }
  419. }
  420. }
  421. .border_bottom_line {
  422. position: relative;
  423. &::after {
  424. content: "";
  425. position: absolute;
  426. bottom: 0;
  427. left: 0;
  428. border-bottom: 1px solid #F5F7FA;
  429. width: 100%;
  430. transform: scaleY(0.5);
  431. border-top-color: #F5F7FA;
  432. border-right-color: #F5F7FA;
  433. border-left-color: #F5F7FA;
  434. }
  435. }
  436. .storebox {
  437. width: 100%;
  438. margin-top: -60rpx;
  439. padding-top: 80rpx;
  440. background-color: #fff;
  441. box-shadow: 0 -20rpx 16rpx #fff;
  442. position: relative;
  443. z-index: 1;
  444. &-info {
  445. padding: 24rpx 24rpx 0 24rpx;
  446. background-color: #fff;
  447. font-family: PingFang SC, PingFang SC;
  448. font-size: 28rpx;
  449. color: #333333;
  450. position: relative;
  451. border-top: 4px solid #F5F7FA;
  452. }
  453. &-map {
  454. display: flex;
  455. align-items: center;
  456. word-break: break-all;
  457. padding: 24rpx 0;
  458. }
  459. &-qualifications {
  460. display: flex;
  461. align-items: center;
  462. padding: 24rpx 0;
  463. }
  464. .qualifications {
  465. padding: 24rpx 0;
  466. }
  467. }
  468. .medic-box{
  469. display: flex;
  470. .cate-list{
  471. box-sizing: border-box;
  472. width: 200upx;
  473. background: #F2F5F9;
  474. display: flex;
  475. flex-direction: column;
  476. padding: 20upx 0;
  477. overflow-y: scroll;
  478. .item{
  479. height: 100upx;
  480. line-height: 100upx;
  481. padding-left: 30upx;
  482. font-size: 28upx;
  483. font-family: PingFang SC;
  484. font-weight: 500;
  485. color: #333333;
  486. position: relative;
  487. &.active{
  488. color: #018C39;
  489. &::after{
  490. content: "";
  491. width: 8upx;
  492. height: 50upx;
  493. background: #018C39;
  494. position: absolute;
  495. top: 25upx;
  496. left: 0;
  497. }
  498. }
  499. }
  500. }
  501. .medic{
  502. box-sizing: border-box;
  503. width: calc(100% - 200upx);
  504. height: 100%;
  505. padding: 0 30upx;
  506. .banner-box{
  507. margin-top: 30rpx;
  508. width: 100%;
  509. height: 160upx;
  510. border-radius: 10upx;
  511. overflow: hidden;
  512. .swiper,
  513. .swiper-item,
  514. .swiper-item image{
  515. width: 100%;
  516. height: 100%;
  517. }
  518. }
  519. .medic-list{
  520. box-sizing: border-box;
  521. padding: 30upx 0;
  522. overflow-y: auto;
  523. height: calc(100% - 220upx);
  524. position: relative;
  525. // .item{
  526. // .title{
  527. // font-size: 28upx;
  528. // font-family: PingFang SC;
  529. // font-weight: bold;
  530. // color: #333333;
  531. // padding-top: 20upx;
  532. // margin-bottom: 30upx;
  533. // }
  534. // }
  535. .inner-list{
  536. display: flex;
  537. flex-wrap: wrap;
  538. .definite{
  539. width: calc(33% - 20upx);
  540. margin-right: 30upx;
  541. margin-bottom: 30upx;
  542. .img-box{
  543. width: 100%;
  544. height: 144upx;
  545. background: #F5F5F5;
  546. border-radius: 8upx;
  547. overflow: hidden;
  548. display: flex;
  549. align-items: center;
  550. image{
  551. max-width: 100%;
  552. }
  553. }
  554. .name{
  555. width: 100%;
  556. margin-top: 20upx;
  557. font-size: 24upx;
  558. font-family: PingFang SC;
  559. font-weight: 500;
  560. color: #666666;
  561. text-align: center;
  562. }
  563. &:nth-child(3n) {
  564. margin-right: 0;
  565. }
  566. }
  567. }
  568. }
  569. }
  570. }
  571. </style>