chat.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="chat-container">
  3. <scroll-view refresher-enabled :refresher-triggered="isRefreshing" @refresherrefresh="onCustomRefresh"
  4. class="scroll-view-class" @scrolltolower="scrolltolower" scroll-y>
  5. <view class="chat-main">
  6. <view v-if="list && list.length > 0">
  7. <view class="chat-item" v-for="item in list" :key="item.code" @click="onClick(item)">
  8. <img src="/static/serverImg/mine/user.png" alt="" class="chat-img" />
  9. <view class="chat-box">
  10. <view class="chat-top">
  11. <text class="chat-name">toutou旗舰店</text>
  12. <text class="chat-time">昨天</text>
  13. </view>
  14. <view class="chat-bottom">
  15. <text class="chat-text">
  16. 尊敬的会员,您行行行行行行行行行行想尊敬的会员,您行行行行行行行行行行想尊敬的会员,您行行行行行行行行行行想尊敬的会员,您行行行行行行行行行行想
  17. </text>
  18. <view class="chat-num">
  19. 2
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
  25. :loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
  26. :nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" /> -->
  27. </view>
  28. <view v-else>
  29. <NoneView value="您还没有相关账单" />
  30. </view>
  31. </view>
  32. </scroll-view>
  33. <custom-tab-bar page="chat" />
  34. </view>
  35. </template>
  36. <script setup>
  37. import CustomTabBar from '@/components/CustomTabBar/index.vue'
  38. import { ref, computed } from 'vue'
  39. import { getAccountChangeList, getVolunteerChangeList } from "@/api/mine";
  40. import { onShow } from '@dcloudio/uni-app';
  41. import { useDict } from '@/utils/dict.js';
  42. import NoneView from '@/components/NoneView/index.vue'
  43. const { } = useDict();
  44. const userType = uni.getStorageSync('userType') //读取本地存储
  45. const list = ref([])
  46. const isRefreshing = ref(false)
  47. const loadmoreInfo = ref({
  48. status: 'loadmore',
  49. loadingText: '努力加载中...',
  50. loadmoreText: '点击加载更多~',
  51. nomoreText: '您没有更多消息~'
  52. })
  53. const pages = ref({
  54. current: 1,
  55. pageSize: 10,
  56. total: 0,
  57. })
  58. const onClick = (record) => {
  59. console.log("TCL: onClick -> record", record)
  60. uni.navigateTo({
  61. url: `/pages_orderuser/pages/talk/pages/index/index?orderId=${123}`
  62. });
  63. }
  64. const scrolltolower = () => {
  65. init('bottom')
  66. };
  67. const onCustomRefresh = () => {
  68. isRefreshing.value = true;
  69. pages.value.current = 1;
  70. init('top')
  71. };
  72. const init = async (type) => {
  73. try {
  74. if (type === 'bottom') {
  75. if (list.value.length < pages.value.total) {
  76. loadmoreInfo.value.status = 'loading';
  77. pages.value.current++;
  78. } else {
  79. loadmoreInfo.value.status = 'nomore';
  80. return;
  81. }
  82. } else {
  83. uni.showLoading({
  84. title: '数据加载中...',
  85. })
  86. }
  87. const listApi = userType === 1 ? getAccountChangeList : getVolunteerChangeList;
  88. const res = await listApi({
  89. pageNum: pages.value.current,
  90. pageSize: pages.value.pageSize,
  91. });
  92. list.value = type === 'top' ? res.rows : [...list.value, ...res.rows];
  93. pages.value.total = res.total;
  94. } catch (error) {
  95. console.log('error', error);
  96. uni.showToast({
  97. title: error.msg,
  98. icon: 'error',
  99. });
  100. } finally {
  101. if (type === 'top') {
  102. isRefreshing.value = false;
  103. uni.hideLoading();
  104. }
  105. if (list.value.length === pages.value.total) {
  106. loadmoreInfo.value.status = 'nomore';
  107. }
  108. }
  109. }
  110. const totalInit = async () => {
  111. // try {
  112. // const listApi = userType === 1 ? getTotalMoney : getVolunteerTotalMoney;
  113. // const res = await listApi({});
  114. // data.value.totalEarning = res.data.totalEarning;
  115. // data.value.totalExpend = res.data.totalExpend;
  116. // } catch (error) {
  117. // console.log('error', error);
  118. // uni.showToast({
  119. // title: error.msg,
  120. // icon: 'error',
  121. // });
  122. // }
  123. }
  124. onShow(() => {
  125. init('top');
  126. totalInit();
  127. })
  128. </script>
  129. <style lang="scss" scoped>
  130. .chat-container {
  131. height: 100vh;
  132. .scroll-view-class {
  133. height: 100vh;
  134. // background: rgba(245, 245, 245, 1);
  135. }
  136. .chat-item {
  137. padding: 16rpx;
  138. display: flex;
  139. .chat-img {
  140. width: 96rpx;
  141. height: 96rpx;
  142. border-radius: 16rpx;
  143. margin-right: 12rpx;
  144. }
  145. .chat-box {
  146. border-bottom: 1px solid rgba(238, 238, 238, 1);
  147. flex: 1;
  148. padding-bottom: 16rpx;
  149. .chat-top {
  150. display: flex;
  151. align-items: center;
  152. justify-content: space-between;
  153. .chat-name {
  154. font-size: 32rpx;
  155. font-weight: 400;
  156. line-height: 48rpx;
  157. color: rgba(0, 0, 0, 1);
  158. }
  159. .chat-time {
  160. font-size: 28rpx;
  161. font-weight: 400;
  162. line-height: 40rpx;
  163. color: rgba(75, 85, 99, 1);
  164. }
  165. }
  166. .chat-bottom {
  167. display: flex;
  168. justify-content: space-between;
  169. .chat-text {
  170. font-size: 28rpx;
  171. font-weight: 400;
  172. line-height: 40rpx;
  173. color: rgba(102, 102, 102, 1);
  174. width: 250px;
  175. white-space: nowrap; /* 禁止换行 */
  176. overflow: hidden; /* 隐藏溢出内容 */
  177. text-overflow: ellipsis; /* 溢出部分显示省略号 */
  178. }
  179. .chat-num {
  180. background: rgba(239, 68, 68, 1);
  181. color: #fff;
  182. display: flex;
  183. align-items: center;
  184. justify-content: center;
  185. width: 20px;
  186. height: 20px;
  187. border-radius: 20px;
  188. line-height: 20px;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>