mailMessage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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.avatar" />
  97. <view class="msg-main">
  98. <view class="msg-header">
  99. <text class="nickname">{{ item.nickname }}</text>
  100. <text class="tag" v-if="item.tag">{{ item.tag }}</text>
  101. <text class="time">{{ item.create_time }}</text>
  102. </view>
  103. <view class="msg-content">{{ item.content }}</view>
  104. </view>
  105. <view v-if="item.quantity >0" class="red-dot">{{ item.quantity }}</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. avatar: '../../static/home/avator.png',
  171. nickname: '雾里',
  172. tag: '发起人',
  173. create_time: '17:10',
  174. content: '谢谢你的关注,远方的陌生人',
  175. quantity: 1
  176. },{
  177. avatar: '../../static/home/avator.png',
  178. nickname: '雾里',
  179. tag: '发起人',
  180. create_time: '17:10',
  181. content: '谢谢你的关注,远方的陌生人',
  182. quantity: 0
  183. },{
  184. avatar: '../../static/home/avator.png',
  185. nickname: '雾里',
  186. tag: '发起人',
  187. create_time: '17:10',
  188. content: '谢谢你的关注,远方的陌生人',
  189. quantity: 9
  190. },
  191. ],
  192. };
  193. },
  194. onLoad() {
  195. this.loadData();
  196. },
  197. onShow() {
  198. this.refreshData();
  199. },
  200. onPullDownRefresh() {
  201. this.refreshData();
  202. },
  203. onReachBottom() {
  204. if (this.hasMore && !this.isLoading) {
  205. this.loadMore();
  206. };
  207. },
  208. onLoad() {
  209. this.loadData();
  210. },
  211. onShow() {
  212. this.refreshData();
  213. },
  214. onPullDownRefresh() {
  215. this.refreshData();
  216. },
  217. onReachBottom() {
  218. if (this.hasMore && !this.isLoading) {
  219. this.loadMore();
  220. }
  221. },
  222. onNavigationBarButtonTap(e) {
  223. if (e.index === 0) {
  224. // uni.navigateTo({
  225. // url: '/pages/my/wishList'
  226. // });
  227. }
  228. },
  229. methods: {
  230. goPages(url){
  231. console.log(url, 'url');
  232. uni.navigateTo({
  233. url,
  234. })
  235. },
  236. onBack() { },
  237. checkTab(tab) {
  238. this.tab = tab;
  239. this.refreshData();
  240. },
  241. scroll: function (e) {
  242. console.log(e);
  243. this.old.scrollTop = e.detail.scrollTop;
  244. },
  245. goDetail(item) {
  246. if (item.article_del == 1) {
  247. uni.showToast({
  248. title: '该文章已删除',
  249. icon: 'none'
  250. });
  251. return;
  252. }
  253. let url = '';
  254. switch (item.type) {
  255. case 'sms':
  256. url = `/pages/index/articleDetail?id=${item.article_id}&type=sms`
  257. break;
  258. case 'work':
  259. url = `/pages/index/workDetail?sms_id=${item.id}&id=${item.article_id}&type=work`
  260. break;
  261. case 'article':
  262. url = `/pages/index/articleDetail?sms_id=${item.id}&id=${item.article_id}&type=article`
  263. break;
  264. }
  265. console.log(url, 'url');
  266. if (item.article_id != 0) {
  267. uni.navigateTo({
  268. url,
  269. })
  270. }
  271. },
  272. refreshData() {
  273. this.offset = 0;
  274. this.hasMore = true;
  275. if (this.tab === 1) {
  276. this.list2 = [];
  277. this.bgColor = "#f2f6f2";
  278. } else {
  279. this.bgColor = "#ffffff";
  280. this.list = [];
  281. if (!this.isLoading) {
  282. this.bgColor = "#f2f6f2";
  283. }
  284. }
  285. this.loadData();
  286. },
  287. loadMore() {
  288. this.offset += this.pageSize;
  289. this.loadData();
  290. },
  291. loadData() {
  292. if (this.isLoading) return;
  293. this.isLoading = true;
  294. const type = this.typeMap[this.tab];
  295. if (!type) {
  296. this.isLoading = false;
  297. return;
  298. }
  299. uni.request({
  300. url: this.$apiHost + "/Sms/getlist",
  301. method: "GET",
  302. data: {
  303. uuid: getApp().globalData.uuid,
  304. skey: getApp().globalData.skey,
  305. type: type,
  306. offset: this.offset,
  307. },
  308. header: {
  309. "content-type": "application/json",
  310. sign: getApp().globalData.headerSign,
  311. },
  312. success: (res) => {
  313. console.log("xx1", res.data);
  314. if (res.data && res.data.success == "yes" && res.data.list) {
  315. const newData = res.data.list || [];
  316. if (newData.length < this.pageSize) {
  317. this.hasMore = false;
  318. }
  319. if (this.tab === 1) {
  320. this.list2 =
  321. this.offset === 0 ? newData : [...this.list2, ...newData];
  322. } else {
  323. this.list =
  324. this.offset === 0 ? newData : [...this.list, ...newData];
  325. }
  326. this.offset += res.data.list.length;
  327. } else {
  328. this.hasMore = false;
  329. this.$refs.ToastW3.show("加载失败,请稍后重试");
  330. }
  331. },
  332. fail: () => {
  333. this.hasMore = false;
  334. this.$refs.ToastW3.show("网络错误,请检查网络连接");
  335. },
  336. complete: () => {
  337. this.isLoading = false;
  338. uni.stopPullDownRefresh();
  339. },
  340. });
  341. },
  342. dateFormat(date) {
  343. if (!date) {
  344. return "";
  345. }
  346. // 将日期字符串转换为 Date 对象
  347. try {
  348. const dateObj = new Date(date);
  349. } catch (error) {
  350. const dateObj = new Date();
  351. }
  352. // 格式化年份、月份、日期、小时和分钟
  353. const year = dateObj.getFullYear();
  354. const month = String(dateObj.getMonth() + 1).padStart(2, "0");
  355. const day = String(dateObj.getDate()).padStart(2, "0");
  356. const hours = String(dateObj.getHours()).padStart(2, "0");
  357. const minutes = String(dateObj.getMinutes()).padStart(2, "0");
  358. // 返回格式化后的字符串
  359. return `${year}.${month}.${day} ${hours}:${minutes}`;
  360. },
  361. formatImage(url) {
  362. if (url) {
  363. return url.split("|")[0];
  364. }
  365. },
  366. },
  367. };
  368. </script>
  369. <style scoped lang="scss">
  370. @import "mailMessage.scss";
  371. .msg-card {
  372. transition: box-shadow 0.2s, background 0.2s, transform 0.1s;
  373. }
  374. .msg-card:active,
  375. .msg-card-active {
  376. background: #f5f5f5 !important;
  377. transform: scale(0.97);
  378. box-shadow: 0 2rpx 16rpx rgba(172,249,52,0.10);
  379. }
  380. </style>