123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- const content = {
- pageNumber: 1,
- pageTotal: 1
- },
- _Http = getApp().globalData.http;
- let sa_brandid = null,
- downCount = null;
- Component({
- options: {
- addGlobalClass: true
- },
- data: {
- CustomBar: getApp().globalData.CustomBar,
- typeList: [],
- list: [],
- filtratelist: [],
- popupShow: false
- },
- methods: {
- init() {
- content.where = {
- condition: "",
- itemclassid: "",
- tradefield: ""
- }
- this.getBrand();
- this.getTradefie();
- return true;
- },
- /* 获取品牌 */
- getBrand() {
- _Http.basic({
- "id": 20220924163702,
- content: {
- nocache: true,
- pageSize: 999,
- }
- }).then(res => {
- console.log("查询品牌", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- if (res.data.length != 0) {
- sa_brandid = res.data[0].sa_brandid;
- this.getTypeList();
- } else {
- wx.showToast({
- title: '未查询到授权品牌',
- icon: "none"
- })
- }
- })
- },
- /* 获取分类 */
- getTypeList() {
- _Http.basic({
- "id": "20220922110403",
- pageSize: 1000,
- content: {
- nocache: true,
- sa_brandid: sa_brandid,
- where: {
- istool: 0,
- ishide: 0
- }
- }
- }).then(res => {
- console.log("营销类别", res)
- if (res.data.length) {
- res.data[0].ttemclass.unshift({
- itemclassid: "",
- itemclassfullname: "全部",
- itemclassname: "全部",
- subdep: []
- })
- this.setData({
- itemClasss: [res.data[0].ttemclass]
- });
- try {
- this.selectAllComponents('#class0').filter(v => {
- v.setData({
- active: 0
- })
- })
- } catch {}
- }
- this.getList(true);
- })
- },
- itemClasssChange(e) {
- let detail = e.detail;
- content.where.itemclassid = detail.item.itemclassid;
- let itemClasss = this.data.itemClasss,
- subdep = detail.item.subdep;
- itemClasss = itemClasss.slice(0, detail.rowIndex + 1);
- /* if (subdep.length) {
- subdep.unshift({
- itemclassid: detail.item.itemclassid,
- itemclassfullname: "全部",
- itemclassname: "全部",
- subdep: []
- })
- itemClasss.push(subdep)
- this.selectAllComponents('#class' + (detail.rowIndex - 0 + 1)).filter(v => v.setData({
- active: 0
- }))
- } */
- this.setData({
- itemClasss
- })
- itemClasss.push(subdep)
- this.setData({
- itemClasss
- })
- this.getList(true);
- },
- /* 获取产品 */
- getList(init = false) {
- wx.hideLoading()
- if (init.detail != undefined) init = init.detail;
- if (init) content.pageNumber = 1;
- if (content.pageNumber > content.pageTotal) return;
- content.brandids = [sa_brandid];
- _Http.basic({
- "id": 20220926142203,
- content
- }).then(res => {
- console.log("商品列表", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- this.selectComponent('#ListBox').RefreshToComplete();
- content.pageNumber = res.pageNumber + 1;
- content.pageTotal = res.pageTotal;
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
- })
- this.setListHeight()
- })
- },
- /* 开始搜索 */
- onSearch({
- detail
- }) {
- content.where.condition = detail;
- wx.showLoading({
- title: '搜索中...',
- })
- this.getList(true)
- },
- onChange({
- detail
- }) {
- content.where.condition = detail;
- },
- /* 获取领域 */
- getTradefie() {
- _Http.basic({
- "id": 20221223141802,
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 9999,
- where: {
- condition: ""
- }
- }
- }, false).then(res => {
- console.log("获取领域", res)
- if (res.msg == '成功' && res.data.length > 1) {
- res.data.unshift({
- rowindex: 0,
- subvalues: [],
- sys_enterprise_tradefieldid: 0,
- tradefield: "全部"
- })
- this.setData({
- tradefieList: res.data
- });
- }
- })
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".division", this);
- },
- tradefieChange({
- detail
- }) {
- content.where.tradefield = detail.item.tradefield == '全部' ? '' : detail.item.tradefield
- this.getList(true);
- this.selectAllComponents('#tradefieList').filter(v => {
- v.setData({
- active: detail.index
- })
- })
- },
- openPopup() {
- this.setData({
- popupShow: true
- })
- },
- onClose() {
- this.setData({
- popupShow: false
- })
- }
- }
- })
|