mailMessage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <view class="page"
  3. :style="{ background: tab == 1 ? '#f2f6f2' : '#ffffff', borderWidth: tab == 2 ? '2rpx' : 'none' }">
  4. <view class="mainBody">
  5. <!-- <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="0"> -->
  6. <view class="tabs">
  7. <view class="tab" :class="{ active: tab === item.id }" @click="checkTab(item.id)"
  8. v-for="(item, index) in cate" :key="index">
  9. <text class="left">{{ item.name }}</text>
  10. <view class="line"></view>
  11. </view>
  12. </view>
  13. <!-- </scroll-view> -->
  14. </view>
  15. <view class="reserveASeat"></view>
  16. <view class="list_info" v-if="tab === 2">
  17. <template v-if="offset">
  18. <view class="item" @click="goDetail(item)" v-for="(item, index) in list" :key="index">
  19. <CircleAvatar class="avator" :src="item.avator"></CircleAvatar>
  20. <view class="content">
  21. <view class="tit">
  22. <view class="name">{{ item.nickname }}</view>
  23. <view class="time one-omit">
  24. {{ item.title }}
  25. <!-- {{ item.create_time }} -->
  26. {{ ' ' + item.tdate }}
  27. </view>
  28. <view class="desc">{{ item.content }} </view>
  29. </view>
  30. <view class="right-image">
  31. <image class="works-image" mode="widthFix" v-if="item.image" :src="formatImage(item.image)">
  32. </image>
  33. <image class="right-image-icon" v-else src="@/static/me/arrow_right_gray.png">
  34. </image>
  35. </view>
  36. </view>
  37. <view class="line"></view>
  38. </view>
  39. <view class="blankHeight"></view>
  40. <view class="loading-more" v-if="tab === 2">
  41. <text v-if="isLoading">正在加载更多...</text>
  42. <view v-else-if="!hasMore">
  43. <text>无更多内容</text>
  44. </view>
  45. </view>
  46. </template>
  47. <template v-else-if="!isLoading">
  48. <view class="noData">
  49. <image src="@/static/icon/xx_img_zanwuxiaoxi.png"></image>
  50. <text class="tips-title"> 暂无内容</text>
  51. <text class="tips-content">
  52. 点赞还在赶来的路上,别着急,你的精彩值得被看见</text>
  53. </view>
  54. </template>
  55. </view>
  56. <view class="list_article" v-if="tab === 1">
  57. <template v-if="offset">
  58. <block v-for="(item, index) in list2" :key="index">
  59. <view class="items" @click="goDetail(item)">
  60. <view class="dateAndTime">{{ item.create_time }}</view>
  61. <view class="items-content">
  62. <image v-if="item.image" :src="item.image || '../../static/dome/home-swper.png'"
  63. mode="widthFix"></image>
  64. <view class="title one-omit">{{ item.title }} </view>
  65. <view class="content">{{ item.content }}</view>
  66. <view class="viewDetails" v-if="item.article_id != 0">
  67. <text>查看详情</text>
  68. <image src="../../static/me/wd_icon_jiantou2.png"></image>
  69. </view>
  70. <view v-else style="width: 100%; height: 20rpx;"></view>
  71. </view>
  72. </view>
  73. </block>
  74. <view class="blankHeight"></view>
  75. <view class="loading-more" v-if="tab === 1">
  76. <text v-if="isLoading">正在加载更多...</text>
  77. <view v-else-if="!hasMore">
  78. <text>暂无更多消息</text>
  79. </view>
  80. </view>
  81. </template>
  82. <template v-else-if="!isLoading">
  83. <view class="noData">
  84. <image src="@/static/icon/xx_img_zanwuxiaoxi.png"></image>
  85. <text class="tips-title"> 暂无消息</text>
  86. <text class="tips-content">
  87. 消息还在 "放假",等它们元气满满回来</text>
  88. </view>
  89. </template>
  90. </view>
  91. <!-- 客服消息 -->
  92. <view class="customer-service-message" v-if="tab === 3">
  93. <template v-if="true || offset">
  94. <block v-for="(item, index) in list3" :key="index">
  95. <view class="msg-card" @click="goPages('/pages/crowdFunding/customerService?id='+item.id)">
  96. <image class="avatar" :src="item&&item.kefu_info&&item.kefu_info.avatar" />
  97. <view class="msg-main">
  98. <view class="msg-header">
  99. <text class="nickname">{{ item&&item.kefu_info&&item.kefu_info.nickname }}</text>
  100. <text class="tag" > 发起人</text>
  101. <text class="time">{{ item.create_time }}</text>
  102. </view>
  103. <view class="msg-content">{{ item.last_message }}</view>
  104. </view>
  105. <view v-if="item.unread_count >0" class="red-dot">{{ item.unread_count }}</view>
  106. </view>
  107. </block>
  108. <view class="blankHeight"></view>
  109. <view class="loading-more" v-if="tab === 3">
  110. <text v-if="isLoading">正在加载更多...</text>
  111. <view v-else-if="!hasMore">
  112. <text>暂无更多消息</text>
  113. </view>
  114. </view>
  115. </template>
  116. <template v-else-if="!isLoading">
  117. <view class="noData">
  118. <image src="@/static/icon/xx_img_zanwuxiaoxi.png"></image>
  119. <text class="tips-title"> 暂无消息</text>
  120. <text class="tips-content">
  121. 消息还在 "放假",等它们元气满满回来</text>
  122. </view>
  123. </template>
  124. </view>
  125. <DialogBox ref="DialogBox"></DialogBox>
  126. <ToastW3 ref="ToastW3"></ToastW3>
  127. <tabbar-view :tabbars="tabbars" :currentIndex="3" ref="tabbar"></tabbar-view>
  128. </view>
  129. </template>
  130. <script>
  131. import tabbarView from "@/components/tabbar/tabbar.vue";
  132. import tabbar from "@/mixins/tabbar";
  133. export default {
  134. components: {
  135. tabbarView,
  136. },
  137. mixins: [tabbar],
  138. data() {
  139. return {
  140. tab: 1,
  141. scrollTop: 0,
  142. old: {
  143. scrollTop: 0,
  144. },
  145. list: [],
  146. list2: [],
  147. cate: [
  148. {
  149. name: "消息",
  150. id: 1,
  151. },
  152. {
  153. name: "评论和赞",
  154. id: 2,
  155. }, {
  156. name: "客服消息",
  157. id: 3,
  158. },
  159. ],
  160. offset: 0,
  161. isLoading: false,
  162. hasMore: true,
  163. pageSize: 20,
  164. typeMap: {
  165. 1: "sms",
  166. 2: "hudong",
  167. },
  168. list3: [
  169. ],
  170. };
  171. },
  172. onLoad() {
  173. this.loadData();
  174. this.getKefuConversations();
  175. },
  176. onShow() {
  177. this.refreshData();
  178. this.getKefuConversations();
  179. },
  180. onPullDownRefresh() {
  181. this.refreshData();
  182. this.getKefuConversations();
  183. },
  184. onReachBottom() {
  185. if (this.hasMore && !this.isLoading) {
  186. this.loadMore();
  187. }
  188. },
  189. onNavigationBarButtonTap(e) {
  190. if (e.index === 0) {
  191. // uni.navigateTo({
  192. // url: '/pages/my/wishList'
  193. // });
  194. }
  195. },
  196. methods: {
  197. goPages(url){
  198. console.log(url, 'url');
  199. uni.navigateTo({
  200. url,
  201. })
  202. },
  203. onBack() { },
  204. checkTab(tab) {
  205. this.tab = tab;
  206. this.refreshData();
  207. if (tab === 3) {
  208. this.getKefuConversations();
  209. }
  210. },
  211. scroll: function (e) {
  212. console.log(e);
  213. this.old.scrollTop = e.detail.scrollTop;
  214. },
  215. goDetail(item) {
  216. if (item.article_del == 1) {
  217. uni.showToast({
  218. title: '该文章已删除',
  219. icon: 'none'
  220. });
  221. return;
  222. }
  223. let url = '';
  224. switch (item.type) {
  225. case 'sms':
  226. url = `/pages/index/articleDetail?id=${item.article_id}&type=sms`
  227. break;
  228. case 'work':
  229. url = `/pages/index/workDetail?sms_id=${item.id}&id=${item.article_id}&type=work`
  230. break;
  231. case 'article':
  232. url = `/pages/index/articleDetail?sms_id=${item.id}&id=${item.article_id}&type=article`
  233. break;
  234. }
  235. console.log(url, 'url');
  236. if (item.article_id != 0) {
  237. uni.navigateTo({
  238. url,
  239. })
  240. }
  241. },
  242. refreshData() {
  243. this.offset = 0;
  244. this.hasMore = true;
  245. if (this.tab === 1) {
  246. this.list2 = [];
  247. this.bgColor = "#f2f6f2";
  248. } else {
  249. this.bgColor = "#ffffff";
  250. this.list = [];
  251. if (!this.isLoading) {
  252. this.bgColor = "#f2f6f2";
  253. }
  254. }
  255. this.loadData();
  256. },
  257. loadMore() {
  258. this.offset += this.pageSize;
  259. this.loadData();
  260. },
  261. loadData() {
  262. if (this.isLoading) return;
  263. this.isLoading = true;
  264. const type = this.typeMap[this.tab];
  265. if (!type) {
  266. this.isLoading = false;
  267. return;
  268. }
  269. uni.request({
  270. url: this.$apiHost + "/Sms/getlist",
  271. method: "GET",
  272. data: {
  273. uuid: getApp().globalData.uuid,
  274. skey: getApp().globalData.skey,
  275. type: type,
  276. offset: this.offset,
  277. },
  278. header: {
  279. "content-type": "application/json",
  280. sign: getApp().globalData.headerSign,
  281. },
  282. success: (res) => {
  283. console.log("xx1", res.data);
  284. if (res.data && res.data.success == "yes" && res.data.list) {
  285. const newData = res.data.list || [];
  286. if (newData.length < this.pageSize) {
  287. this.hasMore = false;
  288. }
  289. if (this.tab === 1) {
  290. this.list2 =
  291. this.offset === 0 ? newData : [...this.list2, ...newData];
  292. } else {
  293. this.list =
  294. this.offset === 0 ? newData : [...this.list, ...newData];
  295. }
  296. this.offset += res.data.list.length;
  297. } else {
  298. this.hasMore = false;
  299. this.$refs.ToastW3.show("加载失败,请稍后重试");
  300. }
  301. },
  302. fail: () => {
  303. this.hasMore = false;
  304. this.$refs.ToastW3.show("网络错误,请检查网络连接");
  305. },
  306. complete: () => {
  307. this.isLoading = false;
  308. uni.stopPullDownRefresh();
  309. },
  310. });
  311. },
  312. dateFormat(date) {
  313. if (!date) {
  314. return "";
  315. }
  316. // 将日期字符串转换为 Date 对象
  317. try {
  318. const dateObj = new Date(date);
  319. } catch (error) {
  320. const dateObj = new Date();
  321. }
  322. // 格式化年份、月份、日期、小时和分钟
  323. const year = dateObj.getFullYear();
  324. const month = String(dateObj.getMonth() + 1).padStart(2, "0");
  325. const day = String(dateObj.getDate()).padStart(2, "0");
  326. const hours = String(dateObj.getHours()).padStart(2, "0");
  327. const minutes = String(dateObj.getMinutes()).padStart(2, "0");
  328. // 返回格式化后的字符串
  329. return `${year}.${month}.${day} ${hours}:${minutes}`;
  330. },
  331. formatImage(url) {
  332. if (url) {
  333. return url.split("|")[0];
  334. }
  335. },
  336. getKefuConversations() {
  337. uni.request({
  338. url: this.$apiHost + '/App/kefuGetConversations',
  339. method: 'GET',
  340. data: {
  341. uuid: getApp().globalData.uuid,
  342. skey: getApp().globalData.skey
  343. },
  344. success: (res) => {
  345. console.log(res.data, "获取客服消息列表");
  346. if (res.data && res.data.success == 'yes') {
  347. this.list3 = res.data.data.conversations || [];
  348. console.log(res.data.data.conversations, "获取客服消息列表");
  349. } else {
  350. uni.showToast({ title: res.data.message || '获取客服消息失败', icon: 'none' });
  351. }
  352. },
  353. fail: () => {
  354. uni.showToast({ title: '获取客服消息失败', icon: 'none' });
  355. },
  356. complete: () => {
  357. uni.stopPullDownRefresh();
  358. }
  359. });
  360. },
  361. },
  362. };
  363. </script>
  364. <style scoped lang="scss">
  365. @import "mailMessage.scss";
  366. .msg-card {
  367. transition: box-shadow 0.2s, background 0.2s, transform 0.1s;
  368. }
  369. .msg-card:active,
  370. .msg-card-active {
  371. background: #f5f5f5 !important;
  372. transform: scale(0.97);
  373. box-shadow: 0 2rpx 16rpx rgba(172,249,52,0.10);
  374. }
  375. </style>