uni-popup-share.vue 3.8 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2
<template>
	<view class="uni-popup-share">
study夏羽's avatar
study夏羽 已提交
3
		<view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
study夏羽's avatar
study夏羽 已提交
4 5 6 7 8 9 10 11 12 13
		<view class="uni-share-content">
			<view class="uni-share-content-box">
				<view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
					<image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
					<text class="uni-share-text">{{item.text}}</text>
				</view>

			</view>
		</view>
		<view class="uni-share-button-box">
study夏羽's avatar
study夏羽 已提交
14
			<button class="uni-share-button" @click="close">{{cancelText}}</button>
study夏羽's avatar
study夏羽 已提交
15 16 17 18 19 20
		</view>
	</view>
</template>

<script>
	import popup from '../uni-popup/popup.js'
study夏羽's avatar
study夏羽 已提交
21 22 23 24 25
	import {
	initVueI18n
	} from '@dcloudio/uni-i18n'
	import messages from '../uni-popup/i18n/index.js'
	const {	t	} = initVueI18n(messages)
study夏羽's avatar
study夏羽 已提交
26 27 28
	export default {
		name: 'UniPopupShare',
		mixins:[popup],
study夏羽's avatar
study夏羽 已提交
29
		emits:['select'],
study夏羽's avatar
study夏羽 已提交
30 31 32
		props: {
			title: {
				type: String,
study夏羽's avatar
study夏羽 已提交
33
				default: ''
study夏羽's avatar
study夏羽 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
			},
			beforeClose: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				bottomData: [{
						text: '微信',
						icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/c2b17470-50be-11eb-b680-7980c8a877b8.png',
						name: 'wx'
					},
					{
						text: '支付宝',
						icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/d684ae40-50be-11eb-8ff1-d5dcf8779628.png',
						name: 'wx'
					},
					{
						text: 'QQ',
						icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/e7a79520-50be-11eb-b997-9918a5dda011.png',
						name: 'qq'
					},
					{
						text: '新浪',
						icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/0dacdbe0-50bf-11eb-8ff1-d5dcf8779628.png',
						name: 'sina'
					},
study夏羽's avatar
study夏羽 已提交
62 63 64 65 66 67 68 69 70 71
					// {
					// 	text: '百度',
					// 	icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
					// 	name: 'copy'
					// },
					// {
					// 	text: '其他',
					// 	icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
					// 	name: 'more'
					// }
study夏羽's avatar
study夏羽 已提交
72 73 74 75
				]
			}
		},
		created() {},
study夏羽's avatar
study夏羽 已提交
76 77 78 79 80 81 82 83
		computed: {
			cancelText() {
				return t("uni-popup.cancel")
			},
		shareTitleText() {
				return this.title || t("uni-popup.shareTitle")
			}
		},
study夏羽's avatar
study夏羽 已提交
84 85 86 87 88 89 90 91 92 93
		methods: {
			/**
			 * 选择内容
			 */
			select(item, index) {
				this.$emit('select', {
					item,
					index
				})
				this.close()
study夏羽's avatar
study夏羽 已提交
94

study夏羽's avatar
study夏羽 已提交
95 96 97 98 99 100 101 102 103 104 105
			},
			/**
			 * 关闭窗口
			 */
			close() {
				if(this.beforeClose) return
				this.popup.close()
			}
		}
	}
</script>
study夏羽's avatar
study夏羽 已提交
106
<style lang="scss" >
study夏羽's avatar
study夏羽 已提交
107 108
	.uni-popup-share {
		background-color: #fff;
study夏羽's avatar
study夏羽 已提交
109 110
		border-top-left-radius: 11px;
		border-top-right-radius: 11px;
study夏羽's avatar
study夏羽 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
	}
	.uni-share-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		height: 40px;
	}
	.uni-share-title-text {
		font-size: 14px;
		color: #666;
	}
	.uni-share-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding-top: 10px;
	}

	.uni-share-content-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		width: 360px;
	}

	.uni-share-content-item {
		width: 90px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		padding: 10px 0;
		align-items: center;
	}

	.uni-share-content-item:active {
		background-color: #f5f5f5;
	}

	.uni-share-image {
		width: 30px;
		height: 30px;
	}

	.uni-share-text {
		margin-top: 10px;
		font-size: 14px;
		color: #3B4144;
	}

	.uni-share-button-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		padding: 10px 15px;
	}

	.uni-share-button {
		flex: 1;
		border-radius: 50px;
		color: #666;
		font-size: 16px;
	}

	.uni-share-button::after {
		border-radius: 50px;
	}
</style>