+
-
+
+
+
+
+
+
+
+ {{content.contact_way.type}}:
+ {{content.contact_way.content}}
+
+
复制
+
+
+
@@ -30,7 +51,7 @@ import FooterSpace from "@/components/FooterSpace.vue";
import InfoCard from "@/components/InfoCard.vue";
import Comment from "@/components/Comment.vue";
import { mapState, mapActions } from "vuex";
-import { login } from "@/axios/api.js";
+import { getLAFDetail, comment, delLAF } from "@/axios/api.js";
import { formatDateTime } from "@/lib/utils.js";
import { Loading } from "element-ui";
@@ -38,8 +59,14 @@ export default {
name: "LAFDetail",
data() {
return {
- content: {},
- show_footer: true
+ content: {
+ contact_way:{
+ type: 'none'
+ },
+ img_url:'no_img.png'
+ },
+ show_footer: true,
+ show_contact: false
};
},
computed: {
@@ -56,103 +83,232 @@ export default {
"setUserInfo",
"setCurrentWeek",
"setCurrentSchedule",
- "setPersonalized"
+ "setPersonalized",
+ "setLAFReflash"
]),
formatDateTime,
// 初始化
init() {
// let id = this.$route.params.item._id["$oid"];
- Object.keys(this.$route.params).length == 0;
+ // 防止本页刷新后丢失params导致渲染出错,直接返回上一级
if (Object.keys(this.$route.params).length == 0) {
this.$router.go(-1);
return;
}
- let id = this.$route.params.item._id;
- this.getPageData(id);
+ let id = this.$route.params.item._id["$oid"];
+ let type = this.$route.params.item.type
+ this.getPageData(id,type);
},
// 获取本页详情
- getPageData() {
- this.content = {
- // 数据库id
- _id: "100",
- // 标题
- title: "测试用文本",
- // 内容
- content: "不知道这是谁的本子,放120了",
- // 时间
- create_time: "1581152278111",
- // 图片
- img_url:
- "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3488199501,3589420970&fm=26&gp=0.jpg",
- // 区域
- total_addr: "南区",
- // 地点
- detail_addr: "南研1201",
- // 联系方式(可选)
- contact_way: { type: "QQ", content: "1144131090" },
- // 评论
- comment: [
-
- ]
- };
- this.addComment()
+ getPageData(id, type) {
+ let load = Loading.service({
+ background: "rgba(236,245,255,.7)",
+ target: document.querySelector(".LAFDetail")
+ });
+ let data = {
+ id,
+ type
+ }
+ getLAFDetail(data).then(res => {
+ // console.log(res)
+ if(res.data.errcode == 200) {
+ // 获取成功
+ this.content = JSON.parse(res.data.detail)
+ // console.log(this.content)
+ load.close()
+ } else {
+ // 获取失败
+ load.close()
+ this.$message.error("服务器开小差了,请过段时间重试");
+ console.log(res.data)
+ this.back()
+ }
+ }).catch(err => {
+ load.close()
+ this.$message.error("服务器开小差了,请过段时间重试");
+ console.log(err)
+ this.back()
+ })
},
back() {
this.$router.go(-1);
},
- addComment() {
- if (this.content.comment && this.content.comment.length!=0) return;
- console.log("加入commnet");
- this.content.comment = [
+
+ // 打开输入框
+ openInput(comment_index, reply_index) {
+ console.log(comment_index,reply_index)
+ this.show_footer = false
+ this.$prompt(
+ `请输入内容,为保证信息质量,该操作将实名制`,
+ "提示",
{
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg: "这可能是一个评论吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328",
- reply: [
- {
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg: "这可能就是一个回复吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328"
- },
- {
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg:
- "这可能就是一个回的空间看到就看见的空间的空间的接口对接复吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328"
- }
- ]
- },
- {
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg: "这可能是一个评论吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328",
- reply: [
- {
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg: "这可能就是一个回复吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328"
- },
- {
- user_avatar: "http://img02.fs.yiban.cn/16515387/avatar/user/200",
- msg: "这可能就是一个回复吧,应该就是了",
- user_nick: "英树",
- time: 1575256258182,
- cid: "170521328"
- }
- ]
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ inputPattern: /^[^\^\$\/\<\(\)]{3,}$/,
+ inputErrorMessage: "请勿输入特殊符号,至少3个字,"
}
- ];
- }
+ )
+ .then(({ value }) => {
+ this.show_footer = true
+ this.submit(comment_index, reply_index, value);
+ })
+ .catch(() => {
+ this.show_footer = true
+ this.$message({
+ type: "info",
+ message: "取消输入"
+ });
+ });
+ },
+ // 确认提交
+ submit(comment_index, reply_index, value) {
+ let load = Loading.service({
+ background: "rgba(236,245,255,.7)",
+ target: document.querySelector(".LAFDetail")
+ });
+ // 合成上传信息
+ // 数据一共需要提交 昵称 时间 cid 内容
+ // 此处内容需要根据是回复还是评论进行处理
+ var data = {
+ user_info: {
+ user_id: this.user_info.id,
+ user_name: this.user_info.name
+ },
+ time: new Date().getTime()
+ };
+ // 后端插入数据的定位信息 商品id 表类型 回复或者评论的类型
+ var position = {
+ id: this.content._id["$oid"],
+ type: this.content.type
+ };
+ if (comment_index == -1) {
+ // 留言
+ data.msg = value;
+ position.comment_type = 1;
+ } else {
+ // 回复
+ if (reply_index == -1) {
+ // 回复留言
+ data.msg = `@${this.content.comment[comment_index].user_info.user_name}:${value}`;
+ position.comment_index = comment_index;
+ position.comment_type = 2;
+ } else {
+ // 回复回复
+ data.msg = `@${this.content.comment[comment_index].reply[reply_index].user_info.user_name}:${value}`;
+ position.comment_index = comment_index;
+ position.comment_type = 2;
+ }
+ }
+ comment(data, position)
+ .then(res => {
+ console.log(res);
+ if (res.data.errcode == 200) {
+ // 提交成功, 刷新数据
+ load.close()
+ this.$message({
+ type: "success",
+ message: `${position.comment_type == 1 ? "留言" : "回复"}成功`
+ });
+ this.getPageData(this.content._id["$oid"], this.content.type);
+ } else {
+ // 错误处理
+ load.close()
+ this.$message.error(
+ `${position.comment_type == 1 ? "留言" : "回复"}失败,请重试`
+ );
+ }
+ })
+ .catch(err => {
+ load.close()
+ console.log(err);
+ this.$message.error(
+ `${position.comment_type == 1 ? "留言" : "回复"}失败,请重试`
+ );
+ });
+ },
+ // 打开删除对话窗
+ openDelLAF(){
+ this.show_footer = false
+ this.$prompt(
+ `此操作将删除该记录,此操作实名制,请输入你的学号`,
+ "警告",
+ {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ inputPattern: /\d{7}W?\d{2}/,
+ inputErrorMessage: "请输入正确的学号"
+ }
+ )
+ .then(({ value }) => {
+ this.show_footer = true
+ if(value == this.user_info.id) {
+ // 填入正确
+ this.closeLAF()
+ }else {
+ this.$message.error('输入学号有误请核对');
+ }
+ })
+ .catch(() => {
+ this.show_footer = true
+ this.$message({
+ type: "info",
+ message: "取消输入"
+ });
+ });
+ },
+ // 进行删除操作
+ closeLAF(){
+ let load = Loading.service({
+ background: "rgba(236,245,255,.7)",
+ target: document.querySelector(".LAFDetail")
+ });
+ let data = {
+ id: this.content._id["$oid"],
+ type: this.content.type,
+ user_info: {
+ user_id: this.user_info.id,
+ user_name: this.user_info.name
+ }
+ }
+ delLAF(data).then(res => {
+ if(res.data.errcode == 200) {
+ // 执行成功
+ load.close()
+ this.$message({
+ type: "success",
+ message: '恭喜,操作成功'
+ });
+ this.setLAFReflash(true)
+ this.back()
+ } else {
+ // 执行失败
+ load.close()
+ console.log(res.data)
+ this.$message.error('抱歉,操作失败');
+ this.setLAFReflash(true)
+ }
+ }).catch(err => {
+ // 执行失败
+ load.close()
+ console.log(err)
+ this.$message.error('抱歉,操作失败');
+ this.setLAFReflash(true)
+ })
+ },
+ // 打开联系发布者弹窗
+ openDialog() {
+ this.show_contact = true
+ },
+ // 关闭联系发布者弹窗
+ closeDialog() {
+ this.show_contact = false
+ },
+ onCopyUrl(e) {
+ this.$message.success("复制成功!");
+ },
+ onErrorUrl(e) {
+ this.$message.success("复制失败!");
+ },
},
created() {
// 刷新vuex
@@ -191,7 +347,7 @@ export default {
\ No newline at end of file
diff --git a/src/views/lostandfound/LostAndFound.vue b/src/views/lostandfound/LostAndFound.vue
index 8da217d..a2991ff 100644
--- a/src/views/lostandfound/LostAndFound.vue
+++ b/src/views/lostandfound/LostAndFound.vue
@@ -6,7 +6,7 @@
搜索
@@ -60,7 +61,8 @@ export default {
"current_week",
"current_schedule",
"personalized",
- "LAF_data"
+ "LAF_data",
+ 'LAF_reflash'
]),
},
methods: {
@@ -69,7 +71,8 @@ export default {
"setUserInfo",
"setCurrentWeek",
"setCurrentSchedule",
- "setLAFData"
+ "setLAFData",
+ "setLAFReflash"
]),
// 初始化
init() {
@@ -83,7 +86,7 @@ export default {
let now = new Date().getTime(); //毫秒级时间戳
if (
now - this.LAF_data.get_time < 1000 * 60 * 3 &&
- !this.need_reflash
+ !this.need_reflash && !this.LAF_reflash
) {
// 上次获取的的时间是3分钟之内且无需刷新
return;
@@ -94,15 +97,49 @@ export default {
target: document.querySelector(".laf")
});
getLAF().then(res => {
- console.log(res);
- let data = {
- lost: res.lost,
- found: res.found,
- get_time: new Date().getTime()
- };
- this.setLAFData(data);
+ console.log(res.data);
+ let data = res.data
+ let laf
+ if(data.lost.errcode == 200 && data.found.errcode == 200) {
+ // 成功获取到信息
+ laf = {
+ lost: JSON.parse(data.lost.arr),
+ found: JSON.parse(data.found.arr),
+ get_time: new Date().getTime()
+ }
+ console.log(laf)
+ if(this.need_reflash) {
+ this.$message({
+ message: "数据更新成功",
+ type: "success"
+ });
+ }
+ } else {
+ // 信息获取失败
+ laf = {
+ lost: [],
+ found: [],
+ get_time: new Date().getTime()
+ }
+ this.$message.error("数据更新失败,请联系管理员");
+ console.log(res.data)
+ }
+ this.setLAFData(laf);
+ this.setLAFReflash(false);
localStorage.setItem("storeState", JSON.stringify(this.$store.state));
this.need_reflash = false;
+ load.close()
+ }).catch(err => {
+ console.log(err)
+ laf = {
+ lost: [],
+ found: [],
+ get_time: new Date().getTime()
+ }
+ this.$message.error("网络连接失败,请联系管理员");
+ this.setLAFData(laf);
+ localStorage.setItem("storeState", JSON.stringify(this.$store.state));
+ this.need_reflash = true;
load.close()
});
},
@@ -118,7 +155,10 @@ export default {
this.need_reflash = true
this.getLAFData()
},
-
+ // 点击详情
+ goToAdd(){
+ this.$router.push('/lafadd')
+ }
},
created() {
this.$store.replaceState(
@@ -245,9 +285,10 @@ export default {
color: #989898;
font-size: 0.3rem;
}
- input {
+ input, p{
width: 100%;
height: 0.7rem;
+ line-height: .7rem;
border: none;
padding-left: 0.3rem;
font-size: 0.3rem;