Browse Source

商城业务员逻辑修改

xiaohaizhao 2 years ago
parent
commit
8d543e6141

+ 212 - 206
packageA/market/detail.js

@@ -1,214 +1,220 @@
 const _Http = getApp().globalData.http;
-let sa_brandid = null;
+let sa_brandid = null,
+  sys_enterpriseid = null;
 import {
-	fileList
+  fileList
 } from "../../utils/FormatTheAttachment";
 import currency from "../../utils/currency";
 
 Page({
-	data: {
-		loading: true
-	},
-	onLoad(options) {
-		if (options.id) this.setData({
-			sa_itemgroupid: options.id,
-			itemno: options.itemno
-		})
-		sa_brandid = options.sa_brandid;
-		this.setData({
-			userrole: wx.getStorageSync('userrole')
-		})
-		this.getDetail();
-	},
-	/* 获取详情 */
-	getDetail() {
-		_Http.basic({
-			"id": "20220926142403",
-			"content": {
-				"sa_itemgroupid": this.data.sa_itemgroupid,
-				// itemno: this.data.itemno
-			}
-		}).then(res => {
-			console.log("商品详情", res)
-			if (res.msg != '成功') return wx.showToast({
-				title: res.msg,
-				icon: "none"
-			})
-			if (res.data.length == 0) {
-				wx.showToast({
-					title: '未查询到商品',
-					icon: "none",
-					mask: true
-				})
-				setTimeout(() => {
-					wx.navigateBack();
-				}, 500)
-				return;
-			}
-			this.handleFiles(res.data[0].attinfos)
-			const CNY = sum => currency(sum, {
-				symbol: "¥",
-				precision: 2
-			}).format();
+  data: {
+    loading: true
+  },
+  onLoad(options) {
+    if (options.id) this.setData({
+      sa_itemgroupid: options.id,
+      itemno: options.itemno
+    })
+    sa_brandid = options.sa_brandid;
+    this.setData({
+      userrole: wx.getStorageSync('userrole')
+    })
 
-			this.setData({
-				detail: res.data[0],
-				rows: res.data.map(v => {
-					v.gradeprice = CNY(v.gradeprice);
-					v.marketprice = CNY(v.marketprice);
-					return v
-				}),
-				loading: false
-			})
-		})
-	},
-	/* 预览媒体 */
-	viewMedias(e) {
-		const {
-			index,
-			type
-		} = e.currentTarget.dataset;
-		wx.previewMedia({
-			current: index,
-			sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
-		})
-	},
-	/* 处理附件 */
-	handleFiles(arr) {
-		let files = {
-				images: [],
-				viewImages: [],
-				videos: [],
-				viewVideos: [],
-				files: []
-			},
-			list = fileList(arr);
-		list.forEach(v => {
-			switch (v.fileType) {
-				case "video":
-					files.videos.push(v)
-					files.viewVideos.push({
-						url: v.url,
-						type: "video",
-						poster: v.subfiles[0].url
-					})
-					break;
-				case "image":
-					files.images.push(v)
-					files.viewImages.push({
-						url: v.url,
-						type: "image"
-					})
-					break;
-				default:
-					files.files.push(v)
-					break;
-			}
-		});
-		this.setData({
-			files
-		})
-	},
-	/* 切换产品 */
-	changeItemno(e) {
-		const {
-			item
-		} = e.currentTarget.dataset;
-		if (item.itemno == this.data.itemno) return;
-		this.handleFiles(item.attinfos)
-		this.setData({
-			detail: item,
-			itemno: item.itemno
-		})
-	},
-	clickBut() {
-		this.data.detail.tradefield.length >= 2 ? wx.showToast({
-			title: '请选择加入产品领域',
-			icon: "none",
-			duration: 3000
-		}) : this.handleStorage(0);
-	},
-	/* 打开文档 */
-	openDocument(e) {
-		const {
-			item
-		} = e.currentTarget.dataset;
-		console.log(item)
-		wx.showLoading({
-			title: '加载中...',
-			mask: true,
-		})
-		wx.downloadFile({
-			url: item.url,
-			success: function (res) {
-				const filePath = res.tempFilePath
-				wx.openDocument({
-					filePath: filePath,
-					showMenu: true,
-					fileType: item.postfix,
-					success: function (res) {
-						wx.hideLoading();
-						console.log('打开文档成功')
-					},
-					fail(e) {
-						console.log(e)
-						wx.showToast({
-							title: '打开失败',
-							icon: "error",
-							mask: true
-						})
-					}
-				})
-			},
-			fail(e) {
-				console.log(e)
-				wx.showToast({
-					title: '打开失败',
-					icon: "error",
-					mask: true
-				})
-			}
-		})
-	},
-	/* 选择领域 */
-	storage(e) {
-		this.handleStorage(e.detail.value)
-	},
-	handleStorage(index) {
-		let detail = this.data.detail;
-		_Http.basic({
-			"id": 20220924095102,
-			"content": {
-				sa_brandid,
-				"itemid": detail.itemid, //货品id
-				"qty": detail.orderminqty, //数量
-				"itemno": this.data.itemno, //货品编号
-				tradefield: detail.tradefield[index].tradefield
-			},
-		}).then(res => {
-			console.log("加入购物车", res)
-			if (res.msg != '成功') return wx.showToast({
-				title: res.msg,
-				icon: "none"
-			});
-			_Http.basic({
-				"id": 20220927093202,
-				"content": {}
-			}, false).then(res => {
-				console.log("购物车数量", res)
-				getApp().globalData.num = res.data.num;
-				if (this.data.userrole == '经销商') this.selectComponent("#Float").setNum(res.data.num)
-				setTimeout(() => {
-					wx.showToast({
-						title: '加入成功',
-						icon: "none",
-						icon: "none"
-					});
-				}, 200);
-			});
-		})
-	},
-	onShow() {
-		if (this.data.userrole == '经销商') this.selectComponent("#Float").setNum(getApp().globalData.num)
-	},
+    if (wx.getStorageSync('userrole') == '业务员') sys_enterpriseid = options.sys_enterpriseid
+    this.getDetail();
+  },
+  /* 获取详情 */
+  getDetail() {
+    let content = {
+      "sa_itemgroupid": this.data.sa_itemgroupid,
+      pageSize: 999
+    }
+    if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
+    console.log(sys_enterpriseid)
+    _Http.basic({
+      "id": "20220926142403",
+      content
+    }).then(res => {
+      console.log("商品详情", res)
+      if (res.msg != '成功') return wx.showToast({
+        title: res.msg,
+        icon: "none"
+      })
+      if (res.data.length == 0) {
+        wx.showToast({
+          title: '未查询到商品',
+          icon: "none",
+          mask: true
+        })
+        setTimeout(() => {
+          wx.navigateBack();
+        }, 500)
+        return;
+      }
+      this.handleFiles(res.data[0].attinfos)
+      const CNY = sum => currency(sum, {
+        symbol: "¥",
+        precision: 2
+      }).format();
+
+      this.setData({
+        detail: res.data[0],
+        rows: res.data.map(v => {
+          v.gradeprice = CNY(v.gradeprice);
+          v.marketprice = CNY(v.marketprice);
+          return v
+        }),
+        loading: false
+      })
+    })
+  },
+  /* 预览媒体 */
+  viewMedias(e) {
+    const {
+      index,
+      type
+    } = e.currentTarget.dataset;
+    wx.previewMedia({
+      current: index,
+      sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
+    })
+  },
+  /* 处理附件 */
+  handleFiles(arr) {
+    let files = {
+        images: [],
+        viewImages: [],
+        videos: [],
+        viewVideos: [],
+        files: []
+      },
+      list = fileList(arr);
+    list.forEach(v => {
+      switch (v.fileType) {
+        case "video":
+          files.videos.push(v)
+          files.viewVideos.push({
+            url: v.url,
+            type: "video",
+            poster: v.subfiles[0].url
+          })
+          break;
+        case "image":
+          files.images.push(v)
+          files.viewImages.push({
+            url: v.url,
+            type: "image"
+          })
+          break;
+        default:
+          files.files.push(v)
+          break;
+      }
+    });
+    this.setData({
+      files
+    })
+  },
+  /* 切换产品 */
+  changeItemno(e) {
+    const {
+      item
+    } = e.currentTarget.dataset;
+    if (item.itemno == this.data.itemno) return;
+    this.handleFiles(item.attinfos)
+    this.setData({
+      detail: item,
+      itemno: item.itemno
+    })
+  },
+  clickBut() {
+    this.data.detail.tradefield.length >= 2 ? wx.showToast({
+      title: '请选择加入产品领域',
+      icon: "none",
+      duration: 3000
+    }) : this.handleStorage(0);
+  },
+  /* 打开文档 */
+  openDocument(e) {
+    const {
+      item
+    } = e.currentTarget.dataset;
+    console.log(item)
+    wx.showLoading({
+      title: '加载中...',
+      mask: true,
+    })
+    wx.downloadFile({
+      url: item.url,
+      success: function (res) {
+        const filePath = res.tempFilePath
+        wx.openDocument({
+          filePath: filePath,
+          showMenu: true,
+          fileType: item.postfix,
+          success: function (res) {
+            wx.hideLoading();
+            console.log('打开文档成功')
+          },
+          fail(e) {
+            console.log(e)
+            wx.showToast({
+              title: '打开失败',
+              icon: "error",
+              mask: true
+            })
+          }
+        })
+      },
+      fail(e) {
+        console.log(e)
+        wx.showToast({
+          title: '打开失败',
+          icon: "error",
+          mask: true
+        })
+      }
+    })
+  },
+  /* 选择领域 */
+  storage(e) {
+    this.handleStorage(e.detail.value)
+  },
+  handleStorage(index) {
+    let detail = this.data.detail;
+    _Http.basic({
+      "id": 20220924095102,
+      "content": {
+        sa_brandid,
+        "itemid": detail.itemid, //货品id
+        "qty": detail.orderminqty, //数量
+        "itemno": this.data.itemno, //货品编号
+        tradefield: detail.tradefield[index].tradefield
+      },
+    }).then(res => {
+      console.log("加入购物车", res)
+      if (res.msg != '成功') return wx.showToast({
+        title: res.msg,
+        icon: "none"
+      });
+      _Http.basic({
+        "id": 20220927093202,
+        "content": {}
+      }, false).then(res => {
+        console.log("购物车数量", res)
+        getApp().globalData.num = res.data.num;
+        if (this.data.userrole == '经销商') this.selectComponent("#Float").setNum(res.data.num)
+        setTimeout(() => {
+          wx.showToast({
+            title: '加入成功',
+            icon: "none",
+            icon: "none"
+          });
+        }, 200);
+      });
+    })
+  },
+  onShow() {
+    if (this.data.userrole == '经销商') this.selectComponent("#Float").setNum(getApp().globalData.num)
+  },
 })

