examTeamApp/pages/notepad/notepad.vue

143 lines
3.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<view class="add" @click="handleAdd" v-if="token">+新增记事</view>
<view v-if="list.length" class="tipsList">
<view class="tips" v-for="(ite,ind) in list" :key="ind">
<view class="title">{{ite.recordtime}}</view>
<uni-swipe-action>
<uni-swipe-action-item :right-options="ite.options" @click="handledetail($event, ind)">
<view class="list">
<icon class="t-icon t-icon-a-ziyuan265"></icon>
<view class="info">
<view class="time">{{petInfo.name}}</view>
<text>记事内容</text>
<text>{{ite.content}}</text>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<view class="endtext" v-if="!lastPage || page >= lastPage">—— 到底了,看看别的吧 ——</view>
</view>
<view class="nolist mt-15" v-if="!lastPage">
<image src="../../static/none.png"></image>
<text>暂无数据</text>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
token: "",
list: [],
page: 1,
lastPage: 0,
}
},
computed: {
...mapState(["petList", "petInfo"]),
},
onShow() {
let that = this
that.page = 1
that.list = []
that.token = uni.getStorageSync("token")
},
onReachBottom() {
let that = this
if (!this.lastPage || this.page >= this.lastPage) {
uni.showToast({
title: '没有更多数据!',
icon: 'none'
})
return
}
this.page++
},
methods: {
getList(page) {
let that = this
that.$model.getNotepadList({
pageNo: this.page,
pageSize: 10,
petid: uni.getStorageSync('petid'),
}).then((res) => {
if (res.code != 0) return
this.list = this.list.concat(res.data.rows)
this.lastPage = res.data.totalpage
})
},
handledetail(e, index) {
let that = this
if (e.content.text === "删除") {
let id = that.list[index].id
uni.showModal({
title: '友情提示',
content: '确定删除该条记录吗?',
success: function(res) {
if (res.confirm) {
that.$model.getNotepadDelete({
id: id
}).then(res => {
if (res.code != 0) return
that.list.splice(index, 1)
that.$tools.msg("删除成功!");
})
} else if (res.cancel) {
that.$tools.msg("您已取消删除!");
}
}
});
return
}
},
handleAdd() {
uni.navigateTo({
url: "/pages/notepad/addNotepad"
})
},
}
}
</script>
<style lang="scss" scoped>
.add {
width: 100%;
text-align: center;
background: #fff;
height: 45px;
line-height: 45px;
border-radius: 5px;
font-weight: bold;
font-size: 16px;
}
.content {
padding: 15px
}
.info {
// height: 50px;
}
text {
margin-top: 3px !important;
width: auto !important;
font-size: 13px;
}
.nolist {
text {
margin: -15px auto 15px !important;
width: 100% !important;
}
}
</style>