list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <scroll-view scroll-y="true" :scroll-into-view="scrollViewId" @scrolltoupper="onScrollTop" style="height: 100vh;">
  3. <view class="message-list-page">
  4. <view class="list">
  5. <view class="message-item" v-for="item in list" :key="item.Id" :id="`msg${item.Id}`">
  6. <view class="top-time-box white-wrap">{{item.msgTime}}</view>
  7. <view class="flex">
  8. <image :src="avatar" mode="aspectFill" style="width: 88rpx;height: 88rpx;"></image>
  9. <view class="message-content">
  10. <view style="color:#666;font-size: 12px;">小助手</view>
  11. <view class="message-card white-wrap" @click="handleGoDetail(item)">
  12. <!-- 问答 -->
  13. <template v-if="type === 5">
  14. <view class="title">{{item.ApprovalInfo.Title}}</view>
  15. <view class="info">提问人:{{item.ApprovalInfo.ApplyName}}</view>
  16. <view class="info">提问时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  17. <image src="@/static/icon-distribute.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  18. </template>
  19. <!-- 评论 -->
  20. <!-- 由于问答评论和视频社区的评论都在一个入口所以根据list返回数据的sourceType来区分 6:问答社区 7:视频社区 -->
  21. <template v-else-if="type === 6">
  22. <template v-if="item.SourceType===6">
  23. <view class="title">{{item.ApprovalInfo.Title}}</view>
  24. <view class="info">所属提问:{{item.ApprovalInfo.Content}}</view>
  25. <view class="info">评论人:{{item.ApprovalInfo.ApplyName}}</view>
  26. <view class="info">客户信息:{{item.ApprovalInfo.CompanyName}}</view>
  27. <view class="info">评论时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  28. <image src="@/static/icon-look.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  29. </template>
  30. <template v-if="[7,8].includes(item.SourceType)">
  31. <view class="title">{{item.ApprovalInfo.Title}}</view>
  32. <view class="info">视频分类:{{item.ApprovalInfo.MessageSource}}</view>
  33. <view class="info">视频标题:{{item.ApprovalInfo.Content}}</view>
  34. <view class="info">所属{{item.SourceType==7?'标签':'品种'}}:{{item.ApprovalInfo.Extra}}</view>
  35. <view class="info">评论人:{{item.ApprovalInfo.ApplyName}}</view>
  36. <view class="info">客户信息:{{item.ApprovalInfo.CompanyName}}</view>
  37. <view class="info">评论时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  38. <image src="@/static/icon-look.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  39. </template>
  40. </template>
  41. <template v-else>
  42. <view class="type">{{item.ApprovalInfo.Type}}</view>
  43. <view class="title">{{item.CompanyName}}</view>
  44. <view v-if="item.MessageType===3">
  45. <view class="info">{{item.Content}}</view>
  46. <view class="info">修改时间:{{item.CreateTime|formatTime}}</view>
  47. </view>
  48. <view v-else>
  49. <view class="info">申请销售:{{item.ApprovalInfo.ApplyName}}</view>
  50. <view class="info" v-if="item.statusName==='待审批'">提交时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  51. <view class="info" v-else>审批时间:{{item.ApprovalInfo.ApprovalTime|formatTime}}</view>
  52. </view>
  53. <image :src="item.statusImg" mode="aspectFill" class="status-img"></image>
  54. </template>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. </template>
  63. <script>
  64. import {apiMessageList} from '@/api/message.js'
  65. export default {
  66. filters:{
  67. formatTime(e){
  68. if(e==='0001-01-01T00:00:00Z'){
  69. return ''
  70. }else{
  71. return e.replace(/T/g,' ').replace(/\+08:00/g,' ').replace(/-/g,'.')
  72. }
  73. }
  74. },
  75. data() {
  76. return {
  77. scrollViewId:'',
  78. type: null, //类型对应的数字: 1客户(custome)、2合同(contract)、3用印(seal) 5问答 6问答评论
  79. typeName:null,//类型对应的英文 客户(custome)、合同(contract)、用印(seal) question questionComment
  80. page: 1, //页码
  81. list: [],
  82. finished: false, //是否列表为最后一页
  83. avatar:'',// 头像
  84. }
  85. },
  86. onLoad(options) {
  87. this.initPage(options.type)
  88. this.getList()
  89. },
  90. // onPullDownRefresh() {
  91. // this.page=1
  92. // this.finished=false
  93. // this.list=[]
  94. // this.getList()
  95. // setTimeout(()=>{
  96. // uni.stopPullDownRefresh()
  97. // },1500)
  98. // },
  99. // onReachBottom() {
  100. // if(this.finished) return
  101. // this.page++
  102. // this.getList()
  103. // },
  104. methods: {
  105. onScrollTop(){
  106. if(this.finished) return
  107. this.page++
  108. this.getList()
  109. },
  110. handleGoDetail(e){
  111. const urlMap = {
  112. 'custome': '/pages-approve/custome/detail?id='+e.CompanyApprovalId,
  113. 'contract': `/pages-approve/contract/detail?ContractApprovalId=0&ContractId=0&ContractApprovalRecordId=${e.CompanyApprovalId}`,
  114. 'seal': `/pages-approve/seal/detail?ContractApprovalId=0&ContractApprovalRecordId=${e.CompanyApprovalId}`,
  115. 'question':`/pages-question/detail/index?type=question&id=${e.CompanyApprovalId}`,
  116. 'questionComment':`/pages-question/detail/index?type=comment&id=${e.CompanyApprovalId}`,
  117. }
  118. // 如果是questionComment 则如果是视频则跳转到视频
  119. if(this.typeName=='questionComment'&&[7,8].includes(e.SourceType)){
  120. uni.navigateTo({url:`/pages-video/comment/list?id=${e.CompanyApprovalId}&source=${e.SourceType===7?2:3}`})
  121. return
  122. }
  123. uni.navigateTo({url:urlMap[this.typeName]})
  124. },
  125. //获取列表数据
  126. async getList() {
  127. const res = await apiMessageList({
  128. SourceType: this.type,
  129. CurrentIndex: this.page
  130. })
  131. if (res.code === 200) {
  132. if(!res.data.List){
  133. this.finished=true
  134. }else{
  135. let arr=res.data.List.map(item=>{
  136. let statusImg='',statusName='';
  137. switch(item.ApprovalStatus){
  138. case 1:
  139. statusImg=require('../static/icon-2.png')
  140. statusName='待审批'
  141. break;
  142. case 2:
  143. statusImg=require('../static/icon-3.png')
  144. statusName='已审批'
  145. break;
  146. case 3:
  147. statusImg=require('../static/icon-4.png')
  148. statusName='已驳回'
  149. break
  150. }
  151. // 处理消息时间
  152. let msgTime=this.handleMsgTime(item.CreateTime)
  153. return {
  154. statusImg,
  155. statusName,
  156. ...item,
  157. msgTime:msgTime
  158. }
  159. })
  160. this.$nextTick(()=>{
  161. this.scrollViewId=`msg${res.data.List[0].Id}`
  162. })
  163. let reArr=arr.reverse()
  164. this.list = [...reArr,...this.list]
  165. }
  166. }
  167. },
  168. handleMsgTime(e){
  169. let timeStr=''
  170. // 获取今日
  171. const todayTime=new Date()
  172. const time=new Date(e)
  173. const year=time.getFullYear()
  174. const month = time.getMonth() + 1 > 9 ? time.getMonth()+1 : '0'+(time.getMonth()+1);
  175. const day = time.getDate() > 9 ? time.getDate() : "0" + time.getDate();
  176. const hours=time.getHours() > 9 ? time.getHours():'0'+time.getHours()
  177. const minutes=time.getMinutes()>9 ?time.getMinutes():'0'+time.getMinutes()
  178. const seconds=time.getSeconds()>9?time.getSeconds():'0'+time.getSeconds()
  179. if(year!=todayTime.getFullYear()||(time.getMonth()!=todayTime.getMonth())){
  180. timeStr=`${year}.${month}.${day} ${hours}:${minutes}:${seconds}`
  181. }else if(time.getDate()+1==todayTime.getDate()){
  182. //昨天
  183. timeStr=`昨天 ${hours}:${minutes}:${seconds}`
  184. }else if(time.getDate()==todayTime.getDate()){
  185. timeStr=`今天 ${hours}:${minutes}:${seconds}`
  186. }else{
  187. timeStr=`${year}.${month}.${day} ${hours}:${minutes}:${seconds}`
  188. }
  189. return timeStr
  190. },
  191. // 初始化界面
  192. initPage(type) {
  193. let navBarTitle = ''
  194. const _this = this
  195. switch (type) {
  196. case '1':
  197. navBarTitle = '客户待审批'
  198. _this.type = 1
  199. _this.typeName='custome'
  200. _this.avatar=require('../../static/icon-1.png')
  201. break;
  202. case '2':
  203. navBarTitle = '合同待审批'
  204. _this.type = 2
  205. _this.typeName='contract'
  206. _this.avatar=require('../../static/icon-2.png')
  207. break;
  208. case '3':
  209. navBarTitle = '用印待审批'
  210. _this.type = 3
  211. _this.typeName='seal'
  212. _this.avatar=require('../../static/icon-3.png')
  213. break;
  214. case '5':
  215. navBarTitle = '待分配提问'
  216. _this.type = 5
  217. _this.typeName='question'
  218. _this.avatar=require('../../static/icon-question.png')
  219. break;
  220. case '6':
  221. navBarTitle = '待查看评论'
  222. _this.type = 6
  223. _this.typeName='questionComment'
  224. _this.avatar=require('../../static/icon-comment.png')
  225. break;
  226. }
  227. uni.setNavigationBarTitle({
  228. title: navBarTitle
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss">
  235. .message-list-page {
  236. padding: 20rpx;
  237. }
  238. .list{
  239. padding: 0 36rpx 0 19rpx;
  240. .message-item{
  241. margin-top: 50rpx;
  242. }
  243. .top-time-box{
  244. display: inline-block;
  245. padding: 0 20rpx;
  246. min-width: 200rpx;
  247. height: 50rpx;
  248. line-height: 50rpx;
  249. font-size: 12px;
  250. text-align: center;
  251. border-radius: 25rpx;
  252. position: relative;
  253. left: 50%;
  254. transform: translateX(-50%);
  255. margin-bottom: 40rpx;
  256. }
  257. .message-content{
  258. margin-left: 20rpx;
  259. flex: 1;
  260. }
  261. .message-card{
  262. margin-top: 20rpx;
  263. padding: 20rpx;
  264. border: 1px solid #EFEFEF;
  265. box-shadow: 0px 3rpx 12rpx rgba(175, 175, 175, 0.08);
  266. border-radius: 6px;
  267. position: relative;
  268. .type{
  269. color: #FFB005;
  270. font-weight: bold;
  271. &::before{
  272. content: '';
  273. display: inline-block;
  274. width: 28rpx;
  275. height: 28rpx;
  276. background-image: url(../static/icon-1.png);
  277. background-size: cover;
  278. margin-right: 20rpx;
  279. position: relative;
  280. top: 4rpx;
  281. }
  282. }
  283. .title{
  284. font-size: 16px;
  285. font-weight: bold;
  286. margin-top: 20rpx;
  287. }
  288. .info{
  289. margin-top: 20rpx;
  290. }
  291. .status-img,.new-status{
  292. position: absolute;
  293. right: 0;
  294. width: 145rpx;
  295. height: 145rpx;
  296. &.status-img {
  297. top: 0;
  298. }
  299. &.new-status {
  300. bottom: 0;
  301. }
  302. }
  303. }
  304. }
  305. </style>