storeIndex.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="content">
  3. <view class="top-content">
  4. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  5. <!-- 这里是状态栏 -->
  6. <view class="top-title">
  7. <u-icon name="arrow-left" color="#fff" size="24" @click="navback()"></u-icon>
  8. <view class="search-cont">
  9. <view class="inner">
  10. <image class="icon-search" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/icon_search.png" mode=""></image>
  11. <input type="text" disabled confirm-type="搜索" @click="toSearch" placeholder="输入药品名称" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  12. </view>
  13. </view>
  14. </view>
  15. <view class="storebox x-bc">
  16. <view class="x-f">
  17. <image class="logo" :src="storeInfo.logoUrl" mode="aspectFill"></image>
  18. <view class="storebox-r" @click="goStoreDetail">
  19. <view class="storename ellipsis2">{{storeInfo.storeName}}</view>
  20. <view class="storedesc">24小时营业 月售{{storeInfo.salesCount|| 0}}</view>
  21. </view>
  22. </view>
  23. <view class="storebox-btn" @click="goStoreDetail">详情</view>
  24. </view>
  25. <view class="top-fixed x-ac" style="background-color: #fff;">
  26. <view style="width: 50%;">
  27. <u-tabs
  28. :scrollable="false"
  29. :list="tabs"
  30. lineColor="#2583EB"
  31. :current="current"
  32. @change="tabChange">
  33. </u-tabs>
  34. </view>
  35. </view>
  36. </view>
  37. <view :style="{height: divHeight}">
  38. <view v-show="current==0" style="width: 100%;">
  39. <tuiStoreProduct ref="tuiStoreProduct" :scrollHeight="divHeight" :storeId="storeId"></tuiStoreProduct>
  40. </view>
  41. <view v-if="current==1" style="height: 100%" class="medic-box">
  42. <view class="cate-list">
  43. <view
  44. v-for="(item,index) in cates"
  45. :key="index"
  46. :class="cateSelect == item.cateId?'item active':'item'"
  47. @click="choseCate(item)"
  48. >{{item.cateName }}</view>
  49. </view>
  50. <view class="medic">
  51. <!-- 轮播图 -->
  52. <view class="banner-box">
  53. <swiper
  54. class="swiper"
  55. :indicator-dots="true"
  56. :circular="true"
  57. :autoplay="true"
  58. :interval="3000"
  59. :duration="1000"
  60. indicator-color="rgba(255, 255, 255, 0.6)"
  61. indicator-active-color="#ffffff"
  62. >
  63. <swiper-item class="swiper-item" v-for="(item,index) in advs" :key="index" @click="handleAdvClick(item)">
  64. <image :src="item.imageUrl" mode=""></image>
  65. </swiper-item>
  66. </swiper>
  67. </view>
  68. <!-- 药品列表 -->
  69. <view class="medic-list">
  70. <!-- <view class="item" v-for="(item,index) in subCates" :key="index">
  71. <view class="title">{{item.cateName}}</view> -->
  72. <view class="inner-list">
  73. <view class="definite"v-for="(subItem,index) in subCates" @click="showProductList(subItem)">
  74. <view class="img-box">
  75. <image :src="subItem.pic" mode="aspectFit"></image>
  76. </view>
  77. <view class="name ellipsis">{{subItem.cateName}}</view>
  78. </view>
  79. </view>
  80. <!-- </view> -->
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import tuiStoreProduct from './components/tuiStoreProduct.vue'
  89. import qualifications from './components/qualifications.vue'
  90. import {getProductCate,storeDetail} from '@/api/index.js'
  91. // import {getAdv} from '@/api/adv'
  92. export default {
  93. components: {
  94. tuiStoreProduct,
  95. qualifications
  96. },
  97. data() {
  98. return {
  99. divHeight:'0px',
  100. allCates:[],
  101. cates:[],
  102. subCates:[],
  103. // 状态栏的高度
  104. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  105. // 选中药品分类
  106. cateSelect: 0,
  107. // 轮播图
  108. advs: [],
  109. tabs:[
  110. {
  111. id:1,
  112. name:'推荐'
  113. },
  114. {
  115. id:2,
  116. name:'分类'
  117. }
  118. ],
  119. current:0,
  120. storeInfo: {},
  121. storeId:''
  122. };
  123. },
  124. onLoad(option) {
  125. this.storeId = option.storeId
  126. uni.showShareMenu({
  127. withShareTicket:true,
  128. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  129. menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友
  130. })
  131. this.getProductCate();
  132. this.getStoreInfo()
  133. },
  134. onShow() {
  135. var that=this;
  136. setTimeout(function(){
  137. let info = uni.createSelectorQuery().select(".top-content");
  138.     info.boundingClientRect(function(data) { //data - 各种参数
  139.       console.log(data.height) // 获取元素宽度
  140. // console.log(uni.upx2px(10))
  141. that.divHeight="calc(100% - "+data.height+"px)"
  142.    }).exec()
  143. },500);
  144. // this.getAdv();
  145. },
  146. methods:{
  147. // divHeight(){
  148. // return 'height:calc(100% - ${this.top}px);'
  149. // },
  150. getStoreInfo() {
  151. console.log(this.storeId)
  152. storeDetail(this.storeId).then(res=>{
  153. if(res.code==200) {
  154. this.storeInfo =res.data || {}
  155. }
  156. })
  157. },
  158. navback() {
  159. uni.navigateBack()
  160. },
  161. tabChange(item) {
  162. this.current=item.index
  163. },
  164. toSearch() {
  165. uni.navigateTo({
  166. url: '/pages_shopping/home/productSearch'
  167. })
  168. },
  169. handleAdvClick(item){
  170. console.log(item);
  171. if(item.showType==1){
  172. uni.setStorageSync('url',item.advUrl);
  173. uni.navigateTo({
  174. url:"/pages_shopping/home/h5"
  175. })
  176. }
  177. else if(item.showType==2){
  178. uni.navigateTo({
  179. url:item.advUrl
  180. })
  181. }
  182. else if(item.showType==3){
  183. uni.setStorageSync('content',item.content);
  184. uni.navigateTo({
  185. url:"/pages_shopping/home/content"
  186. })
  187. }
  188. },
  189. getAdv(){
  190. let data = {advType:2};
  191. getAdv(data).then(
  192. res => {
  193. if(res.code==200){
  194. this.advs=res.data;
  195. }
  196. },
  197. rej => {}
  198. );
  199. },
  200. getProductCate(){
  201. let data = {
  202. storeId: this.storeId
  203. };
  204. getProductCate(data).then(
  205. res => {
  206. if(res.code==200){
  207. this.allCates=res.data;
  208. this.cates = this.allCates.filter(function (item) {
  209. return item.pid==0
  210. });
  211. if(this.cates!=null&&this.cates.length>0){
  212. this.cateSelect=this.cates[0].cateId;
  213. this.getSubCate()
  214. }
  215. }else{
  216. uni.showToast({
  217. icon:'none',
  218. title: "请求失败",
  219. });
  220. }
  221. },
  222. rej => {}
  223. );
  224. },
  225. // 药品分类选择
  226. choseCate(item) {
  227. this.cateSelect = item.cateId;
  228. this.getSubCate()
  229. },
  230. getSubCate(){
  231. var that=this;
  232. this.subCates = this.allCates.filter(function (item) {
  233. // let subList = that.allCates.filter(child => {
  234. // //返回每一项的子级数组
  235. // return child.pid === item.cateId
  236. // });
  237. // subList.length > 0 ? item.children = subList : [];
  238. return item.pid==that.cateSelect
  239. });
  240. console.log(this.subCates);
  241. },
  242. // 查看药品详情
  243. showProductList(item) {
  244. uni.navigateTo({
  245. url: '/pages_shopping/productList?cateId='+item.cateId+"&pid="+item.pid
  246. })
  247. },
  248. goSearch(e) {
  249. if(e.detail.value!=null&&e.detail.value!=""){
  250. this.$addHisSearch(e.detail.value);
  251. }
  252. uni.navigateTo({
  253. url: '/pages_shopping/home/productList?searchValue=' + e.detail.value
  254. })
  255. },
  256. goStoreDetail() {
  257. uni.navigateTo({
  258. url: '/pages_store/storeDetail?storeId='+this.storeId
  259. })
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. page{
  266. height: 100%;
  267. background-color: #fff;
  268. }
  269. .storebox {
  270. padding: 26rpx 32rpx;
  271. font-family: PingFang SC, PingFang SC;
  272. color: #FFFFFF;
  273. .logo {
  274. width: 104rpx;
  275. height: 104rpx;
  276. background: #FFFFFF;
  277. border-radius: 16rpx 16rpx 16rpx 16rpx;
  278. margin-right: 26rpx;
  279. }
  280. .storename {
  281. font-weight: 500;
  282. font-size: 32rpx;
  283. }
  284. .storedesc {
  285. margin-top: 12rpx;
  286. font-weight: 400;
  287. font-size: 22rpx;
  288. }
  289. .storebox-r {
  290. flex: 1;
  291. overflow: hidden;
  292. }
  293. .storebox-btn {
  294. flex-shrink: 0;
  295. padding: 10rpx 16rpx;
  296. background: rgba(46, 218, 212, 0.50);
  297. font-size: 28rpx;
  298. border-radius: 8rpx 8rpx 8rpx 8rpx;
  299. }
  300. }
  301. .content{
  302. height: 100%;
  303. display: flex;
  304. flex-direction: column;
  305. .top-content{
  306. width: 100%;
  307. z-index: 10;
  308. background-repeat: no-repeat;
  309. background-image: url('https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/image/index_img/home_top_bg.png');
  310. background-size: 100% 100%;
  311. .top-title{
  312. height: 88upx;
  313. line-height: 88upx;
  314. font-size: 42upx;
  315. font-family: Source Han Sans CN;
  316. font-weight: bold;
  317. color: #222222;
  318. padding-left: 41upx;
  319. background-color: transparent;
  320. display: flex;
  321. align-items: center;
  322. }
  323. .search-cont{
  324. padding: 6upx 30upx;
  325. .inner{
  326. box-sizing: border-box;
  327. width: 70%;
  328. height: 72upx;
  329. background: #FFFFFF;
  330. border-radius: 36upx;
  331. display: flex;
  332. align-items: center;
  333. padding: 0 30upx;
  334. .icon-search{
  335. width: 28upx;
  336. height: 28upx;
  337. margin-right: 20upx;
  338. }
  339. input{
  340. height: 60upx;
  341. line-height: 60upx;
  342. flex: 1;
  343. }
  344. }
  345. }
  346. }
  347. .medic-box{
  348. display: flex;
  349. .cate-list{
  350. box-sizing: border-box;
  351. width: 200upx;
  352. background: #F2F5F9;
  353. display: flex;
  354. flex-direction: column;
  355. padding: 20upx 0;
  356. overflow-y: scroll;
  357. .item{
  358. height: 100upx;
  359. line-height: 100upx;
  360. padding-left: 30upx;
  361. font-size: 28upx;
  362. font-family: PingFang SC;
  363. font-weight: 500;
  364. color: #333333;
  365. position: relative;
  366. &.active{
  367. color: #2583EB;
  368. &::after{
  369. content: "";
  370. width: 8upx;
  371. height: 50upx;
  372. background: #2583EB;
  373. position: absolute;
  374. top: 25upx;
  375. left: 0;
  376. }
  377. }
  378. }
  379. }
  380. .medic{
  381. box-sizing: border-box;
  382. width: calc(100% - 200upx);
  383. height: 100%;
  384. padding: 0 30upx;
  385. .banner-box{
  386. margin-top: 30rpx;
  387. width: 100%;
  388. height: 160upx;
  389. border-radius: 10upx;
  390. overflow: hidden;
  391. .swiper,
  392. .swiper-item,
  393. .swiper-item image{
  394. width: 100%;
  395. height: 100%;
  396. }
  397. }
  398. .medic-list{
  399. box-sizing: border-box;
  400. padding: 30upx 0;
  401. overflow-y: auto;
  402. height: calc(100% - 220upx);
  403. position: relative;
  404. // .item{
  405. // .title{
  406. // font-size: 28upx;
  407. // font-family: PingFang SC;
  408. // font-weight: bold;
  409. // color: #333333;
  410. // padding-top: 20upx;
  411. // margin-bottom: 30upx;
  412. // }
  413. // }
  414. .inner-list{
  415. display: flex;
  416. flex-wrap: wrap;
  417. .definite{
  418. width: calc(33% - 20upx);
  419. margin-right: 30upx;
  420. margin-bottom: 30upx;
  421. .img-box{
  422. width: 100%;
  423. height: 144upx;
  424. background: #F5F5F5;
  425. border-radius: 8upx;
  426. overflow: hidden;
  427. display: flex;
  428. align-items: center;
  429. image{
  430. max-width: 100%;
  431. }
  432. }
  433. .name{
  434. width: 100%;
  435. margin-top: 20upx;
  436. font-size: 24upx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #666666;
  440. text-align: center;
  441. }
  442. &:nth-child(3n) {
  443. margin-right: 0;
  444. }
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. </style>