twoMailbox.vue 5.4 KB
<template>
	<view class="twoMailbox">
		<!-- 校长信箱 -->
		<view class="tabs-wrap flex">
			<view class="tabs-item" :class="current==index?'tabs-active':''" v-for="(item,index) in tabs" :key="index"
				@tap="tabsClick(item,index)">
				{{item}}
			</view>
		</view>

		<!-- 校长私信 -->
		<template v-if="current==0">
			<view class="wrap area">
				<view class="textarea-wrap area">
					<view class="icon">
						<image src="/static/imagesV2/study/icon-edit.png"></image>
					</view>
					<textarea
						placeholder-style="font-size: 30rpx;font-family: PingFang SC;font-weight: 400;color: #B2B5BB;"
						placeholder="请输入你要发送的内容" v-model="message" maxlength="-1" />
				</view>
				<view class="btn" @click="sub_fuc">
					发送
				</view>
			</view>
		</template>

		<!-- 微信添加 -->
		<template v-if="current==1">
			<view class="wx-wrap area flex">
				<image class="code-img" :src="$service.getimg(codeImg)" mode="aspectFill"></image>
				<view class="wx-text">
					扫一扫 添加校长微信
				</view>
			</view>
		</template>


	</view>
</template>

<script>
	import Vue from 'vue'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	var that
	export default {
		data() {
			return {
				tabs: ['校长私信', '微信添加'],
				current: 0,
				message: '', //输入框内容
				codeImg: '', //校长微信二维码
				
			}
		},
		onLoad() {
			that=this
			that.getdata()
		},
		methods: {
			sub_fuc(){
				///study/letter_wx
				if(!that.message){
					uni.showToast({
						icon: 'none',
						title: '请输入你要发送的内容'
					})
					return
				}
				var datas = {
					message:that.message
				}
				var jkurl = '/study/letter'
							
				that.$service.P_post(jkurl, datas).then(res => {
					that.btnkg = 0
					console.log(res)
					if (res.code == 1) {
						that.htmlReset = 0
						var datas = res.data
						console.log(typeof datas)
						that.message=''
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
						setTimeout(function(){
							uni.navigateBack({
								delta:1
							})
						},1000)
						
						
					} else {
							
						if (res.msg) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取数据失败'
							})
						}
					}
				}).catch(e => {
					that.htmlReset = 1
					that.btnkg = 0
					// that.$refs.htmlLoading.htmlReset_fuc(1)
					console.log(e)
					uni.showToast({
						icon: 'none',
						title: '获取数据失败,请检查您的网络连接'
					})
				})
			},
			getdata(){
				///study/letter_wx
				var datas = {}
				var jkurl = '/study/letter_wx'
							
				that.$service.P_post(jkurl, datas).then(res => {
					that.btnkg = 0
					console.log(res)
					if (res.code == 1) {
						that.htmlReset = 0
						var datas = res.data
						console.log(typeof datas)
						that.codeImg=datas
					} else {
							
						if (res.msg) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取数据失败'
							})
						}
					}
				}).catch(e => {
					that.htmlReset = 1
					that.btnkg = 0
					// that.$refs.htmlLoading.htmlReset_fuc(1)
					console.log(e)
					uni.showToast({
						icon: 'none',
						title: '获取数据失败,请检查您的网络连接'
					})
				})
			},
			tabsClick(item, index) {
				this.current = index
			},
		}
	}
</script>

<style lang="scss" scoped>
	.twoMailbox {
		position: relative;
	}

	.tabs-wrap {
		height: 88rpx;
		justify-content: space-around;
		align-items: center;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #323232;
		background-color: #fff;
		border-top:1rpx solid #f3f4f6;
		.tabs-item {
			height: 100%;
			display: flex;
			align-items: center;
		}
		.tabs-active {
			color: #2D81FF;
			position: relative;
		}

		.tabs-active::after {
			content: '';
			position: absolute;
			left: 50%;
			bottom: 0rpx;
			transform: translate(-50%, 0);
			background-image: url(@/static/imagesV2/icon23.png);
			background-size: 100% 100%;
			height: 24rpx;
			width: 24rpx;
		}
	}

	.wrap {
		position: absolute;
		top: 120rpx;
		left: 50%;
		transform: translate(-50%, 0);
	}

	.textarea-wrap {
		height: 392rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 16rpx 20rpx;
		display: flex;
		.icon {
			width: 30rpx;
			height: 30rpx;
			margin-right: 10rpx;
			margin-top: 5rpx;
			image{
				height: 100%;
				width: 100%;
			}
		}
		textarea {
			width: 100%;
			height: 100%;
			font-size: 30rpx;
		}
	}

	.btn {
		width: 100%;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		background: #2D81FF;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		letter-spacing: 4rpx;
		margin-top: 42rpx;
	}

	// 微信添加
	.wx-wrap {
		height: 392rpx;
		border-radius: 10rpx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: absolute;
		top: 120rpx;
		left: 50%;
		transform: translate(-50%, 0);
		
		.code-img{
			width: 240rpx;
			height: 240rpx;
			border: 4rpx solid #A3C8FF;
			border-radius: 10rpx;
		}
		.wx-text{
			width: 310rpx;
			height: 64rpx;
			background: #2D81FF;
			border-radius: 32px;
			text-align: center;
			font-size: 26rpx;
			line-height: 64rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FEFEFE;
			margin-top: 50rpx;
		}

	}
</style>