zhaoyun 2 долоо хоног өмнө
parent
commit
41d5bcbb32

+ 49 - 1
mer_uniapp/pages/user/index.vue

@@ -100,6 +100,16 @@
 					</div>
 				</div>
 			</view>
+		    <!-- 商家管理 -->
+		    <view class="item-features" v-if="isLogin && isEmployee">
+		    	<view class="item-features-title">店铺管理</view>
+		    	<view class="list-box">
+		    		<view class="item" @click="toggle('bottom')">
+		    			<image :src="urlDomain+'crmebimage/presets/adminImg/sjgl.png'"></image>
+		    			<text>商家管理</text>
+		    		</view>
+		    	</view>
+		    </view>
 		</view>
 	</view>
 </template>
@@ -126,7 +136,7 @@
 	} from '@/config/cache';
 	import animationType from '@/utils/animationType.js'
 	export default {
-		computed: mapGetters(['isLogin']),
+		computed: mapGetters(['isLogin','merchantEmployeeList', 'isEmployee', 'selectMerId']),
 		data() {
 			return {
 				statusBarHeight: app.globalData.statusBarHeight,
@@ -250,9 +260,36 @@
 			if (this.isLogin) {
 				this.getUserCenterInfo();
 				this.getOrderData();
+				this.getMerchantList();
 			}
 		},
 		methods: {
+			toggle(type) {
+				if (this.merchantEmployeeList.length == 1) {
+					merchantActive(this.merchantEmployeeList[0].merId).then(res => {
+						this.$store.commit('SetSelectMerId', this.merchantEmployeeList[0].merId);
+						this.$store.commit('SetSelectMerchantRole', this.merchantEmployeeList[0].role);
+						this.$store.commit('SET_MANAGER_TOKEN', {
+							managerToken: res.data.token
+						});
+						Cache.set('electrPrintingSwitch', res.data.electrPrintingSwitch);
+						uni.navigateTo({
+							url: '/pages/admin/work/index'
+						})
+						return
+					})
+					return
+				}
+				if (this.selectMerId) {
+					uni.navigateTo({
+						url: '/pages/admin/work/index'
+					})
+				} else {
+					this.type = type
+					// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
+					this.$refs.popup.open(type)
+				}
+			},
 			getOrderData() {
 				let that = this;
 				orderNum().then(res => {
@@ -294,6 +331,17 @@
 					// this.showSkeleton = false;
 				});
 			},
+			//获取商户列表
+			getMerchantList() {
+				let that = this
+				MerchantBelongListApi().then(res => {
+					if (this.selectMerId) {
+						let flag = res.data.find(item => item.merId === this.selectMerId);
+						!flag && that.$store.commit('CLEAR_SELECTMERID');
+					}
+					this.$store.commit("SetMerchantEmployeeList", res.data);
+				})
+			},
 			menusTap(url) {
 				if (!this.isLogin) {
 					this.openAuto();