myadvice.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="myAdvice">
  3. <view class="bg"></view>
  4. <!-- 页面头部 -->
  5. <u-navbar
  6. back-icon-color="#fff"
  7. :back-text="$t('common.Back')"
  8. :is-back="true"
  9. :background="{background:'#1777FE'}"
  10. :back-text-style="{color:'#fff'}"
  11. :border-bottom="true"
  12. title-color="#fff"
  13. :title="title"
  14. :custom-back="back"
  15. >
  16. <!-- <view slot="right" class="edit" @click="editMyAdvice">编辑</view> -->
  17. </u-navbar>
  18. <!-- 列表 -->
  19. <view class="tabs" v-if="tabs.length>0">
  20. <view class="item" v-for="(item,index) in tabs" :key="index">
  21. <uni-swipe-action style="width:100%">
  22. <uni-swipe-action-item :right-options="options" @click="deleteInfo(index,item)">
  23. <view class="userimg" @click="showDetial(1,item)"><image class="img" :src="item.src?item.src:defaultImg" mode="widthFix"></image></view>
  24. <view class="userinfo">
  25. <view class="label" v-if="item.senderName" @click="showDetial(1,item)">{{item.senderName}}</view>
  26. <view class="date" @click="showDetial(1,item)">{{formatDate(item.senderDate)}}</view>
  27. <view class="userques" v-if="item.content" @click="showDetial(1,item)">
  28. <view class="text" :class="{line2:true}">{{item.content}}</view>
  29. <!-- <view class="openmsg" @click="showMore('leavingFlag',item)">
  30. <view v-if="!item.leavingFlag" ><u-icon name="arrow-down" color="#aaa" size="32"></u-icon></view>
  31. <view v-if="item.leavingFlag" ><u-icon name="arrow-up" color="#aaa" size="32"></u-icon></view>
  32. </view> -->
  33. </view>
  34. <view class="proName" @click="showDetial(0,item)">
  35. <view class="text">{{item.columnCodeName}}</view>
  36. <view class="icon"><u-icon name="attach" :size="24"></u-icon></view>
  37. </view>
  38. <view class="ans" v-if="item.consultMessageInfo" @click="showDetial(1,item)">
  39. <view style="font-size:30rpx;margin-bottom:10upx">{{$t('common.PlatformReply')}}:</view>
  40. <view class="text" :class="{line2:true}">{{item.consultMessageInfo.content}}</view>
  41. <!-- <view class="openmsg" @click="showMore('replyFlag',item)">
  42. <view v-if="!item.replyFlag" ><u-icon name="arrow-down" color="#aaa" size="32"></u-icon></view>
  43. <view v-if="item.replyFlag" ><u-icon name="arrow-up" color="#aaa" size="32"></u-icon></view>
  44. </view> -->
  45. </view>
  46. </view>
  47. </uni-swipe-action-item>
  48. </uni-swipe-action>
  49. </view>
  50. </view>
  51. <!-- 页面优化提示 -->
  52. <view class="loading" v-if="showLoading" :class="{fixbottom:pageNo<totalPage}">
  53. <u-loadmore :status="status" iconType="flower" :load-text="{loading: $t('common.Loading')}"/>
  54. </view>
  55. <view class="nodata" v-if="!showLoading && tabs.length==0" style="text-align: center;margin-top: 120upx;">
  56. <view style="height:600upx;margin-bottom:60upx">
  57. <image src="../../../static/img/public/7.png" style="width: 80%;margin:0 10%" mode="widthFix"></image>
  58. </view>
  59. <text style="font-size: 30upx;color:#ccc">{{$t('common.Nodata')}}</text>
  60. </view>
  61. <u-toast ref="uToast" />
  62. </view>
  63. </template>
  64. <script>
  65. import {getReplyAndSenderMessage} from '@/api/operation/consultMessageInfo'
  66. import UNavbar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  67. import uniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue'
  68. export default {
  69. name:'MyAdvice',
  70. components:{
  71. UNavbar,
  72. uniSwipeAction
  73. },
  74. data(){
  75. return {
  76. title:'',
  77. keyword:'',
  78. lineIndex:false,
  79. flagName:'展开',
  80. showLoading:true,
  81. status:'loading',
  82. pageNo:1,
  83. pageSize:10,
  84. totalPage:0,
  85. tabs:[],
  86. token:'',
  87. defaultImg:'../../../static/missing-face.png',
  88. options:[
  89. {
  90. text:this.$t('common.Delete'),
  91. style: {
  92. fontSize:'12px',
  93. height:'30px',
  94. backgroundColor:'#f2a059',
  95. }
  96. }
  97. ],
  98. }
  99. },
  100. onLoad(e){
  101. this.title= this.$i18n.locale == 'zh'? '我的咨询': 'My Consultation'
  102. },
  103. created(){
  104. this.getToken();
  105. this.getReplyAndSenderMessage()
  106. },
  107. onShow(){
  108. this.token=uni.getStorageSync('Auth-Token')?'Bearer '+uni.getStorageSync('Auth-Token'):'';
  109. this.userId = uni.getStorageSync('user')? JSON.parse(uni.getStorageSync('user')).id:'';
  110. // if(!this.token){
  111. // uni.navigateTo({url:'/pages/public/login?back=1'})
  112. // }else{
  113. // }
  114. },
  115. mounted(){
  116. this.isLogin()
  117. },
  118. // 滚动监听-加载更多数据
  119. onReachBottom(e){
  120. if(this.pageNo<this.totalPage){
  121. this.showLoading=true;
  122. this.pageNo++;
  123. this.getReplyAndSenderMessage('loadmore')
  124. }else{
  125. if(this.showLoading!=false) this.showLoading=false;
  126. }
  127. },
  128. methods:{
  129. async getToken(){
  130. let res = await this.$myRequest({url:'/sys/token'})
  131. if(res.status==200) this.token=res.data
  132. },
  133. // 获取我的咨询数据列表
  134. async getReplyAndSenderMessage(loadmore){
  135. let data = {
  136. pageNo:this.pageNo,
  137. pageSize:this.pageSize,
  138. language:this.$i18n.locale.toUpperCase()
  139. }
  140. let res = await this.$myRequest({
  141. url:'/op/consultMessageInfos/getReplyAndSenderMessage',
  142. data,
  143. })
  144. this.showLoading=false;
  145. if(res.data.consultMessageInfos){
  146. this.totalPage=parseInt(res.data.page.totalPage);
  147. for(let i=0;i<res.data.consultMessageInfos.length;i++){
  148. this.$set(res.data.consultMessageInfos[i],'replyFlag',false)
  149. this.$set(res.data.consultMessageInfos[i],'leavingFlag',false)
  150. }
  151. if(loadmore){
  152. this.tabs=[...this.tabs,...res.data.consultMessageInfos]
  153. }else{
  154. this.tabs=res.data.consultMessageInfos
  155. }
  156. }
  157. },
  158. //展开或者收起回复
  159. showMore(type,item){
  160. if(type=='leavingFlag') this.$set(item,'leavingFlag',!item.leavingFlag)
  161. else this.$set(item,'replyFlag',!item.replyFlag)
  162. },
  163. //编辑我的咨询
  164. editMyAdvice(){
  165. uni.navigateTo({url:'/pages/service/others/myadvicedit'})
  166. },
  167. //详情
  168. showDetial(type,item){
  169. let url= type==0?'/pages/country/projectPresentation/projectPresentationDetails?id='+item.columnCode:
  170. '/pages/service/others/myadviceDetial?id='+item.columnCode;
  171. if(type!=0){
  172. uni.setStorageSync('myAdviceDetial',item)
  173. }
  174. if(url) uni.navigateTo({url})
  175. },
  176. //删除
  177. async deleteInfo(index,item){
  178. let res = await this.$myRequest({
  179. url:'/op/consultMessageInfos/gateDelConsultMessageInfo',
  180. method:'get',
  181. data:{replyAndSenderMessageId:item.id} //
  182. })
  183. if(res.status==200){
  184. this.tabs.splice(index,1);
  185. this.$refs.uToast.show({
  186. title: this.$i18n.locale == 'zh'? '删除成功': 'delete success',
  187. icon:false,
  188. type:'success'
  189. })
  190. }else{
  191. this.$refs.uToast.show({
  192. title: this.$i18n.locale == 'zh'? '删除失败': 'delete fail',
  193. icon:false,
  194. type:'error'
  195. })
  196. }
  197. },
  198. //路由后退一步
  199. back(){
  200. // #ifdef H5
  201. history.back()
  202. // #endif
  203. // #ifndef H5
  204. uni.navigateBack()
  205. // #endif
  206. },
  207. // 登录检查
  208. isLogin(){
  209. if(!this.token){
  210. this.$refs.uToast.show({
  211. title:this.$i18n.locale == 'zh'?'请登录':'Please Login',
  212. icon:false,
  213. type:'error',
  214. callback:()=>{
  215. uni.navigateTo({url:'/pages/public/login?back=1'})
  216. }
  217. })
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .myAdvice{
  225. .loading{
  226. background-color:#FAFAFA;
  227. width:100%;
  228. height:60upx;
  229. line-height:60upx;
  230. padding-top:10upx;
  231. &.fixbottom{
  232. position:fixed;
  233. bottom:0;
  234. z-index:999;
  235. }
  236. }
  237. .bg{
  238. position:fixed;
  239. top:0;
  240. left:0;
  241. bottom:0;
  242. right:0;
  243. background-color:#fff;
  244. z-index:-1;
  245. }
  246. .edit{
  247. margin-right:30rpx;
  248. color:#fff;
  249. }
  250. .tabs{
  251. width:100%;
  252. .item{
  253. width:100%;
  254. padding:3%;
  255. margin:20rpx 0;
  256. border-bottom:2rpx solid #eee;
  257. &:last-of-type{
  258. border:none;
  259. }
  260. .userimg{
  261. width:100rpx;
  262. height:100rpx;
  263. position:relative;
  264. border-radius:100%;
  265. background:#eee;
  266. margin-right:10rpx;
  267. .img{
  268. display:block;
  269. width:100rpx;
  270. height:100rpx;
  271. }
  272. }
  273. .userinfo{
  274. flex:1;
  275. font-size:24rpx;
  276. color:#666;
  277. display:flex;
  278. flex-direction:column;
  279. margin-right:20rpx;
  280. /deep/ .uni-swipe_button{
  281. height:120rpx;
  282. }
  283. .label{
  284. font-size:22rpx;
  285. }
  286. .userques{
  287. display:flex;
  288. align-items:center;
  289. .text{
  290. flex:1;
  291. margin:16rpx 0;
  292. color:#333;
  293. font-size:30rpx;
  294. &.line2{
  295. overflow:hidden;
  296. text-overflow:ellipsis;
  297. display:-webkit-box;
  298. -webkit-box-orient:vertical;
  299. -webkit-line-clamp:2;
  300. }
  301. }
  302. .openmsg{
  303. width:60rpx;
  304. height:60rpx;
  305. margin-right:20rpx;
  306. text-align:right;
  307. left:10rpx;
  308. color:#333;
  309. font-size:24rpx;
  310. align-self:flex-end;
  311. }
  312. }
  313. .proName{
  314. display:flex;
  315. align-items:center;
  316. color:#666;
  317. .text{
  318. font-size:22rpx;
  319. overflow:hidden;
  320. text-overflow:ellipsis;
  321. display:-webkit-box;
  322. -webkit-box-orient:vertical;
  323. -webkit-line-clamp:2;
  324. width:92%;
  325. }
  326. .icon{
  327. color:#fff;
  328. background-color:#1777FE;
  329. height:32upx;
  330. line-height:32upx;
  331. width:32upx;
  332. text-align:center;
  333. border-radius:50%;
  334. margin-left:10upx;
  335. }
  336. }
  337. .ans{
  338. background:#f0f6ff;
  339. padding:10rpx;
  340. margin-top:30rpx;
  341. position:relative;
  342. border-radius:10rpx;
  343. color:#333;
  344. font-size:24rpx;
  345. padding:16rpx;
  346. .text{
  347. flex:1;
  348. margin:16rpx 0;
  349. color:#333;
  350. font-size:30rpx;
  351. &.line2{
  352. overflow:hidden;
  353. text-overflow:ellipsis;
  354. display:-webkit-box;
  355. -webkit-box-orient:vertical;
  356. -webkit-line-clamp:2;
  357. }
  358. }
  359. .answer{
  360. margin-top:10rpx;
  361. overflow:hidden;
  362. text-overflow:ellipsis;
  363. display:-webkit-box;
  364. font-size:24rpx;
  365. -webkit-box-orient:vertical;
  366. -webkit-line-clamp:2;
  367. &.linemore{
  368. -webkit-line-clamp:10000;
  369. }
  370. }
  371. &:after{
  372. content:'';
  373. position:absolute;
  374. top:-55rpx;
  375. left:10%;
  376. width:0;
  377. height:0;
  378. border-top:30rpx solid transparent;
  379. border-bottom:30rpx solid #f0f6ff;
  380. border-left:20rpx solid transparent;
  381. border-right:20rpx solid transparent;
  382. }
  383. .openmsg{
  384. text-align:right;
  385. margin-right:10rpx;
  386. margin-top:10rpx;
  387. color:#333;
  388. font-size:24rpx;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .opt{
  395. width:100%;
  396. padding:0 10%;
  397. position:fixed;
  398. left:0;
  399. right:0;
  400. bottom:0;
  401. height:140rpx;
  402. margin:0 auto;
  403. background:#fefefe;
  404. display:flex;
  405. align-items:center;
  406. justify-content:space-between;
  407. .clearList,.removeListItem{
  408. margin-top:52rpx;
  409. width:50%;
  410. line-height:70rpx;
  411. border:1px solid #eee;
  412. padding:0 40rpx;
  413. border-radius:0 0 80rpx 80rpx;
  414. text-align:center;
  415. }
  416. }
  417. }
  418. </style>