mailMessage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. <!-- avatar: '../../static/home/avator.png',
  109. nickname: '雾里',
  110. tag: '发起人',
  111. create_time: '17:10',
  112. content: '谢谢你的关注,远方的陌生人',
  113. quantity: 1 -->
  114. <view class="blankHeight"></view>
  115. <view class="loading-more" v-if="tab === 3">
  116. <text v-if="isLoading">正在加载更多...</text>
  117. <view v-else-if="!hasMore">
  118. <text>暂无更多消息</text>
  119. </view>
  120. </view>
  121. </template>
  122. <template v-else-if="!isLoading">
  123. <view class="noData">
  124. <image src="@/static/icon/xx_img_zanwuxiaoxi.png"></image>
  125. <text class="tips-title"> 暂无消息</text>
  126. <text class="tips-content">
  127. 消息还在 "放假",等它们元气满满回来</text>
  128. </view>
  129. </template>
  130. </view>
  131. <DialogBox ref="DialogBox"></DialogBox>
  132. <ToastW3 ref="ToastW3"></ToastW3>
  133. <tabbar-view :tabbars="tabbars" :currentIndex="3" ref="tabbar"></tabbar-view>
  134. </view>
  135. </template>
  136. <script>
  137. import tabbarView from "@/components/tabbar/tabbar.vue";
  138. import tabbar from "@/mixins/tabbar";
  139. export default {
  140. components: {
  141. tabbarView,
  142. },
  143. mixins: [tabbar],
  144. data() {
  145. return {
  146. tab: 1,
  147. scrollTop: 0,
  148. old: {
  149. scrollTop: 0,
  150. },
  151. list: [],
  152. list2: [],
  153. cate: [
  154. {
  155. name: "消息",
  156. id: 1,
  157. },
  158. {
  159. name: "评论和赞",
  160. id: 2,
  161. }, {
  162. name: "客服消息",
  163. id: 3,
  164. },
  165. ],
  166. offset: 0,
  167. isLoading: false,
  168. hasMore: true,
  169. pageSize: 20,
  170. typeMap: {
  171. 1: "sms",
  172. 2: "hudong",
  173. },
  174. list3: [
  175. ],
  176. };
  177. },
  178. onLoad() {
  179. this.loadData();
  180. this.getKefuConversations();
  181. },
  182. onShow() {
  183. this.refreshData();
  184. this.getKefuConversations();
  185. },
  186. onPullDownRefresh() {
  187. this.refreshData();
  188. this.getKefuConversations();
  189. },
  190. onReachBottom() {
  191. if (this.hasMore && !this.isLoading) {
  192. this.loadMore();
  193. }
  194. },
  195. onNavigationBarButtonTap(e) {
  196. if (e.index === 0) {
  197. // uni.navigateTo({
  198. // url: '/pages/my/wishList'
  199. // });
  200. }
  201. },
  202. methods: {
  203. goPages(url){
  204. console.log(url, 'url');
  205. uni.navigateTo({
  206. url,
  207. })
  208. },
  209. onBack() { },
  210. checkTab(tab) {
  211. this.tab = tab;
  212. this.refreshData();
  213. if (tab === 3) {
  214. this.getKefuConversations();
  215. }
  216. },
  217. scroll: function (e) {
  218. console.log(e);
  219. this.old.scrollTop = e.detail.scrollTop;
  220. },
  221. goDetail(item) {
  222. if (item.article_del == 1) {
  223. uni.showToast({
  224. title: '该文章已删除',
  225. icon: 'none'
  226. });
  227. return;
  228. }
  229. let url = '';
  230. switch (item.type) {
  231. case 'sms':
  232. url = `/pages/index/articleDetail?id=${item.article_id}&type=sms`
  233. break;
  234. case 'work':
  235. url = `/pages/index/workDetail?sms_id=${item.id}&id=${item.article_id}&type=work`
  236. break;
  237. case 'article':
  238. url = `/pages/index/articleDetail?sms_id=${item.id}&id=${item.article_id}&type=article`
  239. break;
  240. }
  241. console.log(url, 'url');
  242. if (item.article_id != 0) {
  243. uni.navigateTo({
  244. url,
  245. })
  246. }
  247. },
  248. refreshData() {
  249. this.offset = 0;
  250. this.hasMore = true;
  251. if (this.tab === 1) {
  252. this.list2 = [];
  253. this.bgColor = "#f2f6f2";
  254. } else {
  255. this.bgColor = "#ffffff";
  256. this.list = [];
  257. if (!this.isLoading) {
  258. this.bgColor = "#f2f6f2";
  259. }
  260. }
  261. this.loadData();
  262. },
  263. loadMore() {
  264. this.offset += this.pageSize;
  265. this.loadData();
  266. },
  267. loadData() {
  268. if (this.isLoading) return;
  269. this.isLoading = true;
  270. const type = this.typeMap[this.tab];
  271. if (!type) {
  272. this.isLoading = false;
  273. return;
  274. }
  275. uni.request({
  276. url: this.$apiHost + "/Sms/getlist",
  277. method: "GET",
  278. data: {
  279. uuid: getApp().globalData.uuid,
  280. skey: getApp().globalData.skey,
  281. type: type,
  282. offset: this.offset,
  283. },
  284. header: {
  285. "content-type": "application/json",
  286. sign: getApp().globalData.headerSign,
  287. },
  288. success: (res) => {
  289. console.log("xx1", res.data);
  290. if (res.data && res.data.success == "yes" && res.data.list) {
  291. const newData = res.data.list || [];
  292. if (newData.length < this.pageSize) {
  293. this.hasMore = false;
  294. }
  295. if (this.tab === 1) {
  296. this.list2 =
  297. this.offset === 0 ? newData : [...this.list2, ...newData];
  298. } else {
  299. this.list =
  300. this.offset === 0 ? newData : [...this.list, ...newData];
  301. }
  302. this.offset += res.data.list.length;
  303. } else {
  304. this.hasMore = false;
  305. this.$refs.ToastW3.show("加载失败,请稍后重试");
  306. }
  307. },
  308. fail: () => {
  309. this.hasMore = false;
  310. this.$refs.ToastW3.show("网络错误,请检查网络连接");
  311. },
  312. complete: () => {
  313. this.isLoading = false;
  314. uni.stopPullDownRefresh();
  315. },
  316. });
  317. },
  318. dateFormat(date) {
  319. if (!date) {
  320. return "";
  321. }
  322. // 将日期字符串转换为 Date 对象
  323. try {
  324. const dateObj = new Date(date);
  325. } catch (error) {
  326. const dateObj = new Date();
  327. }
  328. // 格式化年份、月份、日期、小时和分钟
  329. const year = dateObj.getFullYear();
  330. const month = String(dateObj.getMonth() + 1).padStart(2, "0");
  331. const day = String(dateObj.getDate()).padStart(2, "0");
  332. const hours = String(dateObj.getHours()).padStart(2, "0");
  333. const minutes = String(dateObj.getMinutes()).padStart(2, "0");
  334. // 返回格式化后的字符串
  335. return `${year}.${month}.${day} ${hours}:${minutes}`;
  336. },
  337. formatImage(url) {
  338. if (url) {
  339. return url.split("|")[0];
  340. }
  341. },
  342. getKefuConversations() {
  343. uni.request({
  344. url: this.$apiHost + '/App/kefuGetConversations',
  345. method: 'GET',
  346. data: {
  347. uuid: getApp().globalData.uuid,
  348. skey: getApp().globalData.skey
  349. },
  350. success: (res) => {
  351. console.log(res.data, "获取客服消息列表");
  352. if (res.data && res.data.success == 'yes') {
  353. this.list3 = res.data.data.conversations || [];
  354. console.log(res.data.data.conversations, "获取客服消息列表");
  355. } else {
  356. uni.showToast({ title: res.data.message || '获取客服消息失败', icon: 'none' });
  357. }
  358. },
  359. fail: () => {
  360. uni.showToast({ title: '获取客服消息失败', icon: 'none' });
  361. },
  362. complete: () => {
  363. uni.stopPullDownRefresh();
  364. }
  365. });
  366. },
  367. },
  368. };
  369. </script>
  370. <style scoped lang="scss">
  371. @import "mailMessage.scss";
  372. .msg-card {
  373. transition: box-shadow 0.2s, background 0.2s, transform 0.1s;
  374. }
  375. .msg-card:active,
  376. .msg-card-active {
  377. background: #f5f5f5 !important;
  378. transform: scale(0.97);
  379. box-shadow: 0 2rpx 16rpx rgba(172,249,52,0.10);
  380. }
  381. </style>