shoplist.vue 5.3 KB

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