stu_bz_index.vue 7.2 KB
<template>
	<view class="wrap_box">
		<view class="bz_box">
			<view class="bz_tab">
				<view v-for="(item,index) in tabs" :key="index" class="tab_li" :class="{active:active==item.id}" @click="setac_fuc(item.id)">
					{{item.title}}
				</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item,index) in datas" :key="index">
					<view class="item-remarks">
						{{item.content}}
					</view>
					<view class="item-footer">
						<view class="time">
							{{item.create_time}}
						</view>
						
						<view 
							class="btn" 
							@click="$service.jump" 
							:data-url="'/pagesA/stu_bz_edit/stu_bz_edit?id='+item.id+'&time='+item.create_time+'&content='+item.content">
							<view class="icon">
								<image src="/static/imagesV2/tch_index/icon11.png" mode=""></image>
							</view>
							修改
						</view>
						<view class="btn"  @click="showDelModal(item)">
							<view class="icon">
								<image src="/static/imagesV2/tch_index/icon12.png" mode=""></image>
							</view>
							删除
						</view>
					</view>
				</view>
				<view class="bz_li"  v-if="datas.length==0">
					<u-empty
						mode="data"
						text="暂无记录"
						icon="/static/images/tch/img_blank.png"
					>
					</u-empty>
				</view>
			</view>
			<view class="bz_add" >
				<view class="" @click="$service.jump" :data-url="'/pagesA/stu_bz_edit/stu_bz_edit?stu_id='+options.id">
					添加
				</view>
			</view>
			
			<u-modal 
				:show="show"
				title="提示"
				content="是否删除该备注?"
				@confirm="del_fuc(current)"
				@cancel="show = false"
				:asyncClose="true"
				:showCancelButton="true"
				>
			</u-modal>
			
		</view>
	</view>
</template>

<script>
	import Vue from 'vue'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	var that 
	export default {
		data() {
			return {
				options:'',
				datas:[
					1,1,1,1,1,1,1,1,1,1
				],
				tabs:[
					{
						title:'成绩变化',
						id:1
					},
					{
						title:'思想动态',
						id:2
					},
					{
						title:'生活',
						id:3
					},
				],
				active:1,
				show: false,
				current: null
			}
		},
		computed: {
		...mapState(['hasLogin', 'forcedLogin', 'userName', 'userinfo','nowtime']),
		},
		onLoad(e) {
			that=this
			that.options=e||{}
			console.log(e)
			
			
		},
		onShow() {
			that.onRetry()
		},
		onReachBottom() {
			that.getdata()
		},
		methods: {
			// ...mapMutations(['wxshouquan','login']),
			test(){},
			setac_fuc(index){
				that.active=index
				that.onRetry()
			},
			showDelModal(item) {
				this.show = true;
				this.current = item;
			},
			del_fuc(item){
				var datas={
					id: item.id
				}
				var jkurl='/teacher/remark_del'
				that.$service.P_post(jkurl, datas).then(res => {
					this.show = false;
					that.btnkg = 0
					console.log(res)
					if (res.code == 1) {
						that.htmlReset = 0
						var datas = res.data
						console.log(typeof datas)
				
						if (typeof datas == 'string') {
							datas = JSON.parse(datas)
						}
						console.log(res)
						uni.showToast({
							icon:'none',
							title:'删除成功'
						})
						setTimeout(function(){
							that.onRetry()
						},1000)
					} else {
					
						if (res.msg) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取数据失败'
							})
						}
					}
				}).catch(e => {
					this.show = false;
					that.htmlReset = 1
					that.btnkg = 0
					// that.$refs.htmlLoading.htmlReset_fuc(1)
					console.log(e)
					uni.showToast({
						icon: 'none',
						title: '获取数据失败,请检查您的网络连接'
					})
				})
			},
			onRetry(){
				that.page=1
				that.datas = []
				that.getdata()
			},
			getdata() {
			
				var jkurl="/teacher/remark"
				//类型1、成绩变化 2、思想动态 3、生活
				var datas={
					id:that.options.id,
					page:that.page,
					type:that.active
				}
				// if(that.data_last == true){
				// 	return
				// }
				if (that.btnkg == 1) {
					return
				} else {
					that.btnkg = 1
				}
				var page_now=that.page
				that.$service.P_post(jkurl, datas).then(res => {
					that.btnkg = 0
					console.log(res)
					if (res.code == 1) {
						var datas = res.data
						console.log(typeof datas)
				
						if (typeof datas == 'string') {
							datas = JSON.parse(datas)
						}
					
						if (page_now == 1) {
						
							that.datas = datas.data
						
						} else {
							if (datas.data.length == 0) {
								that.data_last = true
								return
							}
							that.data_last = false
							that.datas = that.datas.concat(datas.data)
						}
						that.page++
				
					} else {
						if (res.msg) {
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '操作失败'
							})
						}
					}
				}).catch(e => {
					that.btnkg = 0
					console.log(e)
					uni.showToast({
						icon: 'none',
						title: '操作失败'
					})
				})
			},
			
			getimg(img){
				return service.getimg(img)
			},
			jump(e) {
				var that = this
				if (that.btnkg == 1) {
					return
				} else {
					that.btnkg = 1
					setTimeout(function() {
						that.btnkg = 0
					}, 2000)
				}
				console.log(e.currentTarget.dataset.type)
				service.jump(e)
			},
			goback(){
			  uni.navigateBack()
			},
			func(){
				// that.$store.commit('setSystem',datas.system)
			}
		}
	}
</script>

<style lang="scss" scoped>
.wrap_box{
	width: 100%;
	// padding: 30rpx;
	min-height: 100vh;
	// #ifdef H5
	min-height: calc(100vh - 44px);
	// #endif
	background: #F8F8F8;
	position: relative;
	padding-bottom: 130rpx;
}

.bz_box{
	width: 100%;
	position: relative;
}
.bz_tab{
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-around;
	background-color: #fff;
	border-top:1rpx solid #f3f4f6;
}
.tab_li{
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 500;
	color: #323232;
	padding:30rpx;
	position: relative;
	&.active{
		color: #2D81FF;
		&:after{
			content: '';
			position: absolute;
			bottom: 8rpx;
			left: 50%;
			background-image: url(@/static/imagesV2/icon23.png);
			background-size: 100% 100%;
			transform: translateX(-50%);
			height: 24rpx;
			width: 24rpx;
		}
	}
}
.list{
	margin: 20rpx;
	.item {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		& + .item {
			margin-top: 20rpx;
		}
		&-remarks {
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #323232;
		}
		&-footer {
			display: flex;
			align-items: center;
			margin-top: 30rpx;
			.time {
				flex: 1;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
			}
			.btn {
				display: flex;
				align-items: center;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #646464;
				margin-left: 30rpx;
				.icon {
					margin-right: 10rpx;
					width: 30rpx;
					height: 30rpx;
				}
			}
		}
	}
}
.bz_add{
	width: 100%;
	position: fixed;
	bottom: 0;
	background: #fff;
	z-index: 800;
	left: 0;
	padding: 16rpx 26rpx;
	view {
		background: #2D81FF;
		border-radius: 44rpx;
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
	}
}
</style>