123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- // components/BdList/BdList.js
- const {
- api_teamMember_list,
- } = require('../../utils/api.js');
- const {
- net
- } = require('../../utils/net.js');
- const util = require('../../utils/util.js');
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- checkType: {
- type: String,
- value: ''
- },
- radioId: {
- type: [String, Number],
- value: ''
- },
- height: {
- type: [String, Number],
- value: ''
- },
- sourceUserIds: {
- type: Array,
- value: []
- },
- auditStatus: {
- type: [String, Number],
- value: ''
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- isFliter: false,
- positionType: 8,
- dataArr: [],
- loadingFlag: true,
- totalCount: null,
- page: 1,
- limit: 10,
- keyWord: "",
- resultData: {},
- scrollViewHeight: 0,
- sourceUserIdArr: []
- },
- /**
- * 组件的方法列表
- */
- methods: {
- getScrollViewHeight() {
- let height = this.data.height
- const query = wx.createSelectorQuery().in(this)
- query.select('.search-wrap').boundingClientRect()
- query.exec(res => {
- res.forEach(element => {
- if (element && element.height) {
- height = height - element.height
- }
- });
- this.setData({
- scrollViewHeight: height
- })
- })
- },
- getResultDataCallack(data) {
- this.setData({
- totalCount: null,
- resultData: data,
- isFliter: Object.keys(data).length === 0 ? false : true
- }, () => {
- this.data.page = 1
- this.getData();
- })
- },
- goFilterHandle() {
- wx.navigateTo({
- url: `/pages/mydistributorfilter/mydistributorfilter?resultData=${JSON.stringify(this.data.resultData)}`
- })
- },
- reachBottomHandle() {
- let page = this.data.page + 1
- this.data.page = page
- this.getData(page)
- },
- // 实时搜索
- touchSearch(event) {
- let _this = this;
- clearTimeout(this.timer)
- this.timer = setTimeout(() => {
- _this.searchHandle(event);
- }, 500)
- },
- // 完成搜索
- searchHandle(event) {
- this.setData({
- totalCount: null,
- keyWord: event.detail.value,
- }, () => {
- this.data.page = 1
- this.getData();
- })
- },
- getData() {
- const { totalCount, dataArr } = this.data
- if ((totalCount && parseInt(totalCount)) === dataArr.length) {
- return false
- }
- let params = {
- url: api_teamMember_list,
- data: {
- page: this.data.page,
- limit: this.data.limit,
- keyWord: this.data.keyWord,
- positionType: this.data.positionType,
- }
- }
- if (this.data.auditStatus) {
- params.data.auditStatus = this.data.auditStatus
- }
- params.data = Object.assign({}, params.data, this.data.resultData)
- if (this.data.keywords) {
- params.data.keywords = this.data.keywords
- }
- this.setData({
- loadingFlag: true
- })
- net.req(params).then((res) => {
- this.setData({
- loadingFlag: false,
- dataArr: this.data.page > 1 ? this.data.dataArr.concat(res.data.list) : res.data.list || [],
- totalCount: res.data.pages.totalCount
- }, () => {
- this.getScrollViewHeight()
- })
- })
- },
- showDetail(options) {
- const {
- item
- } = options.currentTarget.dataset;
- const { checkType } = this.data
- if (checkType) {
- if (checkType == 1) {
- // 单选来源人
- this.triggerEvent('radioEvent', item)
- } else if (checkType == 2) {
- this.triggerEvent('checkBoxEvent', item)
- }
- return false
- }
- wx.navigateTo({
- url: `/pages/mydistributorsdetail/mydistributorsdetail?id=${item.id}`
- })
- },
- },
- observers: {
- 'sourceUserIds': function (subfield) {
- this.setData({
- sourceUserIdArr: subfield
- })
- },
- },
- lifetimes: {
- attached: function () {
- },
- ready() {
- this.getData()
- }
- },
- })
|