Commit c018a133 by 胡悦

提交服务中心置顶和详情

1 parent 41e911f6

2.61 MB | W: | H:

2.61 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template> <template>
<view> <view>
<ServiceList @handleClick="handleClick" /> <ServiceList :topListProp="topList" @handleClick="handleClick" />
</view> </view>
</template> </template>
<script> <script>
...@@ -12,9 +12,14 @@ export default { ...@@ -12,9 +12,14 @@ export default {
}, },
data() { data() {
return { return {
topList: []
} }
}, },
created() {
uni.$on('messageBackHome', (topList) => {
this.topList = topList
})
},
methods: { methods: {
handleClick(item) { handleClick(item) {
const { moduleType } = item const { moduleType } = item
......
...@@ -17,11 +17,16 @@ ...@@ -17,11 +17,16 @@
{{ messageInfo.polishContent }} {{ messageInfo.polishContent }}
</view> </view>
</view> </view>
<view class="detail-footer" v-if="messageInfo.status == 0"> <view class="detail-footer">
<template v-if="messageInfo.status == 0">
<view class="tips">以上内容请认真阅读,至少读完{{ countTime }}分钟,如未按照要求阅读完内容,今日无法使用pad接待</view> <view class="tips">以上内容请认真阅读,至少读完{{ countTime }}分钟,如未按照要求阅读完内容,今日无法使用pad接待</view>
<view :class="['btn', !countFlag ? '' : 'blue']" @click="handleCompleted">已完成阅读 {{ !countFlag ? <view :class="['btn', !countFlag ? '' : 'blue']" @click="handleCompleted">已完成阅读 {{ !countFlag ?
`${countdown}s` : `${countdown}s` :
'' }}</view> '' }}</view>
</template>
<template v-if="pageType == 'service'">
<view class="btn blue more-script" @click="handleMoreScript">更多话术</view>
</template>
</view> </view>
</view> </view>
</view> </view>
...@@ -43,7 +48,8 @@ export default { ...@@ -43,7 +48,8 @@ export default {
enterTime: '', enterTime: '',
isProcessing: false, isProcessing: false,
MOCKDATA: {}, MOCKDATA: {},
countTime: 0 countTime: 0,
pageType: ''
} }
}, },
computed: { computed: {
...@@ -65,6 +71,7 @@ export default { ...@@ -65,6 +71,7 @@ export default {
// 进入埋点的时间 // 进入埋点的时间
this.enterTime = dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss") this.enterTime = dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
this.messageInfo = JSON.parse(row) this.messageInfo = JSON.parse(row)
this.pageType = options.type
}, },
beforeDestroy() { beforeDestroy() {
if (timer) { if (timer) {
...@@ -141,7 +148,11 @@ export default { ...@@ -141,7 +148,11 @@ export default {
} }
} }
}, },
handleMoreScript() {
uni.redirectTo({
url: '/pages/common/messageList'
});
}
} }
} }
</script> </script>
...@@ -306,5 +317,8 @@ export default { ...@@ -306,5 +317,8 @@ export default {
opacity: 1; opacity: 1;
} }
} }
.more-script {
margin-bottom: toRpx(48);
}
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<view class="message-index-box"> <view class="message-index-box">
<view class="message-list"> <view class="message-list" v-if="getTopList.length > 0">
<view :class="['message-item', moduleType == i.moduleType ? 'active' : '']" v-for="(i, ind) in getTopList" :key="ind" @click.stop="handleClick(i)"> <view :class="['message-item', moduleType == i.moduleType ? 'active' : '']" v-for="(i, ind) in getTopList" :key="ind" @click.stop="handleClick(i)">
<view class="message-item-icon"> <view class="message-item-icon">
<view :class="['sprite-icon', `icon-${moduleIconEnum[i.moduleType]}`]"></view> <view :class="['sprite-icon', `icon-${moduleIconEnum[i.moduleType]}`]"></view>
...@@ -55,6 +55,10 @@ export default { ...@@ -55,6 +55,10 @@ export default {
moduleType: { moduleType: {
type: [Number, String, null], type: [Number, String, null],
default: null default: null
},
topListProp: {
type: Array,
default: () => []
} }
}, },
data() { data() {
...@@ -62,7 +66,7 @@ export default { ...@@ -62,7 +66,7 @@ export default {
moduleTypeEnum, moduleTypeEnum,
moduleIconEnum, moduleIconEnum,
moduleContentEnum, moduleContentEnum,
topList: [1], topList: [],
msgList: [ msgList: [
{ {
moduleType: 3, moduleType: 3,
...@@ -102,10 +106,21 @@ export default { ...@@ -102,10 +106,21 @@ export default {
] ]
} }
}, },
watch: {
topListProp: {
handler(newVal) {
this.topList = newVal
},
immediate: true
}
},
computed: { computed: {
getTopList() { getTopList() {
if (!this.topList) return []; if (!this.topList) return [];
return this.msgList.filter(item => this.topList.includes(item.moduleType)); // 按topList中的倒序排列
return this.topList.slice().reverse().map(type =>
this.msgList.find(item => item.moduleType === type)
).filter(Boolean);
}, },
getList() { getList() {
// 过滤掉topList中包含moduleType的对象 // 过滤掉topList中包含moduleType的对象
...@@ -132,7 +147,16 @@ export default { ...@@ -132,7 +147,16 @@ export default {
})); }));
} }
}, },
created() {
this.getTopInfo()
},
methods: { methods: {
getTopInfo() {
const {phone, shopMerchantId, sceneType} = uni.$storage.get('userInfo')
const _topInfo = uni.$storage.get('noticeTopInfo') || {}
const key = `${phone}-${shopMerchantId}-${sceneType}`
this.topList = _topInfo[key] || []
},
formatTime(time) { formatTime(time) {
return dayjs(time).format('HH:mm'); return dayjs(time).format('HH:mm');
}, },
......
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
</view> </view>
<view class="detail-content"> <view class="detail-content">
<view class="detail-left"> <view class="detail-left">
<ServiceList :moduleType="moduleType" @handleClick="handleClick" /> <ServiceList :moduleType="moduleType" :topListProp="topList" @handleClick="handleClick" />
</view> </view>
<view class="detail-right"> <view class="detail-right">
<view class="common-title"> <view class="common-title">
<view>{{ moduleTypeEnum[moduleType] }}</view> <view>{{ moduleTypeEnum[moduleType] }}</view>
<view class="stick-top"> <view class="stick-top" @click="handleStickTop">
<view class="sprite-icon icon-stick-top-blue"></view> <view class="sprite-icon icon-stick-top-blue"></view>
{{ topList.includes(Number(moduleType)) ? '取消置顶' : '置顶' }} {{ topList.includes(Number(moduleType)) ? '取消置顶' : '置顶' }}
</view> </view>
</view> </view>
<scroll-view scroll-y class="service-list" @scrolltolower="pageonReachBottom" :scroll-top="scrollTop"> <scroll-view scroll-y class="service-list" @scrolltolower="pageonReachBottom" :scroll-top="scrollTop">
<view class="service-item" v-for="(item, index) in list" :key="index"> <view class="service-item" v-for="(item, index) in list" :key="index" @click="handleDetail(item)">
<view class="service-item-title">{{ moduleTypeEnum[moduleType] }} <view class="service-item-title">{{ moduleTypeEnum[moduleType] }}
<view class="service-item-title-right"> <view class="service-item-title-right">
<view>查看详情</view> <view>查看详情</view>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</view> </view>
</template> </template>
<script> <script>
const PAGE_SIZE = 5 const PAGE_SIZE = 10
const PAGE_NUM = 1 const PAGE_NUM = 1
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { moduleTypeEnum, moduleContentEnum } from './components/contant' import { moduleTypeEnum, moduleContentEnum } from './components/contant'
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
moduleTypeEnum, moduleTypeEnum,
moduleContentEnum, moduleContentEnum,
moduleType: null, moduleType: null,
topList: [1], topList: [],
scriptList: [], scriptList: [],
earlyWarnList: [], earlyWarnList: [],
systemList: [], systemList: [],
...@@ -67,7 +67,8 @@ export default { ...@@ -67,7 +67,8 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
scrollTop: 0, scrollTop: 0,
isLoading: false isLoading: false,
userInfo: {}
} }
}, },
computed: { computed: {
...@@ -104,13 +105,25 @@ export default { ...@@ -104,13 +105,25 @@ export default {
} }
}, },
created() { created() {
console.log(this.$route.query.moduleType) this.userInfo = uni.$storage.get('userInfo')
this.getTopInfo()
this.moduleType = Number(this.$route.query.moduleType) this.moduleType = Number(this.$route.query.moduleType)
// this.handleClick({moduleType: this.moduleType}) // this.handleClick({moduleType: this.moduleType})
}, },
methods: { methods: {
// 获取缓存中置顶的列表
getTopInfo() {
const {phone, shopMerchantId, sceneType} = this.userInfo
const _topInfo = uni.$storage.get('noticeTopInfo') || {}
const key = `${phone}-${shopMerchantId}-${sceneType}`
this.topList = _topInfo[key] || []
},
backPage() { backPage() {
uni.navigateBack() uni.navigateBack({
success: (res) => {
uni.$emit('messageBackHome', this.topList)
}
});
}, },
handleClick(item) { handleClick(item) {
// 如果点击的是同一个模块类型,则不进行操作 // 如果点击的是同一个模块类型,则不进行操作
...@@ -260,6 +273,81 @@ export default { ...@@ -260,6 +273,81 @@ export default {
} else { } else {
this.nothing = true; this.nothing = true;
} }
},
// 查看详情
async handleDetail(item) {
console.log(item, this.moduleType)
const {moduleType} = this
switch (moduleType) {
case 0:
console.log('企业消息跳转')
const res = await uni.$api.commonApi.getTaskById({ id: item.id })
const _row = encodeURIComponent(JSON.stringify(res))
if (res.contentType == 1) {
uni.navigateTo({
url: `/pages/common/systemDetail?row=${_row}`
})
} else if (res.contentType == 2) {
console.log(JSON.parse(res.content))
const _content = res.content ? JSON.parse(res.content) : []
const url = _content[0]
const { content, title, id } = res
uni.navigateTo({
// url: `/pages/common/msgwebview?url=${url}&title=${title}&id=${id}`
url: `/pages/common/imgPreview?tabName=${title}&sourceType=2&detailUrl=${url}&row=${_row}`
})
} else if (res.contentType == 3) {
const _content = res.content ? JSON.parse(res.content) : []
const url = _content[0].image
const { content, title, id } = res
uni.navigateTo({
url: `/pages/common/msgwebview?fileUrl=${url}&title=${title}&id=${id}&row=${_row}`
})
}
break
case 1:
console.log('优秀话术跳转')
uni.navigateTo({
url: `/pages/common/messageDetail?row=${encodeURIComponent(JSON.stringify(item))}&type=service`,
fail: (err) => {
console.error('页面跳转失败:', err);
}
});
break
case 2:
console.log('违规话术跳转')
uni.navigateTo({
url: `/pages/common/earlyWarnDetail?row=${encodeURIComponent(JSON.stringify(item))}`,
fail: (err) => {
console.error('页面跳转失败:', err);
}
});
break
case 3:
console.log('短课程学习跳转')
break
case 4:
console.log('长课程学习跳转')
break
default:
break
}
},
// 置顶,取消置顶
handleStickTop() {
console.log('置顶')
const {phone, shopMerchantId, sceneType} = this.userInfo
const _topInfo = uni.$storage.get('noticeTopInfo') || {}
const key = `${phone}-${shopMerchantId}-${sceneType}`
let _topList = _topInfo[key] || []
if (_topList.includes(this.moduleType)) {
_topList = _topList.filter(item => item !== this.moduleType)
} else {
_topList.push(this.moduleType)
}
_topInfo[key] = _topList
this.topList = _topList
uni.$storage.set('noticeTopInfo', _topInfo)
} }
} }
} }
......
...@@ -41,5 +41,5 @@ export const STORAGE_OBJECTKEY = { ...@@ -41,5 +41,5 @@ export const STORAGE_OBJECTKEY = {
recordTrackList: 'recordTrackList', recordTrackList: 'recordTrackList',
beisenToken: 'beisenToken', beisenToken: 'beisenToken',
messagePopShownDate: 'messagePopShownDate', messagePopShownDate: 'messagePopShownDate',
noticeTopList: 'noticeTopList' noticeTopInfo: 'noticeTopInfo'
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!