brand.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="" v-if="isEmpty">
  3. <u-navbar
  4. :placeholder="true"
  5. title="品牌导览"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <u-empty mode="list" text="暂无数据" marginTop="200"></u-empty>
  11. </view>
  12. <view class="" v-else>
  13. <!-- <view class="" :style="{height: navHeight+'px' }"></view> -->
  14. <u-navbar
  15. :placeholder="true"
  16. title="品牌导览"
  17. :autoBack="true"
  18. :safeAreaInsetTop="true"
  19. >
  20. </u-navbar>
  21. <view class="search-wrap">
  22. <u-search
  23. placeholder="请搜索"
  24. :clearabled="true"
  25. :showAction="false"
  26. height="80rpx"
  27. @search="search"
  28. @custom="search"
  29. @clear="reloadList"
  30. bgColor="#fff"
  31. borderColor="#00A447"
  32. v-model="params.name">
  33. </u-search>
  34. </view>
  35. <view class="out-wrap u-flex u-col-top">
  36. <view class="floors">
  37. <view class="floor"
  38. :class="{active:index==floorIndex}"
  39. @click.stop="floorClick(index)"
  40. v-for="(item,index) in floorTree" :key="item.parentId">
  41. <view class="floorName u-flex u-row-center">
  42. {{item.floorName}}
  43. <u-icon :name="index==floorIndex?'arrow-down-fill':'play-right-fill'" :customStyle="{'margin-left': '20rpx'}" color="#666" size="10"></u-icon>
  44. </view>
  45. <view v-if="index==floorIndex" class="children" @click.stop="childrenClick(i)" :class="{active:children.id==childrenId&&!params.name}" v-for="(children,i) in item.children" :key="children.id">
  46. {{children.floorName}}
  47. </view>
  48. </view>
  49. </view>
  50. <view class="right">
  51. <view class="tabs-wrap">
  52. <u-tabs
  53. :list="tabsList"
  54. lineWidth="0"
  55. :current="tabsCurrent"
  56. :inactiveStyle="{background:'#F5F5F5','border-radius':'11px',padding:'10rpx 22rpx','font-size':'22rpx'}"
  57. :activeStyle="{background:'rgba(0,164,71,0.1)',color:'#00A447','border-radius':'11px',padding:'10rpx 22rpx','font-size':'22rpx'}"
  58. @click="tabsClick"></u-tabs>
  59. </view>
  60. <!-- <view class="second-types">
  61. <view class="u-flex u-row-between u-col-top u-border-bottom">
  62. <view class="u-flex u-flex-wrap">
  63. <view class="type"
  64. :class="{active:index==secondTypesIndex}"
  65. @click="secondTypesClick(index)"
  66. v-for="(item,index) in subTypeList" :key="item.id">
  67. {{item.name}}
  68. </view>
  69. </view>
  70. <u-icon
  71. @click="showMoreSecondTypes"
  72. v-if="subTypeListMore.length>0"
  73. size="24px"
  74. :name="showMoreSecondTypesIcon"></u-icon>
  75. </view>
  76. <view class="more-second-types u-flex" v-if="moreSecondTypes">
  77. <view class="type"
  78. :class="{active:index==moreSecondTypesIndex}"
  79. @click="moreSecondTypesClick(index)"
  80. v-for="(item,index) in subTypeListMore" :key="item.id">
  81. {{item.name}}
  82. </view>
  83. </view>
  84. </view> -->
  85. <mescroll-body class="mescroll-body" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  86. <view class="page-wrap" @click="$u.route('/brand/branddetails',{id:item.id})" v-for="item in dataList" :key="item.id">
  87. <view class="brand-list">
  88. <view class="brand u-flex">
  89. <u--image :showLoading="true" :src="item.logo" width="145rpx" height="145rpx"></u--image>
  90. <view class="text">
  91. <view class="name u-line-1">{{item.name}}</view>
  92. <view class="typeName"> <text class="type">{{item.typeName}}</text> </view>
  93. <view class="businessTime">营业时间:{{item.businessTime}}</view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </mescroll-body>
  99. </view>
  100. </view>
  101. <!-- <tabbar :tabbarIndexProps="Number(1)" /> -->
  102. <u-toast ref="uToast"></u-toast>
  103. </view>
  104. </template>
  105. <script>
  106. import { systemInfo } from "@/mixin.js";
  107. // 引入mescroll-mixins.js
  108. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  109. import tabbar from "../components/tabbar.vue";
  110. export default {
  111. mixins: [MescrollMixin,systemInfo], // 使用mixin
  112. components: {
  113. tabbar
  114. },
  115. data() {
  116. return {
  117. isEmpty:false,
  118. staticUrl:this.$commonConfig.staticUrl,
  119. floorIndex:0,
  120. secondTypesIndex:0,
  121. moreSecondTypesIndex:null,
  122. moreSecondTypes:false,
  123. showMoreSecondTypesIcon:'list',
  124. tabsList:[{name:'全部',id:''}],
  125. downOption: {},
  126. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  127. upOption: {
  128. page: {
  129. size: 10 // 每页数据的数量,默认10
  130. },
  131. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  132. empty: {
  133. tip: '暂无相关数据'
  134. }
  135. },
  136. //菜单
  137. floorTree:[],
  138. childrenIndex:0,
  139. childrenId:undefined,
  140. //子菜单
  141. subTypeList:[],
  142. subTypeListMore:[],
  143. // 列表数据
  144. dataList: [],
  145. params:{
  146. floorId:'',//楼层id
  147. typeName:'',//品牌类型名称
  148. name:'',//品牌名称
  149. },
  150. tabsCurrent:0,
  151. }
  152. },
  153. watch:{
  154. floorIndex:{
  155. handler(val){
  156. // console.log('floorIndex',val);
  157. this.params.name = '' ;
  158. this.childrenIndex = 0;
  159. this.mescroll.resetUpScroll();
  160. },
  161. immediate:false
  162. }
  163. },
  164. onLoad() {
  165. this.getSystemInfo();
  166. },
  167. onShow() {
  168. this.selectBrandFloorTree();
  169. this.brandCategoryType();
  170. },
  171. methods: {
  172. /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
  173. downCallback(){
  174. this.mescroll.resetUpScroll();
  175. },
  176. /*上拉加载的回调*/
  177. upCallback(page) {
  178. // 此处可以继续请求其他接口
  179. // if(page.num == 1){
  180. // // 请求其他接口...
  181. // }
  182. let childrenArr = this.floorTree[this.floorIndex]?.children||[];
  183. this.childrenId = childrenArr[this.childrenIndex]?.id;
  184. // console.log('childrenId',this.childrenId);
  185. this.params.floorId = this.childrenId;
  186. // console.log('floorId',this.params.floorId);
  187. this.params.typeName = this.tabsList[this.tabsCurrent].name;
  188. if(this.params.typeName=='全部'){this.params.typeName=''}
  189. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  190. if(!this.params.floorId){
  191. this.mescroll.endErr();
  192. this.isEmpty = true;
  193. // this.selectBrandFloorTree();
  194. return // 此处return,先获取xx
  195. }
  196. if(this.params.name){
  197. this.params.floorId = ''
  198. }
  199. // console.log('this.params.floorId',this.params.floorId);
  200. let pageNum = page.num; // 页码, 默认从1开始
  201. let pageSize = page.size; // 页长, 默认每页10条
  202. this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
  203. this.$u.api.brandList(this.params).then(data => {
  204. // console.log('data',JSON.parse(JSON.stringify(data)));
  205. // 接口返回的当前页数据列表 (数组)
  206. let curPageData = data.data.rows;
  207. // console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
  208. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  209. let curPageLen = curPageData.length;
  210. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  211. // let totalPage = data.data.data.totalPage;
  212. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  213. let totalSize = data.data.total;
  214. // 接口返回的是否有下一页 (true/false)
  215. // let hasNext = data.xxx;
  216. // console.log('totalPage',totalPage,'curPageLen',curPageLen);
  217. //设置列表数据
  218. if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
  219. this.dataList = this.dataList.concat(curPageData); //追加新数据
  220. // 请求成功,隐藏加载状态
  221. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  222. // this.mescroll.endByPage(curPageLen, totalPage);
  223. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  224. this.mescroll.endBySize(curPageLen, totalSize);
  225. }).catch(err => {
  226. this.mescroll.endErr()
  227. console.log(err)
  228. });
  229. },
  230. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  231. reloadList() {
  232. this.mescroll.resetUpScroll();
  233. },
  234. search(e){
  235. // this.floorIndex = '';
  236. this.tabsCurrent = 0;
  237. this.reloadList();
  238. },
  239. selectBrandFloorTree(){
  240. this.$u.api.selectBrandFloorTree().then(res=>{
  241. this.floorTree = res.data;
  242. if(res.data.length>0){
  243. this.isEmpty = false;
  244. }
  245. this.mescroll.resetUpScroll();
  246. }).catch(err=>{
  247. this.mescroll.endErr()
  248. console.log('selectBrandFloorTree',err);
  249. })
  250. },
  251. brandCategoryType(){
  252. this.$u.api.brandCategoryType().then(res=>{
  253. let data = res.data.map(item=>{
  254. return {name:item.dictLabel,id:item.dictValue}
  255. });
  256. this.tabsList = data;
  257. this.tabsList.unshift({name:'全部',id:''});
  258. this
  259. }).catch(err=>{
  260. this.mescroll.endErr()
  261. console.log('brandCategoryType',err);
  262. })
  263. },
  264. floorClick(index){
  265. let childrenArr = this.floorTree[index]?.children||[];
  266. if(childrenArr.length<1){
  267. uni.$u.toast('该区域暂无品牌信息')
  268. return
  269. }
  270. this.floorIndex = index;
  271. },
  272. tabsClick(e){
  273. // console.log('tabsClick',e);
  274. this.tabsCurrent = e.index;
  275. this.reloadList();
  276. },
  277. secondTypesClick(index){
  278. this.secondTypesIndex = index;
  279. this.moreSecondTypesIndex = null;
  280. this.mescroll.resetUpScroll();
  281. },
  282. childrenClick(i){
  283. if(!this.floorIndex){
  284. this.floorIndex = 0
  285. }
  286. // console.log('children',this.floorTree[this.floorIndex].children[i]);
  287. let children = this.floorTree[this.floorIndex].children[i];
  288. // console.log('childrenClick',children);
  289. // this.floorIndex = children.parentId;
  290. // console.log('parentId',children.parentId);
  291. this.childrenIndex = i;
  292. this.params.name = '' ;
  293. this.tabsCurrent = 0;
  294. this.reloadList()
  295. }
  296. }
  297. }
  298. </script>
  299. <style>
  300. page{
  301. /* padding-top: 0; */
  302. }
  303. </style>
  304. <style lang="scss" scoped>
  305. .out-wrap{
  306. background-color: #F5F5F5;
  307. .right{
  308. background-color: #fff;
  309. width: calc( 100vw - 200rpx );
  310. // flex: 1;
  311. }
  312. }
  313. .tabs-wrap{
  314. /deep/ .u-tabs__wrapper__nav__item{
  315. padding: 0 10rpx;
  316. }
  317. }
  318. .floors{
  319. width: 200rpx;
  320. font-size: 26rpx;
  321. text-align: center;
  322. .floor{
  323. position: relative;
  324. padding: 25rpx 0;
  325. &.active{
  326. background-color: #fff;
  327. }
  328. .floorName{
  329. padding: 27rpx 0;
  330. font-weight: 600;
  331. }
  332. .children{
  333. padding: 27rpx 0;
  334. &.active{
  335. background: rgba(0,164,71,0.1);
  336. color: #00A447;
  337. }
  338. }
  339. }
  340. }
  341. .brand-list{
  342. .brand{
  343. border-bottom: 0.5px solid #eee;
  344. padding-bottom: 30rpx;
  345. margin-bottom: 30rpx;
  346. .text{
  347. margin-left: 20rpx;
  348. font-size: 22rpx;
  349. color: #999999;
  350. line-height: 30rpx;
  351. .name{
  352. font-size: 30rpx;
  353. font-weight: 600;
  354. color: #333333;
  355. line-height: 42rpx;
  356. margin-bottom: 20rpx;
  357. }
  358. .typeName{
  359. margin-bottom: 20rpx;
  360. .type{
  361. background: rgba(0,164,71,0.1);
  362. border-radius: 4rpx;
  363. font-size: 24rpx;
  364. color: #00A447;
  365. padding: 8rpx 16rpx;
  366. margin-left: 0;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. .mescroll-body{
  373. background-color: #fff;
  374. }
  375. </style>