详情小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
9.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <view class="head" v-if="$isRight(filter)">
  4. <!-- <button class="sign-in-btn">最新</button> -->
  5. <!-- tabs -->
  6. <view class="filter-item" v-for="(value, key) in filter" :key="key" @click="switchFilter(key)">
  7. <text style="white-space: nowrap">{{ value.selected || value.name }}</text>
  8. <text class="lf-iconfont icon-iconfront-" :class="{'tab-active': show_filter && filter_key == key}"></text>
  9. </view>
  10. <!-- 普通列表文字选择 -->
  11. <view class="filter-modal" v-if="show_filter && filter_key != 'search'" @click="show_filter = false">
  12. <view class="filter-content">
  13. <view v-for="(item, index) in filter[filter_key].data" :key="index" @click="activeItem(item.text)">{{ item.text }}</view>
  14. </view>
  15. </view>
  16. <!-- 多条件搜索 -->
  17. <view class="filter-modal" v-else-if="show_filter && filter_key == 'search'" @click="show_filter = false">
  18. <view class="filter-many" @click.stop>
  19. <view class="filter-main">
  20. <view v-for="(value, key) in filter[filter_key]" :key="key" v-if="key != 'name'">
  21. <block v-if="key == 'search_value'">
  22. <view class="filter-title">会员编号搜索</view>
  23. <input class="input-search" :focus="on_focus" placeholder="请输入会员编号" :value="value" @blur="inputBlur(key, $event)" />
  24. </block>
  25. <block v-else>
  26. <view class="filter-title">{{ value.name }}</view>
  27. <view class="lf-flex-wrap">
  28. <view class="filter-capsule"
  29. :class="{'filter-active': item.text == value.selected}"
  30. v-for="(item, index) in value.data" :key="index"
  31. @click="switchCondition(key, item.text)"
  32. >{{ item.text }}</view>
  33. </view>
  34. </block>
  35. </view>
  36. </view>
  37. <view class="filter-foot">
  38. <button class="filter-btn" @click="resetFilter">重置条件</button>
  39. <button class="filter-btn solid-btn" @click="comfirm">确定</button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- head end -->
  45. <view style="height: 104rpx;"></view>
  46. <lf-user-list :list="members"></lf-user-list>
  47. <!-- 加载 -->
  48. <view class="loading-more">
  49. <text :class="{'loading-more-text': loading_class}">{{ loading_text }}</text>
  50. </view>
  51. <!-- 回到顶部 -->
  52. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  53. </view>
  54. </template>
  55. <script>
  56. import lfUserList from '@/components/lf-userList/lf-userList.vue'
  57. // var filterObj = require('./filter.json');
  58. export default {
  59. components: { lfUserList },
  60. data(){
  61. return {
  62. show_filter: false,
  63. filter: {},
  64. filter_key: '',
  65. name: '最新',
  66. on_focus: false,
  67. filterObj: {},
  68. page: 1,
  69. page_size: 10,
  70. isPage: true,
  71. loading_class: true,
  72. loading_text: '正在加载中',
  73. members: []
  74. }
  75. },
  76. onLoad(options){
  77. console.log(this.filter)
  78. this.name = options.name || this.name;
  79. this.getMemberParams();
  80. if(this.name == '搜索') {
  81. this.show_filter = true;
  82. this.filter_key = 'search';
  83. this.on_focus = true;
  84. }
  85. },
  86. methods: {
  87. // 获取查询参数
  88. getMemberParams(){
  89. this.$http(this.API.API_MEMBERS_PARAMS).then(res => {
  90. console.log(res, "---------");
  91. this.filterObj = res.data;
  92. this.filter = this.productionObj();
  93. this.getMembers();
  94. })
  95. },
  96. // 获取会员列表
  97. getMembers(options = {}){
  98. let params = this.getSelectFilter();
  99. this.$http(this.API.API_MEMBERS_ALL, {
  100. page: this.page,
  101. pagesize: this.page_size,
  102. ...params
  103. }).then(res => {
  104. let members = res.data.members.data || [];
  105. let isPage = this.$isRight(res.data.members.next_page_url);
  106. this.isPage = isPage;
  107. if(!isPage){
  108. this.loading_class = false;
  109. this.loading_text = '已加载全部数据~';
  110. }
  111. if(options.refresh){
  112. this.$msg('刷新成功', {icon: 'success'})
  113. uni.stopPullDownRefresh();
  114. }else if(options.reset){
  115. this.$msg('重置成功');
  116. }
  117. this.members = members;
  118. })
  119. },
  120. // 引入数据,并序列化,避免数据引用
  121. productionObj(){
  122. return JSON.parse( JSON.stringify(this.filterObj) );
  123. },
  124. // 切换显示隐藏筛选
  125. switchFilter(key){
  126. if(this.filter_key != key){
  127. this.show_filter = true;
  128. }else{
  129. this.show_filter = !this.show_filter;
  130. }
  131. this.filter_key = key;
  132. },
  133. // 选中筛选条件
  134. activeItem(value){
  135. this.filter[this.filter_key].selected = value;
  136. this.comfirm();
  137. },
  138. // 切换筛选条件
  139. switchCondition(key, value){
  140. this.filter[this.filter_key][key].selected = value;
  141. },
  142. // 输入框失去焦点事件
  143. inputBlur(key, event){
  144. this.filter[this.filter_key][key] = event.detail.value;
  145. },
  146. // 确定筛选
  147. comfirm(){
  148. this.show_filter = false;
  149. this.reset();
  150. this.getMembers();
  151. },
  152. reset(){
  153. this.page = 1;
  154. this.isPage = true;
  155. this.loading_class = true;
  156. this.loading_text = '正在加载中';
  157. },
  158. // 重置筛选条件
  159. resetFilter(){
  160. this.filter = this.productionObj();
  161. this.show_filter = false;
  162. this.reset();
  163. this.getMembers({reset: true});
  164. },
  165. getSelectFilter(){
  166. let filter = this.filter;
  167. let obj = {};
  168. for(let i in filter){
  169. if(i == 'search'){
  170. for(let j in filter[i]){
  171. if(j == 'search_value'){
  172. obj[j] = filter[i][j];
  173. }else if(j != 'name'){
  174. filter[i][j].data.map(item => {
  175. if(filter[i][j].selected == item.text){
  176. obj[j] = item.value;
  177. };
  178. })
  179. }
  180. }
  181. }else{
  182. filter[i].data.map(item => {
  183. if(filter[i].selected == item.text){
  184. if(Array.isArray(item.value)){
  185. obj[i] = JSON.stringify(item.value);
  186. }else{
  187. obj[i] = item.value;
  188. }
  189. };
  190. })
  191. }
  192. }
  193. return obj;
  194. }
  195. },
  196. onPullDownRefresh(){
  197. this.reset();
  198. this.getMembers({refresh: true});
  199. },
  200. onReachBottom(){
  201. if(this.isPage){
  202. this.page++;
  203. this.getMembers();
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped="scoped">
  209. .head{
  210. width: 750rpx;
  211. height: 102rpx;
  212. border-bottom: 1rpx solid #e5e5e5;
  213. position: fixed;
  214. background-color: #FFFFFF;
  215. z-index: 9;
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. padding: 0 32rpx;
  220. box-sizing: border-box;
  221. .sign-in-btn{
  222. margin: 0;
  223. width: 140rpx;
  224. height: 62rpx;
  225. background-color: #FCF7FA;
  226. border: 1rpx solid #E21196;
  227. border-radius: 10rpx;
  228. font-size: 28rpx;
  229. color: #E21196;
  230. line-height: 60rpx;
  231. }
  232. .filter-item{
  233. width: 114rpx;
  234. height: 62rpx;
  235. // line-height: 62rpx;
  236. // text-align: right;
  237. display: flex;
  238. flex-wrap: nowrap;
  239. justify-content: center;
  240. align-items: center;
  241. font-size: 28rpx;
  242. color: #222222;
  243. .tab-active{
  244. display: inline-block;
  245. transform: rotate(180deg);
  246. color: #E21196 !important;
  247. }
  248. }
  249. .filter-modal{
  250. position: absolute;
  251. z-index: 7;
  252. background-color: rgba(0,0,0,0.5);
  253. top: 103rpx;
  254. right: 0;
  255. bottom: 0;
  256. left: 0;
  257. width: 100vw;
  258. height: calc(100vh - 103rpx);
  259. .filter-content{
  260. position: absolute;
  261. width: 100%;
  262. height: max-content;
  263. max-height: 806rpx;
  264. background-color: #FFFFFF;
  265. left: 0;
  266. z-index: 14;
  267. overflow-y: scroll;
  268. padding: 0 0 32rpx 32rpx;
  269. display: flex;
  270. flex-direction: column;
  271. justify-content: space-evenly;
  272. view{
  273. height: 60rpx;
  274. // border-bottom: 1rpx solid #e5e5e5;
  275. padding: 20rpx 0;
  276. line-height: 60rpx;
  277. }
  278. }
  279. .filter-many{
  280. position: absolute;
  281. width: 100%;
  282. height: 806rpx;
  283. background-color: #FFFFFF;
  284. left: 0;
  285. z-index: 14;
  286. .filter-main{
  287. height: 675rpx;
  288. overflow-y: scroll;
  289. box-sizing: border-box;
  290. padding: 32rpx;
  291. .filter-title{
  292. font-size: 28rpx;
  293. color: #222222;
  294. font-weight: bold;
  295. margin-bottom: 20rpx;
  296. }
  297. .filter-capsule{
  298. width: 163rpx;
  299. height: 62rpx;
  300. border-radius: 31rpx;
  301. border: 1rpx solid #999999;
  302. font-size: 20rpx;
  303. color: #999999;
  304. text-align: center;
  305. line-height: 62rpx;
  306. margin-right: 12rpx;
  307. &:nth-child(4n){
  308. margin-right: 0rpx;
  309. }
  310. &:nth-child(n+5){
  311. margin-top: 12rpx;
  312. }
  313. }
  314. .filter-active{
  315. border-color: #E21196;
  316. color: #E21196;
  317. }
  318. .input-search{
  319. width: 686rpx;
  320. height: 62rpx;
  321. background-color: #FFFFFF;
  322. border-radius: 10rpx;
  323. border: 1rpx solid #DDDDDD;
  324. box-sizing: border-box;
  325. padding: 0 15rpx;
  326. font-size: 28rpx;
  327. margin-bottom: 50rpx;
  328. }
  329. }
  330. .filter-main>view:nth-child(n+3){
  331. margin-top: 40rpx;
  332. }
  333. .filter-foot{
  334. height: 130rpx;
  335. border-top: 1rpx solid #e5e5e5;
  336. padding: 32rpx;
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. .filter-btn{
  341. width: 332rpx;
  342. height: 90rpx;
  343. border-radius: 10rpx;
  344. border: 1rpx solid #555555;
  345. background-color: #FFFFFF;
  346. line-height: 88rpx;
  347. font-size: 32rpx;
  348. color: #555555;
  349. margin: 0;
  350. }
  351. .solid-btn{
  352. background-color: #E21196;
  353. color: #FFFFFF;
  354. border: none;
  355. }
  356. }
  357. }
  358. }
  359. }
  360. </style>