+ 56 - 23
packageA/market/index.js

@@ -1,6 +1,6 @@
 const _Http = getApp().globalData.http;
-let sys_enterpriseid = null;
 Page({
+
 	data: {
 		istool: 0, //0商品 1工具
 		brand: {}, //当前品牌
@@ -24,7 +24,9 @@ Page({
 			selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
 			value: "", //选中值
 			list: []
-		}]
+		}],
+		sys_enterpriseid: "",
+
 	},
 	onLoad(options) {
 		this.setData({
@@ -43,14 +45,30 @@ Page({
 		})
 		getApp().globalData.handleSelect = this.handleRole.bind(this);
 	},
-	handleRole(e) {
+	handleRole({
+		sys_enterpriseid,
+		enterprisename
+	}) {
+		console.log(sys_enterpriseid)
 		this.setData({
-			buttonText: e.enterprisename
+			buttonText: enterprisename,
+			tradefieid: "",
+			sys_enterpriseid
 		});
-		sys_enterpriseid = e.sys_enterpriseid;
 		this.getBrand();
+		this.getTradefie();
 		wx.navigateBack();
 	},
+	onCleaRole() {
+		this.setData({
+			buttonText: "",
+			sys_enterpriseid: ""
+		})
+		setTimeout(() => {
+			this.getTradefie();
+			this.getBrand();
+		}, 0)
+	},
 	/* 获取系统分类 */
 	getOptionTypeSelect() {
 		_Http.basic({
@@ -79,15 +97,18 @@ Page({
 	},
 	/* 获取领域 */
 	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": 20221223141802,
-			"content": {
-				"pageNumber": 1,
-				"pageSize": 9999,
-				"where": {
-					"condition": ""
-				}
-			}
+			content
 		}, false).then(res => {
 			console.log("获取领域", res)
 			if (res.msg != '成功') {
@@ -98,12 +119,21 @@ Page({
 					tradefield: "全部"
 				}]
 			} else {
-				res.data.unshift({
-					rowindex: 0,
-					subvalues: [],
-					sys_enterprise_tradefieldid: 0,
-					tradefield: "全部"
-				})
+				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: "",
@@ -138,9 +168,10 @@ Page({
 	/* 获取品牌 */
 	getBrand() {
 		let content = {
-			"pageSize": 999,
+			nocache: true,
+			pageSize: 999,
 		};
-		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
+		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;
 		_Http.basic({
 			"id": 20220924163702,
 			content
@@ -163,6 +194,7 @@ Page({
 				})
 				this.setData({
 					brandList: [],
+					loading: false,
 					list: [],
 					typeList: []
 				})
@@ -178,11 +210,12 @@ Page({
 	getTypeList() {
 		let content = {
 			sa_brandid: this.data.brand.sa_brandid,
+			nocache: true,
 			where: {
 				istool: 0, //默认0,不是工具,1表示工具
 			}
 		}
-		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
+		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;
 		_Http.basic({
 			"id": "20220922110403",
 			"pageSize": 1000,
@@ -212,13 +245,13 @@ Page({
 	/* 获取产品 */
 	getList(init = false) {
 		if (init.detail != undefined) init = init.detail;
-		let content = this.data.content;
+		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];
 		content.where.itemclassid = this.data.cType.itemclassid;
 		content.where.tradefield = this.data.tradefieid;
-		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
+		if (this.data.sys_enterpriseid) content.sys_enterpriseid = this.data.sys_enterpriseid;
 		_Http.basic({
 			"id": 20220926142203,
 			content

+ 36 - 24
packageA/market/index.scss

@@ -1,5 +1,41 @@
 @import "./index.skeleton.wxss";
 
+.role {
+	position: relative;
+	margin-top: -20rpx;
+
+	.clear {
+		position: absolute;
+		height: 38px;
+		line-height: 38px;
+		width: 32px;
+		z-index: 999;
+		top: 0;
+		right: 0;
+		color: #666666;
+		background-color: #fff;
+	}
+
+	.cell {
+		padding-top: 14rpx !important;
+		padding-bottom: 14rpx !important;
+	}
+
+	.cell-value {
+		font-size: 26rpx;
+		overflow: hidden;
+		white-space: nowrap;
+		text-overflow: ellipsis;
+		padding-left: 10rpx;
+		color: #333;
+	}
+}
+
+
+.title-value {
+	font-size: 26rpx;
+}
+
 .brand-box {
 	margin-left: 30rpx;
 	padding-bottom: 20rpx;
@@ -20,28 +56,4 @@
 .division {
 	height: 10rpx;
 	background-color: #F4F5F7;
-}
-
-
-.footer {
-	display: flex;
-	justify-content: center;
-	position: fixed;
-	bottom: 0;
-	width: 100vw;
-	min-height: 130rpx;
-	background-color: #fff;
-	box-shadow: rgba(0, 0, 0, 0.15) 0px 5rpx 15rpx 0px;
-	z-index: 999999999999999;
-
-	.but {
-		width: 690rpx;
-		height: 90rpx;
-		background: #FA8C16;
-		border-radius: 16rpx;
-		font-size: 28rpx;
-		font-weight: 600;
-		color: #FFFFFF;
-		margin-top: 10rpx;
-	}
 }

+ 11 - 9
packageA/market/index.wxml

@@ -1,24 +1,26 @@
 <!-- 骨架屏 -->
 <import src="./index.skeleton.wxml" />
 <template is="skeleton" wx:if="{{loading}}" />
-
 <Yl_HeadNav styleType="1" sort='{{content.sort}}' bindonSearch="onSearch" />
+<view class="role" wx:if="{{userrole=='业务员'}}">
+	<van-cell title-width='95' title="经销商/客户:" custom-class='cell' title-class='title-value' value-class='cell-value' is-link value="{{buttonText||'前去选择'}}" bindtap="selsectedRole" />
+	<view style="height: 8rpx; background-color: #fff;" />
+	<view wx:if="{{buttonText}}" class="clear" catchtap='onCleaRole'>
+		<van-icon name="clear" />
+	</view>
+</view>
 <!-- 领域列表 -->
-<Tabs list="{{tradefieList}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' name='tradefield' bind:onChange="tradefieChange" />
-
+<Tabs list="{{tradefieList}}" wx:if="{{tradefieList.length>1}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' name='tradefield' bind:onChange="tradefieChange" />
 <!-- 品牌列表 -->
-<Tabs list="{{brandList}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' bind:onChange="brandChange" />
+<Tabs list="{{brandList}}" wx:if="{{brandList.length>1}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' bind:onChange="brandChange" />
 <!-- 产品列表 -->
 <Tabs wx:for="{{typeList}}" active="{{item.active}}" wx:key="{{index}}" rowIndex="{{index}}" list="{{item.list}}" bind:onChange="typeChange" name='itemclassname' box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
 <view class="division" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
-	<List list="{{list}}" />
+	<List list="{{list}}" sys_enterpriseid='{{sys_enterpriseid}}' />
 	<view wx:if="{{userrole=='业务员'}}" style="height: 80rpx;" />
 </Yl_ListBox>
 <!-- 筛选条件 -->
 <Yl_Filtrate id='Filtrate' list="{{filter}}" bind:handle="handleFilter" dateRange='{{false}}' />
 <!-- 购物车按钮 -->
-<Float wx:if="{{userrole!='业务员'}}" id="Float" pageType="{{istool==0?'Standard':'Tool'}}" />
-<view wx:else class="footer">
-	<van-button custom-class='but' bindtap="selsectedRole">{{buttonText||"选择客户/经销商"}}</van-button>
-</view>
+<Float wx:if="{{userrole!='业务员'}}" id="Float" pageType="{{istool==0?'Standard':'Tool'}}" />

+ 2 - 1
packageA/market/modules/list/index.js

@@ -1,5 +1,6 @@
 Component({
   properties: {
-    list: Array
+    list: Array,
+    sys_enterpriseid: String
   }
 })

+ 1 - 1
packageA/market/modules/list/index.wxml

@@ -1,4 +1,4 @@
-<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}&itemno={{item.itemno}}&sa_brandid={{item.sa_brandid}}" wx:for="{{list}}" wx:key="index">
+<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}&itemno={{item.itemno}}&sa_brandid={{item.sa_brandid}}&sys_enterpriseid={{sys_enterpriseid}}" wx:for="{{list}}" wx:key="index">
 	<view class="image-box">
 		<van-image width="100%" wx:if="{{item.attinfos[0]||item.cover}}" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
 			<van-loading slot="loading" type="spinner" size="20" vertical />