<template>
	<view :style="[mainStyle]">
		<view>
			<view class="gw-topbox">
				<view class="gw-title">添加官方客服微信~</view>
				<view class="gw-subtitle">了解更多</view>
				<view class="gw-header">
					<image :src="advisor.headUrl?advisor.headUrl:'/other/static/images/kefu.png'"></image>
				</view>
				<view class="gw-name">{{advisor.realName}}</view>
				<view class="ddflex" style="justify-content: center;" v-if="advisor&&advisor.label">
					<view class="gw-tag" v-for="item,index in advisor.label.split(',')" :key="index">{{item}}</view>
				</view>
				<view class="gw-add" v-for="item,index  in advisor.merchantTitle?advisor.merchantTitle.split(','):[]" :key="index">{{item}}</view>
				<view class="gw-text">{{sysConfig.contact_text?sysConfig.contact_text:''}}</view>
			</view>
			<view class="gw-line"></view>
			<view class="gw-bottombox">
				<image class="gw-wx" :src="advisor.wechatQrcode" show-menu-by-longpress="true"></image>
				<view class="gw-sm">1.长按扫码     2.添加微信</view>
			</view>
		</view>
		
		<view style="height: 110rpx;"></view>
		<view class="bot ddflex">
			<view class="b-btn fflex ddflex" @click="call(advisor.mobile)">
				<image src="../static/images/kf_icon3.png"></image>
				电话咨询
			</view>
		</view>
	</view>
</template>

<script>
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
const app = getApp();
export default {
	data() {
		return {
			mainStyle: app.globalData.mainStyle,
			goShare: false,
			isLogin: false,
			id: '',
			detaile: '',
			sysConfig: {},
			advisor:''
		};
	},
	onLoad(options) {
		this.id = options.id;
		// this.getDetail();
		this.getSysConfig();
		this.getAdvisor()
	},

	onShow() {},

	methods: {
		getAdvisor() {
			return new Promise((resolve, reject) => {
				req.getRequest('/api/distribution/advisorInfo', {}, data => {
					console.log('服务顾问==', data)
					this.advisor = data;
					resolve();
				})
			})
		},
		getDetail() {
			let that = this;
			let apiUrl = '/api/v3/sysUser/info';
			return new Promise((resolve,reject)=>{
				req.getRequest(apiUrl,{ id: that.id },async res => {
					that.detaile = res;
					resolve();
				},true);
			})
		},
		getSysConfig() {
			req.getRequest('/api/config', {}, json => {
				this.sysConfig = json;
			});
		},

		//预览图片
		previewImgss(url) {
			//预览合同图片
			var src = [];
			src.push(url);
			uni.previewImage({
				current: 0,
				urls: src
			});
		},

		saveImge(url) {
			req.saveImageToPhotosAlbum(url);
		},

		copy(number) {
			uni.setClipboardData({
				data: number,
				success: function(res) {
					uni.showToast({
						title: '复制成功'
					});
				}
			});
		},

		call(mobile) {
			if(!mobile) return false
			uni.makePhoneCall({
				phoneNumber: mobile
			});
		}
	}
};
</script>

<style>
@import './index.css';
</style>
