storeIndex.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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,background:' #f5f5f5',overflow:'auto'}">
  38. <view v-show="current==0" style="width: 100%;">
  39. <tuiStoreProduct ref="tuiStoreProduct" :scrollHeight="mescrollHeight" :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. <mescroll-body :height="mescrollHeight+'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  52. <view style="display: flex;flex-wrap: wrap;">
  53. <medicineVerticalItem v-for="(item, index) in dataList" :key="index" :item="item" :storeId="storeId"></medicineVerticalItem>
  54. </view>
  55. </mescroll-body>
  56. <!-- 轮播图 -->
  57. <!-- <view class="banner-box">
  58. <swiper
  59. class="swiper"
  60. :indicator-dots="true"
  61. :circular="true"
  62. :autoplay="true"
  63. :interval="3000"
  64. :duration="1000"
  65. indicator-color="rgba(255, 255, 255, 0.6)"
  66. indicator-active-color="#ffffff"
  67. >
  68. <swiper-item class="swiper-item" v-for="(item,index) in advs" :key="index" @click="handleAdvClick(item)">
  69. <image :src="item.imageUrl" mode=""></image>
  70. </swiper-item>
  71. </swiper>
  72. </view> -->
  73. <!-- 药品列表 -->
  74. <!-- <view class="medic-list">
  75. <view class="item" v-for="(item,index) in subCates" :key="index">
  76. <view class="title">{{item.cateName}}</view>
  77. <view class="inner-list">
  78. <view class="definite"v-for="(subItem,index) in subCates" @click="showProductList(subItem)">
  79. <view class="img-box">
  80. <image :src="subItem.pic" mode="aspectFit"></image>
  81. </view>
  82. <view class="name ellipsis">{{subItem.cateName}}</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view> -->
  87. </view>
  88. </view>
  89. <template v-if="current==2">
  90. <detail ref="getStoreInfo" :storeInfo="storeInfo"></detail>
  91. </template>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  97. import tuiStoreProduct from './components/tuiStoreProduct.vue'
  98. import qualifications from './components/qualifications.vue'
  99. import {getProductCate,storeDetail,getProducts} from '@/api/index.js'
  100. import medicineVerticalItem from "@/components/medicineVerticalItem";
  101. import detail from './components/storeDetail.vue'
  102. // import {getAdv} from '@/api/adv'
  103. export default {
  104. mixins: [MescrollMixin], // 使用mixin
  105. components: {
  106. tuiStoreProduct,
  107. qualifications,
  108. medicineVerticalItem,
  109. detail
  110. },
  111. data() {
  112. return {
  113. divHeight:'0px',
  114. allCates:[],
  115. cates:[],
  116. subCates:[],
  117. // 状态栏的高度
  118. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  119. // 选中药品分类
  120. cateSelect: 0,
  121. // 轮播图
  122. advs: [],
  123. tabs:[
  124. {
  125. id:1,
  126. name:'推荐'
  127. },
  128. {
  129. id:2,
  130. name:'分类'
  131. },
  132. {
  133. id:3,
  134. name:'详情'
  135. }
  136. ],
  137. current:0,
  138. storeInfo: {},
  139. storeId:'',
  140. mescroll:null,
  141. downOption: { //下拉刷新
  142. use:true,
  143. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  144. },
  145. // 上拉加载的配置
  146. upOption: {
  147. onScroll:true,
  148. use: true, // 是否启用上拉加载; 默认true
  149. page: {
  150. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  151. size: 10 // 每页数据的数量,默认10
  152. },
  153. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  154. empty: {
  155. icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
  156. tip: '暂无数据'
  157. },
  158. textNoMore:"已经到底了",
  159. },
  160. // 列表数据
  161. dataList: [],
  162. form:{
  163. defaultOrder:'desc',
  164. newOrder:null,
  165. priceOrder:null,
  166. salesOrder:null,
  167. productName:"",
  168. storeId: "",
  169. cateId:'',
  170. pid:'',
  171. storeId: ''
  172. },
  173. mescrollHeight: 200
  174. };
  175. },
  176. onLoad(option) {
  177. this.storeId = option.storeId
  178. this.form.storeId = option.storeId || ''
  179. uni.showShareMenu({
  180. withShareTicket:true,
  181. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  182. menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友
  183. })
  184. this.getProductCate();
  185. this.getStoreInfo()
  186. },
  187. onShow() {
  188. var that=this;
  189. setTimeout(function(){
  190. let info = uni.createSelectorQuery().select(".top-content");
  191.     info.boundingClientRect(function(data) { //data - 各种参数
  192.       console.log(data.height) // 获取元素宽度
  193. // console.log(uni.upx2px(10))
  194. that.divHeight="calc(100% - "+data.height+"px)"
  195. that.mescrollHeight = uni.getSystemInfoSync().screenHeight - data.height
  196.    }).exec()
  197. },500);
  198. // this.getAdv();
  199. },
  200. methods:{
  201. // divHeight(){
  202. // return 'height:calc(100% - ${this.top}px);'
  203. // },
  204. getStoreInfo() {
  205. console.log(this.storeId)
  206. storeDetail(this.storeId).then(res=>{
  207. if(res.code==200) {
  208. this.storeInfo =res.data || {}
  209. }
  210. })
  211. },
  212. navback() {
  213. uni.navigateBack()
  214. },
  215. tabChange(item) {
  216. this.current=item.index
  217. },
  218. toSearch() {
  219. uni.navigateTo({
  220. url: '/pages_shopping/home/productSearch?storeId='+this.storeId
  221. })
  222. },
  223. handleAdvClick(item){
  224. console.log(item);
  225. if(item.showType==1){
  226. uni.setStorageSync('url',item.advUrl);
  227. uni.navigateTo({
  228. url:"/pages_shopping/home/h5"
  229. })
  230. }
  231. else if(item.showType==2){
  232. uni.navigateTo({
  233. url:item.advUrl
  234. })
  235. }
  236. else if(item.showType==3){
  237. uni.setStorageSync('content',item.content);
  238. uni.navigateTo({
  239. url:"/pages_shopping/home/content"
  240. })
  241. }
  242. },
  243. getAdv(){
  244. let data = {advType:2};
  245. getAdv(data).then(
  246. res => {
  247. if(res.code==200){
  248. this.advs=res.data;
  249. }
  250. },
  251. rej => {}
  252. );
  253. },
  254. getProductCate(){
  255. let data = {
  256. // storeId: this.storeId
  257. };
  258. getProductCate(data).then(
  259. res => {
  260. if(res.code==200){
  261. this.allCates=res.data;
  262. this.cates = this.allCates.filter(function (item) {
  263. return item.pid==0
  264. });
  265. if(this.cates!=null&&this.cates.length>0){
  266. this.cateSelect=this.cates[0].cateId;
  267. this.form.cateId = this.cates[0].cateId;
  268. // this.form.pid = this.cates[0].pid;
  269. this.mescroll&&this.mescroll.resetUpScroll()
  270. }
  271. }else{
  272. uni.showToast({
  273. icon:'none',
  274. title: "请求失败",
  275. });
  276. }
  277. },
  278. rej => {}
  279. );
  280. },
  281. // 药品分类选择
  282. choseCate(item) {
  283. this.cateSelect = item.cateId;
  284. // this.getSubCate()
  285. this.form.cateId = item.cateId;
  286. this.mescroll.resetUpScroll()
  287. },
  288. getSubCate(){
  289. var that=this;
  290. this.subCates = this.allCates.filter(function (item) {
  291. // let subList = that.allCates.filter(child => {
  292. // //返回每一项的子级数组
  293. // return child.pid === item.cateId
  294. // });
  295. // subList.length > 0 ? item.children = subList : [];
  296. return item.pid==that.cateSelect
  297. });
  298. console.log(this.subCates);
  299. },
  300. // 查看药品详情
  301. showProductList(item) {
  302. uni.navigateTo({
  303. url: '/pages_shopping/productList?cateId='+item.cateId+"&pid="+item.pid+'&storeId='+this.storeId
  304. })
  305. },
  306. goSearch(e) {
  307. if(e.detail.value!=null&&e.detail.value!=""){
  308. this.$addHisSearch(e.detail.value);
  309. }
  310. uni.navigateTo({
  311. url: '/pages_shopping/home/productList?storeId='+this.storeId+'&searchValue=' + e.detail.value
  312. })
  313. },
  314. goStoreDetail() {
  315. uni.navigateTo({
  316. url: '/pages_store/storeDetail?storeId='+this.storeId
  317. })
  318. },
  319. mescrollInit(mescroll) {
  320. this.mescroll = mescroll;
  321. },
  322. /*下拉刷新的回调 */
  323. downCallback(mescroll) {
  324. mescroll.resetUpScroll()
  325. },
  326. upCallback(page) {
  327. //联网加载数据
  328. var that = this;
  329. this.form.page=page.num;
  330. this.form.pageSize=page.size;
  331. getProducts(this.form).then(res => {
  332. if(res.code==200){
  333. //设置列表数据
  334. if (page.num == 1) {
  335. that.dataList = res.data.list;
  336. } else {
  337. that.dataList = that.dataList.concat(res.data.list);
  338. }
  339. that.mescroll.endBySize(res.data.list.length, res.data.total);
  340. }else{
  341. uni.showToast({
  342. icon:'none',
  343. title: "请求失败",
  344. });
  345. that.dataList = null;
  346. that.mescroll.endErr();
  347. }
  348. });
  349. },
  350. }
  351. }
  352. </script>
  353. <style lang="scss">
  354. page{
  355. height: 100%;
  356. background-color: #fff;
  357. }
  358. .storebox {
  359. padding: 26rpx 32rpx;
  360. font-family: PingFang SC, PingFang SC;
  361. color: #FFFFFF;
  362. .logo {
  363. width: 104rpx;
  364. height: 104rpx;
  365. background: #FFFFFF;
  366. border-radius: 16rpx 16rpx 16rpx 16rpx;
  367. margin-right: 26rpx;
  368. }
  369. .storename {
  370. font-weight: 500;
  371. font-size: 32rpx;
  372. }
  373. .storedesc {
  374. margin-top: 12rpx;
  375. font-weight: 400;
  376. font-size: 22rpx;
  377. }
  378. .storebox-r {
  379. flex: 1;
  380. overflow: hidden;
  381. }
  382. .storebox-btn {
  383. flex-shrink: 0;
  384. padding: 10rpx 16rpx;
  385. background: rgba(46, 218, 212, 0.50);
  386. font-size: 28rpx;
  387. border-radius: 8rpx 8rpx 8rpx 8rpx;
  388. }
  389. }
  390. .content{
  391. height: 100%;
  392. display: flex;
  393. flex-direction: column;
  394. .top-content{
  395. width: 100%;
  396. z-index: 10;
  397. background-repeat: no-repeat;
  398. background-image: url('https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/image/index_img/home_top_bg.png');
  399. background-size: 100% 100%;
  400. .top-title{
  401. height: 88upx;
  402. line-height: 88upx;
  403. font-size: 42upx;
  404. font-family: Source Han Sans CN;
  405. font-weight: bold;
  406. color: #222222;
  407. padding-left: 41upx;
  408. background-color: transparent;
  409. display: flex;
  410. align-items: center;
  411. }
  412. .search-cont{
  413. padding: 6upx 30upx;
  414. .inner{
  415. box-sizing: border-box;
  416. width: 70%;
  417. height: 72upx;
  418. background: #FFFFFF;
  419. border-radius: 36upx;
  420. display: flex;
  421. align-items: center;
  422. padding: 0 30upx;
  423. .icon-search{
  424. width: 28upx;
  425. height: 28upx;
  426. margin-right: 20upx;
  427. }
  428. input{
  429. height: 60upx;
  430. line-height: 60upx;
  431. flex: 1;
  432. }
  433. }
  434. }
  435. }
  436. .medic-box{
  437. display: flex;
  438. background: #fff;
  439. .cate-list{
  440. box-sizing: border-box;
  441. width: 200upx;
  442. background: #F2F5F9;
  443. display: flex;
  444. flex-direction: column;
  445. padding: 20upx 0;
  446. overflow-y: scroll;
  447. .item{
  448. height: 100upx;
  449. line-height: 100upx;
  450. padding-left: 30upx;
  451. font-size: 28upx;
  452. font-family: PingFang SC;
  453. font-weight: 500;
  454. color: #333333;
  455. position: relative;
  456. &.active{
  457. color: #2583EB;
  458. &::after{
  459. content: "";
  460. width: 8upx;
  461. height: 50upx;
  462. background: #2583EB;
  463. position: absolute;
  464. top: 25upx;
  465. left: 0;
  466. }
  467. }
  468. }
  469. }
  470. .medic{
  471. box-sizing: border-box;
  472. width: calc(100% - 200upx);
  473. height: 100%;
  474. margin: 0 24upx;
  475. .banner-box{
  476. margin-top: 30rpx;
  477. width: 100%;
  478. height: 160upx;
  479. border-radius: 10upx;
  480. overflow: hidden;
  481. .swiper,
  482. .swiper-item,
  483. .swiper-item image{
  484. width: 100%;
  485. height: 100%;
  486. }
  487. }
  488. .medic-list{
  489. box-sizing: border-box;
  490. padding: 30upx 0;
  491. overflow-y: auto;
  492. height: calc(100% - 220upx);
  493. position: relative;
  494. // .item{
  495. // .title{
  496. // font-size: 28upx;
  497. // font-family: PingFang SC;
  498. // font-weight: bold;
  499. // color: #333333;
  500. // padding-top: 20upx;
  501. // margin-bottom: 30upx;
  502. // }
  503. // }
  504. .inner-list{
  505. display: flex;
  506. flex-wrap: wrap;
  507. .definite{
  508. width: calc(33% - 20upx);
  509. margin-right: 30upx;
  510. margin-bottom: 30upx;
  511. .img-box{
  512. width: 100%;
  513. height: 144upx;
  514. background: #F5F5F5;
  515. border-radius: 8upx;
  516. overflow: hidden;
  517. display: flex;
  518. align-items: center;
  519. image{
  520. max-width: 100%;
  521. }
  522. }
  523. .name{
  524. width: 100%;
  525. margin-top: 20upx;
  526. font-size: 24upx;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. color: #666666;
  530. text-align: center;
  531. }
  532. &:nth-child(3n) {
  533. margin-right: 0;
  534. }
  535. }
  536. }
  537. }
  538. }
  539. }
  540. }
  541. </style>