| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 | const _Http = getApp().globalData.http;Page({	data: {		istool: 0, //0商品 1工具		brand: {}, //当前品牌		brandList: [], //品牌列表		typeList: [],		cType: {},		loading: true,		"content": {			"pageNumber": 1,			"pageTotal": 1,			"where": {				"condition": ""			},			sort: []		},		sys_enterpriseid: "",	},	onLoad(options) {		this.setData({			istool: options.istool ? 1 : 0,			userrole: wx.getStorageSync('userrole')		})		this.getBrand()		this.getNum();		this.getTradefie();		this.getOptionTypeSelect();		getApp().globalData.Language.getLanguagePackage(this, 'E-订单');	},	/* 业务员选择角色 */	selsectedRole(e) {		wx.navigateTo({			url: './selected/index',		})		getApp().globalData.handleSelect = this.handleRole.bind(this);	},	handleRole({		sys_enterpriseid,		enterprisename	}) {		this.setData({			buttonText: enterprisename,			tradefieid: "",			sys_enterpriseid		});		this.getBrand();		this.getTradefie();		wx.navigateBack();	},	onCleaRole() {		this.setData({			buttonText: "",			sys_enterpriseid: ""		})		setTimeout(() => {			this.getTradefie();			this.getBrand();		}, 0)	},	/* 获取授权标准 */	getOptionTypeSelect() {		_Http.basic({			"id": "20230519141202",			"content": {				sys_enterpriseid: this.data.sys_enterpriseid			},		}, false).then(res => {			console.log("授权标准", res)			if (res.code == '1') {				res.data.unshift("全部")				this.setData({					standardList: res.data.map(v => {						return {							standard: v						}					})				})			}		})	},	standardChange(e) {		this.setData({			standard: e.detail.item.standard == '全部' ? "" : e.detail.item.standard		})		this.getList(true);	},	/* 获取领域 */	getTradefie() {		let content = {			nocache: true,			pageNumber: 1,			pageSize: 9999,			where: {				condition: ""			}		};		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;		_Http.basic({			"id": this.data.userrole == '业务员' ? 20230418142202 : 20221223141802,			content		}, false).then(res => {			console.log("获取领域", this.data.userrole, res)			if (res.code != '1') {				res.data = [{					rowindex: 0,					subvalues: [],					sys_enterprise_tradefieldid: 0,					tradefield: "全部"				}]			} else {				if (res.data.length == 1) {					res.data[0] = {						rowindex: 0,						subvalues: [],						sys_enterprise_tradefieldid: 0,						tradefield: "全部"					}				} else {					res.data.unshift({						rowindex: 0,						subvalues: [],						sys_enterprise_tradefieldid: 0,						tradefield: "全部"					})				}			}			this.setData({				tradefieid: "",				tradefieList: res.data			});		})	},	/* 切换领域 */	tradefieChange(e) {		this.setData({			tradefieid: e.detail.item.tradefield == '全部' ? "" : e.detail.item.tradefield		})		this.getList(true);	},	/* 切换分类 */	typeChange({		detail	}) {		let typeList = this.data.typeList;		if (typeList.length - 1 != detail.rowIndex) typeList = typeList.slice(0, detail.rowIndex + 1);		typeList[detail.rowIndex].active = detail.index		if (detail.item.subdep.length) typeList.push({			active: -1,			list: detail.item.subdep		})		this.setData({			cType: detail.item,			typeList		});		this.getList(true);	},	/* 获取品牌 */	getBrand() {		let content = {			nocache: true,			pageSize: 999,		};		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;		_Http.basic({			"id": 20220924163702,			content		}).then(res => {			console.log("查询品牌", res)			if (res.code != '1') return wx.showToast({				title: res.msg,				icon: "none"			});			if (res.data.length != 0) {				let obj = {					brandname: "全部品牌",					rowindex: 1,					sa_brandid: 0,				}				res.data.unshift(obj)				this.setData({					brandList: res.data,				});				this.data.brand = res.data[0];				this.getTypeList();			} else {				getApp().globalData.Language.showToast('未查询到授权品牌')				this.setData({					brandList: [obj],					loading: false,					list: [],					typeList: []				})			}		})	},	/* 切换品牌 */	brandChange(e) {		this.data.brand = e.detail.item;		this.getTypeList();	},	/* 获取分类 */	getTypeList() {		let content = {			sa_brandid: this.data.brand.sa_brandid,			nocache: true,			where: {				istool: 0, //默认0,不是工具,1表示工具			}		}		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;		_Http.basic({			"id": "20220922110403",			"pageSize": 1000,			content		}).then(res => {			console.log("营销类别", res)			let siteid = wx.getStorageSync('userMsg').siteid;			if (res.data.length) {				res.data[0].ttemclass.unshift({					itemclassid: "",					itemclassfullname: siteid == 'HY' ? '营销类别' : "全部",					itemclassname: siteid == 'HY' ? '营销类别' : "全部",					subdep: []				})				this.setData({					['typeList[0]']: {						active: 0,						list: res.data[0].ttemclass					},					"cType": res.data[0].ttemclass[0],					loading: false				});			}			this.getList(true);		})	},	/* 获取产品 */	getList(init = false) {		if (init.detail != undefined) init = init.detail;		let content = JSON.parse(JSON.stringify(this.data.content));		if (init) content.pageNumber = 1;		if (content.pageNumber > content.pageTotal) return;		content.brandids = this.data.brand.sa_brandid == 0 ? [] : [this.data.brand.sa_brandid];		content.where.itemclassid = this.data.cType.itemclassid || "";		content.where.tradefield = this.data.tradefieid || "";		content.where.standards = this.data.standard || '';		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;		_Http.basic({			"id": 20220926142203,			content		}).then(res => {			console.log("商品列表", res)			if (res.code != '1') return wx.showToast({				title: res.msg,				icon: "none"			})			this.selectComponent('#ListBox').RefreshToComplete();			this.setData({				list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),				"content.pageNumber": res.pageNumber + 1,				"content.pageTotal": res.pageTotal,				"content.sort": res.sort,				loading: false			})			this.setListHeight()		})	},	/* 搜索 */	onSearch({		detail	}) {		this.setData({			"content.where.condition": detail		});		this.getList(true)	},	onReady() {		this.setListHeight()	},	/* 设置页面高度 */	setListHeight() {		this.selectComponent("#ListBox").setHeight(".division", this);	},	/* 获取购物车数量 */	getNum() {		if (this.data.userrole == '业务员') return;		_Http.basic({			"id": 20220927093202,			"content": {}		}).then(res => {			console.log("购物车数量", res)			getApp().globalData.num = res.data.num;			this.selectComponent("#Float").setNum(res.data.num)		});	},	onShow() {		if (getApp().globalData.num && this.data.userrole != '业务员') this.selectComponent("#Float").setNum(getApp().globalData.num)	}})
 |