list.vue 12 KB

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