index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <view class="search">
  5. <uni-row class="demo-uni-row" :width="nvueWidth">
  6. <uni-col>
  7. <view class="demo-uni-col">
  8. <uni-easyinput class="uni-input" prefixIcon="search" v-model="searchVal" placeholder="请输入商户名称"></uni-easyinput>
  9. </view>
  10. </uni-col>
  11. </uni-row>
  12. <uni-row class="demo-uni-row" :width="nvueWidth">
  13. <uni-col :span="11">
  14. <view class="demo-uni-col">
  15. <uni-data-picker :localdata="items" placeholder="商铺位置" popup-title="选择商铺位置" @change="onchange" @nodeclick="onnodeclick"></uni-data-picker>
  16. </view>
  17. </uni-col>
  18. <uni-col :span="5">
  19. <view class="demo-uni-col">
  20. <uni-data-select class="search-data-select" placeholder="使用状态" v-model="statusValue" :localdata="statusRange" @change="changeStatus">状态</uni-data-select>
  21. </view>
  22. </uni-col>
  23. <uni-col :span="4">
  24. <view class="demo-uni-col">
  25. <button class="searchBtn" type="default" size="mini" @click="handleSearch">搜索</button>
  26. </view>
  27. </uni-col>
  28. <uni-col :span="4">
  29. <view class="demo-uni-col">
  30. <button class="searchBtn" type="default" size="mini" @click="handleReset">重置</button>
  31. </view>
  32. </uni-col>
  33. </uni-row>
  34. </view>
  35. </view>
  36. <uni-list border class="list">
  37. <uni-list-item
  38. v-for="(item, index) in dataList"
  39. :key="index"
  40. :ellipsis="2"
  41. :title=getTitle(item)
  42. :note="item.createTime"
  43. showArrow
  44. clickable
  45. @click="listItemBtn(item)">
  46. </uni-list-item>
  47. </uni-list>
  48. <uni-load-more :status="more" />
  49. </view>
  50. </template>
  51. <script>
  52. import dictApi from '../../api/dict.js';
  53. import shopApi from '../../api/shop.js';
  54. import { BASE_URL } from '../../env.js';
  55. export default {
  56. data() {
  57. return {
  58. searchVal: '',
  59. // more = 加载前, loading = 加载中, noMore = 没有更多
  60. more: 'more',
  61. dataList: [],
  62. items: [{
  63. text: "一年级",
  64. value: "1-0",
  65. children: [
  66. {
  67. text: "1.1班",
  68. value: "1-1"
  69. },
  70. {
  71. text: "1.2班",
  72. value: "1-2"
  73. }
  74. ]
  75. },
  76. {
  77. text: "二年级",
  78. value: "2-0"
  79. },
  80. {
  81. text: "三年级",
  82. value: "3-0"
  83. }],
  84. queryForm: {
  85. pageNum: 1,
  86. pageSize: 12,
  87. district: null,
  88. building: null,
  89. floor: null,
  90. status: null,
  91. name: null,
  92. }
  93. }
  94. },
  95. onShow: function() {
  96. // this.init();
  97. },
  98. async mounted() {
  99. this.getShopList();
  100. await this.getDicts();
  101. },
  102. methods: {
  103. getTitle(shop){
  104. const title = shop.district
  105. + " 楼栋:" + shop.building
  106. + " 楼层:" + shop.floor
  107. + " 铺位号:" + shop.number;
  108. + "商户:" + shop.name;
  109. + "状态:" + shop.status;
  110. return title;
  111. },
  112. async getDicts() {
  113. const resp_district = await dictApi.getDict('che_district');
  114. if (resp_district.code == 200)
  115. this.districtRange = resp_district.data.map(l => ({ ...l, value: l.dictValue, text: l.dictLabel }));
  116. const resp_vacant = await dictApi.getDict('vacant_status');
  117. if (resp_vacant.code == 200)
  118. this.statusRange = resp_vacant.data.map(l => ({ ...l, value: l.dictValue, text: l.dictLabel }));
  119. },
  120. // 列表点击函数
  121. listItemBtn(e) {
  122. uni.navigateTo({ url: `/pages/shop/info?id=${e.shopId}` })
  123. },
  124. // 搜索函数
  125. async getShopList() {
  126. this.reset();
  127. this.more = 'loading';
  128. const queryParams = {};
  129. for (const key in this.queryForm) {
  130. if (this.queryForm[key] !== null && this.queryForm[key] !== undefined) {
  131. queryParams[key] = this.queryForm[key];
  132. }
  133. }
  134. const resp = await shopApi.getShopList({...queryParams});
  135. this.dataList.push(...resp.data.map(e => {return {...e}}))
  136. // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
  137. this.more = this.page >= Math.ceil(resp.total / this.size) ? 'noMore' : 'more';
  138. },
  139. // 搜索函数
  140. async handleSearch() {
  141. await this.getShopList();
  142. },
  143. async changeDistrict(e) {
  144. this.buildingValue = null;
  145. this.buildingRange.length = 0;
  146. this.districtValue = e;
  147. const resp_building = await shopApi.listBuildingByDistrict({district: e});
  148. if (resp_building.code == 200)
  149. this.buildingRange = resp_building.data.map(l => ({ ...l, value: l, text: l}));
  150. },
  151. changeBuidling(e) {
  152. this.buildingValue = e;
  153. console.log("e:", e);
  154. },
  155. changeStatus(e) {
  156. console.log("e:", e);
  157. },
  158. reset() {
  159. this.dataList.length = 0;
  160. this.queryForm.pageNum = 1;
  161. this.queryForm.pageSize= 12;
  162. this.queryForm.district = this.districtValue;
  163. this.queryForm.status = this.statusValue;
  164. this.queryForm.building = this.buildingValue;
  165. this.queryForm.floor = this.floor;
  166. this.queryForm.name = this.searchVal;
  167. }
  168. },
  169. // 页面生命周期中onReachBottom(页面滚动到底部的事件)
  170. onReachBottom() {
  171. if(this.more != 'noMore') {
  172. this.more = 'more';
  173. this.getShopList();
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. .container {
  180. width: 100%;
  181. background-color: #fff;
  182. }
  183. .top {
  184. width: 100%;
  185. z-index: 999;
  186. background-color: #fff;
  187. /* overflow: hidden; */
  188. }
  189. .tabsBox {
  190. width: 100%;
  191. border-bottom: 1px solid #d3d3d3;
  192. display: flex;
  193. }
  194. .tab {
  195. width: 25%;
  196. }
  197. .text {
  198. display: block;
  199. width: 80%;
  200. margin: 0 auto;
  201. text-align: center;
  202. }
  203. .current {
  204. color: #ff9302;
  205. border-bottom: 1px solid #ff9302;
  206. }
  207. .search {
  208. width: 98%;
  209. border: 1px solid #f3f3f3;
  210. background-color: #fff !important;
  211. border-radius: 5px;
  212. margin: 2px;
  213. padding: 2rpx;
  214. display: block;
  215. }
  216. .demo-uni-row {
  217. margin-bottom: 10px;
  218. display: block;
  219. }
  220. /deep/ .uni-row {
  221. margin-bottom: 10px;
  222. }
  223. .demo-uni-col {
  224. height: 24px;
  225. margin-bottom: 10px;
  226. border-radius: 4px;
  227. }
  228. .uni-easyinput {
  229. width: 100%;
  230. font-size: 14px;
  231. display: block;
  232. }
  233. .uni-easyinput .uni-easyinput__content {
  234. border: 1px solid #f3f3f3;
  235. border-radius: 10px;
  236. }
  237. .search-data-select{
  238. width: 100%;
  239. border-radius: 10px;
  240. }
  241. .searchBtn {
  242. width: 98%;
  243. background-color: #ff9302 !important;
  244. border: none;
  245. color: #fff !important;
  246. border-radius: 12px;
  247. }
  248. .list {
  249. display: block;
  250. }
  251. </style>