fix: 圈子权限调试
This commit is contained in:
parent
63c193cd88
commit
7403968e85
@ -80,116 +80,121 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import Nav from "@/components/NavBar.vue";
|
||||
import ChatFrame from "./components/ChatFrame.vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { sendMessage } from "@/api/circle";
|
||||
import { getCircleDetail, msgUnreadCount } from "@/api/circle";
|
||||
import useWebSocket from "./hooks/useWebSocket";
|
||||
import { useStore } from "vuex";
|
||||
import { ref } from "vue"
|
||||
import Nav from "@/components/NavBar.vue"
|
||||
import ChatFrame from "./components/ChatFrame.vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { sendMessage } from "@/api/circle"
|
||||
import { getCircleDetail, msgUnreadCount } from "@/api/circle"
|
||||
import useWebSocket from "./hooks/useWebSocket"
|
||||
import { useStore } from "vuex"
|
||||
|
||||
const active = ref(0);
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const sendTextLoading = ref(false);
|
||||
const content = ref("");
|
||||
const store = useStore();
|
||||
const active = ref(0)
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const sendTextLoading = ref(false)
|
||||
const content = ref("")
|
||||
const store = useStore()
|
||||
|
||||
const showNotice = ref(false); // 是否展示公告栏,同一个公告栏只展示一次
|
||||
const showNotice = ref(false) // 是否展示公告栏,同一个公告栏只展示一次
|
||||
const detail = ref({
|
||||
advisor: {},
|
||||
});
|
||||
})
|
||||
const queryCircleDetail = async () => {
|
||||
const ret = await getCircleDetail({ id: route.query.id });
|
||||
if (ret && ret.code === 0) {
|
||||
detail.value = ret.data;
|
||||
const key = `circleNotice-${detail.value.id}-${store.state.userInfo.userId}`;
|
||||
const storageCircleNotice = localStorage.getItem(key);
|
||||
if (!storageCircleNotice || storageCircleNotice !== detail.value.notice) {
|
||||
showNotice.value = true;
|
||||
localStorage.setItem(key, detail.value.notice);
|
||||
const ret = await getCircleDetail({ id: route.query.id })
|
||||
if (ret && ret.code == 0) {
|
||||
detail.value = ret.data
|
||||
const key = `circleNotice-${detail.value.id}-${store.state.userInfo.userId}`
|
||||
const storageCircleNotice = localStorage.getItem(key)
|
||||
if (
|
||||
detail.value.notice &&
|
||||
(!storageCircleNotice || storageCircleNotice !== detail.value.notice)
|
||||
) {
|
||||
showNotice.value = true
|
||||
localStorage.setItem(key, detail.value.notice)
|
||||
} else {
|
||||
showNotice.value = false;
|
||||
showNotice.value = false
|
||||
}
|
||||
} else if (ret && ret.code === 6013) {
|
||||
router.replace(`/circle?id=${route.query.id}`)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
queryCircleDetail();
|
||||
queryCircleDetail()
|
||||
|
||||
const privateNewMsg = ref({});
|
||||
const privateNewMsg = ref({})
|
||||
const privateMessage = (msg) => {
|
||||
console.log("privateMessage", msg);
|
||||
const body = JSON.parse(msg.body);
|
||||
const data = body.data;
|
||||
console.log("data", data);
|
||||
console.log("privateMessage", msg)
|
||||
const body = JSON.parse(msg.body)
|
||||
const data = body.data
|
||||
console.log("data", data)
|
||||
// interactiveType 交互类型:1群聊;2私聊;3会话消息
|
||||
if ([1].includes(body.type)) {
|
||||
privateNewMsg.value = data;
|
||||
privateNewMsg.value = data
|
||||
if (active.value !== 2) {
|
||||
privateMsgUnreadCount.value++;
|
||||
privateMsgUnreadCount.value++
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const newMsg = ref({}); // ws最新推送的消息
|
||||
const newMsg = ref({}) // ws最新推送的消息
|
||||
const chatMessage = (msg) => {
|
||||
const body = JSON.parse(msg.body);
|
||||
const data = body.data;
|
||||
console.log("data", data);
|
||||
const body = JSON.parse(msg.body)
|
||||
const data = body.data
|
||||
console.log("data", data)
|
||||
// interactiveType 交互类型:1群聊;2私聊;3会话消息
|
||||
if ([1].includes(body.type)) {
|
||||
newMsg.value = data;
|
||||
newMsg.value = data
|
||||
} else if (body.type === 6) {
|
||||
detail.value.interactiveStatus = data;
|
||||
detail.value.interactiveStatus = data
|
||||
} else if (body.type === 16) {
|
||||
// 隐藏用户昵称
|
||||
detail.value.showNickName = data;
|
||||
detail.value.showNickName = data
|
||||
} else if (body.type === 19) {
|
||||
// 隐藏圈子人数
|
||||
detail.value.showMemberCount = data;
|
||||
detail.value.showMemberCount = data
|
||||
}
|
||||
};
|
||||
}
|
||||
const { stompClient } = useWebSocket({
|
||||
id: route.query.id,
|
||||
privateMessage,
|
||||
chatMessage,
|
||||
});
|
||||
})
|
||||
|
||||
const sendMsg = async () => {
|
||||
let ret = await sendMessage({
|
||||
content: content.value,
|
||||
groupId: route.query.id,
|
||||
interactiveType: active.value === 2 ? 2 : 1,
|
||||
});
|
||||
})
|
||||
if (ret && ret.code === 0) {
|
||||
content.value = "";
|
||||
content.value = ""
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 获取私聊未读消息
|
||||
const privateMsgUnreadCount = ref();
|
||||
const privateMsgUnreadCount = ref()
|
||||
const getMsgUnreadCount = async () => {
|
||||
const lastId = localStorage.getItem(
|
||||
`privateMsgUnreadCount-${route.query.id}-${store.state.userInfo.userId}`
|
||||
);
|
||||
if (!lastId) return;
|
||||
)
|
||||
if (!lastId) return
|
||||
let ret = await msgUnreadCount({
|
||||
groupId: route.query.id,
|
||||
type: 5,
|
||||
lastId,
|
||||
});
|
||||
})
|
||||
if (ret && ret.code === 0) {
|
||||
privateMsgUnreadCount.value = ret.data;
|
||||
privateMsgUnreadCount.value = ret.data
|
||||
}
|
||||
};
|
||||
getMsgUnreadCount();
|
||||
}
|
||||
getMsgUnreadCount()
|
||||
|
||||
const changeTab = (tabName) => {
|
||||
if (tabName === 2) {
|
||||
privateMsgUnreadCount.value = 0;
|
||||
privateMsgUnreadCount.value = 0
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.set {
|
||||
|
||||
@ -8,72 +8,81 @@
|
||||
error-text="加载错误,请点击重新加载"
|
||||
@load="onLoad"
|
||||
>
|
||||
<CircleItem
|
||||
<CircleItem
|
||||
class="circle-item"
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
:item="item"/>
|
||||
:item="item"
|
||||
/>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps } from "vue";
|
||||
import { getCircleList } from "@/api/circle";
|
||||
import CircleItem from "./components/CircleItem.vue";
|
||||
import { ref, defineProps } from "vue"
|
||||
import { getCircleList } from "@/api/circle"
|
||||
import CircleItem from "./components/CircleItem.vue"
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
console.log(props);
|
||||
console.log(props)
|
||||
|
||||
const list = ref([]);
|
||||
const loading = ref(false);
|
||||
const loadError = ref(false);
|
||||
const finished = ref(false);
|
||||
const refreshing = ref(false);
|
||||
const current = ref(1);
|
||||
const list = ref([])
|
||||
const loading = ref(false)
|
||||
const loadError = ref(false)
|
||||
const finished = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const current = ref(1)
|
||||
|
||||
const onRefresh = () => {
|
||||
current.value = 1;
|
||||
current.value = 1
|
||||
// 清空列表数据
|
||||
finished.value = false;
|
||||
finished.value = false
|
||||
|
||||
// 重新加载数据
|
||||
// 将 loading 设置为 true,表示处于加载状态
|
||||
loading.value = true;
|
||||
onLoad();
|
||||
};
|
||||
loading.value = true
|
||||
onLoad()
|
||||
}
|
||||
const onLoad = async () => {
|
||||
// 异步更新数据
|
||||
let ret = await getCircleList({
|
||||
id: props.id,
|
||||
lastId: refreshing.value || !list.value.length
|
||||
lastId:
|
||||
refreshing.value || !list.value.length
|
||||
? ""
|
||||
: list.value[list.value.length - 1].id,
|
||||
lastPublishTime: refreshing.value || !list.value.length
|
||||
lastPublishTime:
|
||||
refreshing.value || !list.value.length
|
||||
? ""
|
||||
: list.value[list.value.length - 1].auditTime,
|
||||
lastWeight: refreshing.value || !list.value.length
|
||||
lastWeight:
|
||||
refreshing.value || !list.value.length
|
||||
? ""
|
||||
: list.value[list.value.length - 1].isRecommend,
|
||||
size: 10,
|
||||
});
|
||||
: list.value[list.value.length - 1].isRecommend,
|
||||
size: 10,
|
||||
})
|
||||
if (ret.code === 0) {
|
||||
if (refreshing.value) {
|
||||
list.value = [];
|
||||
refreshing.value = false;
|
||||
list.value = []
|
||||
refreshing.value = false
|
||||
}
|
||||
current.value++;
|
||||
list.value = list.value.concat(ret.data.list);
|
||||
finished.value = !ret.data.hasNext;
|
||||
current.value++
|
||||
list.value = list.value.concat(ret.data.list)
|
||||
finished.value = !ret.data.hasNext
|
||||
} else {
|
||||
loadError.value = true;
|
||||
loadError.value = true
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
loading.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped lang="scss">
|
||||
.circle-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -32,17 +32,11 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const toCircleDetail = () => {
|
||||
if (props.item.authorityId) {
|
||||
router.push(
|
||||
`/circle?id=${props.item.id}&saleUserId=${route.query.saleUserId || ""}`
|
||||
)
|
||||
} else {
|
||||
router.push(
|
||||
`/circle/interact?id=${props.item.id}&saleUserId=${
|
||||
route.query.saleUserId || ""
|
||||
}`
|
||||
)
|
||||
}
|
||||
router.push(
|
||||
`/circle/interact?id=${props.item.id}&saleUserId=${
|
||||
route.query.saleUserId || ""
|
||||
}`
|
||||
)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
const { defineConfig } = require("@vue/cli-service");
|
||||
const { VantResolver } = require("@vant/auto-import-resolver");
|
||||
const AutoImport = require("unplugin-auto-import/webpack");
|
||||
const Components = require("unplugin-vue-components/webpack");
|
||||
const fileanagerWebpackPlugin = require("filemanager-webpack-plugin");
|
||||
const path = require("path");
|
||||
const { defineConfig } = require("@vue/cli-service")
|
||||
const { VantResolver } = require("@vant/auto-import-resolver")
|
||||
const AutoImport = require("unplugin-auto-import/webpack")
|
||||
const Components = require("unplugin-vue-components/webpack")
|
||||
const fileanagerWebpackPlugin = require("filemanager-webpack-plugin")
|
||||
const path = require("path")
|
||||
|
||||
module.exports = defineConfig({
|
||||
publicPath: "/h5/",
|
||||
@ -34,13 +34,14 @@ module.exports = defineConfig({
|
||||
proxy: {
|
||||
"/app": {
|
||||
target: "http://8.138.144.54:8080",
|
||||
// target: "https://do.tgsys.sztg.com",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
chainWebpack: (config) => {
|
||||
// SVG 规则排除 icons 目录
|
||||
config.module.rule("svg").exclude.add(path.resolve("src/assets/icons"));
|
||||
config.module.rule("svg").exclude.add(path.resolve("src/assets/icons"))
|
||||
// 添加 icons 目录的 SVG loader
|
||||
config.module
|
||||
.rule("icons")
|
||||
@ -49,6 +50,6 @@ module.exports = defineConfig({
|
||||
.end()
|
||||
.use("svg-sprite-loader")
|
||||
.loader("svg-sprite-loader")
|
||||
.options({ symbolId: "icon-[name]" });
|
||||
.options({ symbolId: "icon-[name]" })
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user