storeIndex.vue 14 KB

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