mailMessage.vue 7.8 KB

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