<template>
	<view class="page">
		<navbar title="联系我们" leftClick @leftClick="$utils.navigateBack" />
		
		<!-- todo: check -->
		<view class="box">
			<view v-if="configList.wx_image">
				<image :src="configList.wx_image" mode="aspectFill"></image>
				<view class="uni-color-btn" @click="saveImage(configList.wx_image)">
					保存二维码
				</view>
			</view>
			
			<view v-if="configList.config_phone">
				全国联系电话：{{ configList.config_phone }}
				<view class="uni-color-btn" @click="onCall(configList.config_phone)">
					拨打电话
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			// 拨打电话
			onCall(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber,
					success() {
						console.log('安卓拨打成功');
					},
					fail() {
						console.log('安卓拨打失败');
					}
				})
			},
			saveImage(image){
				/* 获取图片的信息 */
				uni.getImageInfo({
					src: image,
					success: function(image) {
						/* 保存图片到手机相册 */
						uni.saveImageToPhotosAlbum({
							filePath: image.path,
							success: function() {
								uni.showModal({
									title: '保存成功',
									content: '图片已成功保存到相册',
									showCancel: false
								});
							},
							complete(res) {
								console.log(res);
							}
						});
					}
				});
			},
		}
	}
</script>

<style scoped lang="scss">
.page{
	.box{
		display: flex;
		justify-content: center;
		align-items: center;
		height: 70vh;
		flex-direction: column;
		gap: 40rpx;
		image{
			width: 400rpx;
			height: 400rpx;
		}
	}
}
</style>
