Browse Source

企业微信客服显示判断

baijunde 1 year ago
parent
commit
232cc9fe28
2 changed files with 34 additions and 27 deletions
  1. 33 11
      components/common/serviceWidget.vue
  2. 1 16
      pages/carInsure/entry.vue

+ 33 - 11
components/common/serviceWidget.vue

@@ -1,14 +1,14 @@
 <template>
 	<view>
 		<view id="_drag_button" class="drag" :style="'left: ' + left + 'px; top:' + top + 'px;'"
-			@touchmove.stop.prevent="touchmove" @touchend="touchend"
-			:class="{transition: isDock && !isMove }">
-			<image src="/static/img/customerService.png" mode="" style="width: 46px;height: 56px;"  @click.stop.prevent="click"></image>
-			<view class="wechat" @click="weChat">
+			@touchmove.stop.prevent="touchmove" @touchend="touchend" :class="{transition: isDock && !isMove }">
+			<image src="/static/img/customerService.png" mode="" style="width: 46px;height: 56px;"
+				@click.stop.prevent="click"></image>
+			<view class="wechat" @click="weChatService" v-if="isDisplay">
 				微信客服
 			</view>
 		</view>
-		
+
 	</view>
 </template>
 <script>
@@ -40,7 +40,9 @@
 				windowHeight: 0,
 				isMove: true,
 				edge: 10,
-				text: '按钮'
+				text: '按钮',
+				supportStaffUrl: '', //企业微信客服地址
+				isDisplay: null, //企业微信客服是否展示
 			}
 		},
 		mounted() {
@@ -84,11 +86,18 @@
 						this.top = this.windowHeight - this.height - this.edge;
 					}
 				}).exec();
-			}, 200)
-
+			}, 200);
+			this.getWechatData()
 		},
 		methods: {
-			weChat(){
+			//获取企业微信客服地址,是否展示
+			getWechatData(){
+				this.$http.get('/sys/qy/wechat/find/picture').then(res => {
+					this.supportStaffUrl = res.data.supportStaffUrl
+					this.isDisplay = res.data.display
+				})
+			},
+			weChat() {
 				this.$emit('weChatClick');
 			},
 			click() {
@@ -143,6 +152,18 @@
 				}
 
 			},
+			//点击跳转企业微信客服
+			weChatService() {
+				uni.share({
+					provider: "weixin",
+					openCustomerServiceChat: true,
+					customerUrl: this.supportStaffUrl, //企业微信地址
+					corpid: 'wwfe67d19509d43ec5', //企业id
+					success: (res) => {},
+					fail: (err) => {}
+				});
+			},
+
 		}
 	}
 </script>
@@ -168,7 +189,8 @@
 		&.transition {
 			transition: left .3s ease, top .3s ease;
 		}
-		.wechat{
+
+		.wechat {
 			width: 55%;
 			font-size: 30rpx;
 			line-height: 30rpx;
@@ -177,7 +199,7 @@
 			display: flex;
 			justify-content: center;
 			align-items: center;
-			background-color:#07c160 ;
+			background-color: #07c160;
 			color: #ffffff;
 			box-sizing: border-box;
 			border-radius: 10rpx;

+ 1 - 16
pages/carInsure/entry.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="page">
-		<service-widget @btnClick="btn_click" @weChatClick="weChatService"></service-widget>
+		<service-widget @btnClick="btn_click" ></service-widget>
 		<view class="banner mb-3" v-if="insuranceType==1">
 			<image src="/static/image/car-insure/carban.png" mode=""></image>
 		</view>
@@ -714,22 +714,7 @@
 					url: '/pages/chat/chat'
 				})
 			},
-			weChatService(){
-					this.$http.get('/sys/qy/wechat/find/picture').then(res => {
-						 uni.share({
-						 	provider: "weixin",
-						 	openCustomerServiceChat: true,
-						 	customerUrl: res.data.supportStaffUrl, //企业微信地址
-						 	corpid: 'wwfe67d19509d43ec5', //企业id
-						 	success: (res) => {
-						 	},
-						 	fail: (err) => {
-						 	}
-						 });
 
-
-					})
-			},
 			toggleSwitch() {
 				this.isActive = !this.isActive;
 			},