cardDetail.vue 7.3 KB
<template>
	<view class="content">
		<view class="detail_top">
			<!-- 公司名称 -->
			<view class="company_name">{{ cardDetail.company_name }}</view>
			<!-- 名片正反面 -->
			<view> 
				<image class="card_pic" :src="cardDetail.front_image" mode=""></image>
				<view class="card_tips">名片正面</view>
			</view>
			<view>
				<image class="card_pic" :src="cardDetail.reverse_image" mode=""></image>
				<view class="card_tips">名片反面</view>
			</view>
		</view>
		<!-- 公司简介 -->
		<view class="company_intro">
			<view class="company_title_wrap"><view class="company_title">公司简介</view></view>
			<view class="company_detail">
				<view class="company_detail_box">
					<view class="">{{ cardDetail.brief }}</view>
					<view class="company_pic_wrap flex_wrap_no">
						<view class="company_pic_single" @click="showImg(item)" v-for="(item, index) in cardDetail.brief_images" :key="index"><image :src="item" mode=""></image></view>
					</view>
				</view>
			</view>
		</view>
		<!-- 经营范围 -->
		<view class="company_intro">
			<view class="company_title_wrap"><view class="company_title">经营范围</view></view>
			<view class="company_detail">
				<view class="company_detail_box">
					<view class="">{{ cardDetail.scope }}</view>
					<view class="company_pic_wrap flex_wrap_no">
						<view class="company_pic_single" @click="showImg(item)" v-for="(item, index) in cardDetail.scope_images" :key="index"><image :src="item" mode=""></image></view>
					</view>
				</view>
			</view>
		</view>
		<!-- 联系方式 -->
		<view class="company_intro">
			<view class="company_title_wrap"><view class="company_title">联系方式</view></view>
			<!-- 地址 -->
			<view class="contact_code">
				<view class="layer_nobetween">
					<!-- 二维码 -->
					<view class="qr_code" @click="showImg(cardDetail.wechat_image)"><image :src="cardDetail.wechat_image" mode=""></image></view>
					<!-- 姓名 地址 -->
					<view class="contact_r flex_star_between">
						<view class="">联系人:{{ cardDetail.name }}</view>
						<view class="" v-if="cardDetail.phone">电话:{{ cardDetail.phone }}</view>
						<view class="" v-if="cardDetail.site">地址:{{ cardDetail.site }}</view>
					</view>
				</view>
			</view>
			<!-- 各种联系方式 -->
			<view class="contact_single layer_between" v-if="cardDetail.fax">
				<view class="layer_between">
					<image class="contact_icon" src="../../static/phone.png" mode=""></image>
					传真
				</view>
				<view class="" @click="copyFax()">{{ cardDetail.fax }}</view>
			</view>
			<view class="contact_single layer_between" v-if="cardDetail.mobile">
				<view class="layer_between">
					<image class="contact_icon" src="../../static/tel.png" mode=""></image>
					手机号
				</view>
				<view class="" @click="callUp()">{{ cardDetail.mobile }}</view>
			</view>
			<view class="contact_single layer_between" v-if="cardDetail.qq">
				<view class="layer_between">
					<image class="contact_icon" src="../../static/qq.png" mode=""></image>
					QQ
				</view>
				<view class="" @click="copyQQ()">{{ cardDetail.qq }}</view>
			</view>
			<view class="contact_single no_bottom layer_between" v-if="cardDetail.wechat">
				<view class="layer_between">
					<image class="contact_icon" src="../../static/weixin.png" mode=""></image>
					微信
				</view>
				<view class="" @click="copyWx()">{{ cardDetail.wechat }}</view>
			</view>
		</view>
		<!-- 图片放大 -->
		<view class="tx_mask" v-if="isShowImg" @click="closDialog()"></view>
		<view class="mask_content" v-if="isShowImg" @click="closDialog()" @longpress="saveImg()">
			<image :src="img" mode="widthFix"></image>
		</view>
		<!-- 收藏按钮 -->
		<view class="collect_btn" @click="collectCard()">{{cardDetail.is_collect == 1?"取消收藏":"收藏名片"}}</view>
	</view>
</template>

<script>
import App from '../../App.vue';
export default {
	data() {
		return {
			id: '',
			imgList: [],
			cardDetail: '',
			token: '',
			// 图片放大
			isShowImg:false,
			img:"",
		};
	},
	methods: {
		// 图片放大
		showImg(img){
			
			this.isShowImg = true
			this.img = img;
			
		},
		saveImg(){
			let t = this ;
			uni.downloadFile({
				url: t.img,
				success: function(res) {
					uni.saveImageToPhotosAlbum({
						filePath: res.tempFilePath,
						success: function() {
							uni.showToast({
								title: '保存成功',
								icon: 'none',
								duration: 1500
							});
							t.isShowImg = false
						},
						fail: function(err) {
							if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg ===
								"saveImageToPhotosAlbum:fail:auth denied") {
								uni.showToast({
									title: '需要您授权保存相册',
									icon:none,
									duration: 1500,
									success: modalSuccess => {
										uni.openSetting({
											success(settingdata) {
												if (settingdata.authSetting['scope.writePhotosAlbum']) {
													uni.showToast({
														title: '获取权限成功',
														icon: 'none',
														duration: 1500
													});
												} else {
													uni.showToast({
														title: '获取权限失败',
														icon: 'none',
														duration: 1500
													});
												}
											},
											fail(failData) {
												console.log("failData", failData)
											},
											complete(finishData) {
												console.log("finishData", finishData)
											}
										})
									}
								})
							}
						},
					});
				}
			});
		},
		closDialog(){
			this.isShowImg = false
		},
		// 名片详情
		getCarDetail() {
			let t = this;
			let url = '/api/goods/goods_detail';
			let params = {
				goods_id: this.id
			};
			App.post(url, params).then(res => {
				this.cardDetail = res;
			});
		},
		// 复制传真
		copyFax() {
			uni.setClipboardData({
				data: this.cardDetail.fax,
				success: function() {
					uni.showToast({
						title: '复制成功',
						icon: 'success'
					});
				}
			});
		},
		// 复制qq
		copyQQ() {
			uni.setClipboardData({
				data: this.cardDetail.qq,
				success: function() {
					uni.showToast({
						title: '复制成功',
						icon: 'success'
					});
				}
			});
		},
		// 复制微信
		copyWx() {
			uni.setClipboardData({
				data: this.cardDetail.wechat,
				success: function() {
					uni.showToast({
						title: '复制成功',
						icon: 'success'
					});
				}
			});
		},
		// 拨打电话
		callUp() {
			uni.makePhoneCall({
				phoneNumber: this.cardDetail.mobile
			});
		},
		// 收藏名片
		collectCard() {
			if (this.token) {
				let url = '/api/collect/collect';
				let params = {
					goods_id:this.id
				};
				App.post(url,params)
				.then(res=>{
					uni.showToast({
						title:'操作成功',
						icon:'success',
						duration:1500
					})
					setTimeout(function(){
						uni.navigateBack({
							delta:1
						})
					},1500)
					
				})
			} else {
				uni.navigateTo({
					url: '/pages/start/start'
				});
			}
		}
	},
	onLoad(option) {
		this.token = uni.getStorageSync('token');
		this.id = option.id;
		// 获取名片详情
		this.getCarDetail();
	},
	
	onShareAppMessage: function (res) {
	    var that = this;
	   
	   
	        // 来自页面内转发按钮
	        return {
	          title: '分享',
	          path: "/pages/index/cardDetail?id="+that.id
	          
	        }
	      
	  }

};
</script>

<style>
@import url('../../style/cardDetail');
</style>