index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="detail-page">
  3. <view class="tip"
  4. >数据更新时间:{{
  5. formatDate(
  6. new Date().setDate(new Date().getDate() - 1),
  7. "YYYY-MM-DD",
  8. ) || "--"
  9. }}</view
  10. >
  11. <scroll-view
  12. class="list-scroll"
  13. scroll-y="true"
  14. refresher-enabled
  15. :refresher-triggered="isRefreshing"
  16. @refresherrefresh="onRefresh"
  17. @scrolltolower="onLoadMore"
  18. >
  19. <view class="list-container">
  20. <view
  21. class="card-item"
  22. v-for="(item, index) in rows"
  23. :key="index"
  24. @click="toDetail(item)"
  25. >
  26. <view class="left-info">
  27. <view class="row1-name"
  28. >{{ item.receiverName }}
  29. <text
  30. class="level-tag"
  31. :class="getLevelClass(item.customerLevel)"
  32. >
  33. {{ item.customerLevel }}
  34. </text></view
  35. >
  36. <view class="row2-info">
  37. <text class="province"
  38. >客户省份:{{ item.receiverProvince }}
  39. </text>
  40. </view>
  41. <view class="row3-nature">客户性质:{{ item.customerNature }}</view>
  42. <view class="row4-manager">责任经理:{{ item.manager }}</view>
  43. </view>
  44. <view class="right-info">
  45. <text class="alert-count">{{ item.alertCount }}次预警</text>
  46. </view>
  47. </view>
  48. <view class="loading-more" v-if="loading">
  49. <image
  50. class="loading-icon"
  51. src="../../../static/images/loading.png"
  52. />
  53. </view>
  54. <view v-if="!loading && rows.length === 0" class="empty-data">
  55. <EmptyView text="无相关数据" />
  56. </view>
  57. <view v-if="!hasMore && rows.length > 0" class="no-more">
  58. <text>没有更多数据了</text>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. </template>
  64. <script>
  65. import EmptyView from "../../../wigets/empty.vue";
  66. import request from "../../../request/index.js";
  67. import { formatDate } from "../../../utils/utils.js";
  68. export default {
  69. components: {
  70. EmptyView,
  71. },
  72. data() {
  73. return {
  74. isRefreshing: false,
  75. loading: false,
  76. rows: [],
  77. totalCount: 60, // Simulated total count
  78. hasMore: true,
  79. pageNum: 1,
  80. pageSize: 20,
  81. };
  82. },
  83. created() {
  84. this.resetFetch();
  85. },
  86. methods: {
  87. formatDate,
  88. getLevelClass(level) {
  89. if (level === "VIP") return "tag-vip";
  90. if (level === "二级") return "tag-l2";
  91. if (level === "三级") return "tag-l3";
  92. return "tag-default";
  93. },
  94. generateFakeData() {
  95. const newRows = [];
  96. const levels = ["VIP", "二级", "三级"];
  97. const provinces = ["北京市", "上海市", "广东省", "浙江省", "江苏省"];
  98. const natures = ["协议客户", "非协议客户"];
  99. const managers = ["张明华", "李建华", "王丽萍", "陈大文"];
  100. const startIdx = (this.pageNum - 1) * this.pageSize;
  101. const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
  102. if (startIdx >= this.totalCount) {
  103. this.hasMore = false;
  104. return [];
  105. }
  106. for (let i = startIdx; i < endIdx; i++) {
  107. newRows.push({
  108. id: i,
  109. receiverName: `测试收货企业${i + 1}有限公司`,
  110. receiverProvince: provinces[i % provinces.length],
  111. customerLevel: levels[i % levels.length],
  112. customerNature: natures[i % natures.length],
  113. manager: managers[i % managers.length],
  114. alertCount: Math.floor(Math.random() * 10) + 1,
  115. });
  116. }
  117. return newRows;
  118. },
  119. async onRefresh() {
  120. this.isRefreshing = true;
  121. this.pageNum = 1;
  122. this.hasMore = true;
  123. // Simulate network request
  124. setTimeout(() => {
  125. this.rows = this.generateFakeData();
  126. this.isRefreshing = false;
  127. }, 1000);
  128. },
  129. onLoadMore() {
  130. if (this.loading || !this.hasMore) return;
  131. this.loading = true;
  132. this.pageNum++;
  133. // Simulate network request
  134. setTimeout(() => {
  135. const more = this.generateFakeData();
  136. if (more.length > 0) {
  137. this.rows = [...this.rows, ...more];
  138. } else {
  139. this.hasMore = false;
  140. }
  141. this.loading = false;
  142. }, 800);
  143. },
  144. resetFetch() {
  145. this.loading = true;
  146. this.pageNum = 1;
  147. this.hasMore = true;
  148. // Simulate initial load
  149. setTimeout(() => {
  150. this.rows = this.generateFakeData();
  151. this.loading = false;
  152. }, 500);
  153. },
  154. toDetail(item) {
  155. uni.navigateTo({
  156. url: `/traceCodePackages/traceabilityReport/pages/ganmaoling/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
  157. });
  158. },
  159. },
  160. };
  161. </script>
  162. <style scoped>
  163. .detail-page {
  164. display: flex;
  165. flex-direction: column;
  166. height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
  167. box-sizing: border-box;
  168. background: #f3f6f9;
  169. }
  170. .tip {
  171. font-size: 24rpx;
  172. color: #999;
  173. padding: 24rpx;
  174. background: #f3f6f9;
  175. }
  176. .list-scroll {
  177. flex: 1;
  178. height: 0;
  179. /* Important for flex expansion */
  180. padding: 0 24rpx;
  181. box-sizing: border-box;
  182. }
  183. .list-container {
  184. padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
  185. }
  186. .card-item {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: flex-start;
  190. /* Align top */
  191. background: #fff;
  192. border-radius: 16rpx;
  193. padding: 30rpx;
  194. margin-bottom: 20rpx;
  195. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  196. }
  197. .left-info {
  198. flex: 1;
  199. margin-right: 20rpx;
  200. }
  201. .row1-name {
  202. font-size: 30rpx;
  203. font-weight: bold;
  204. color: #1890ff;
  205. margin-bottom: 16rpx;
  206. display: flex;
  207. align-items: center;
  208. gap: 20rpx;
  209. }
  210. .row2-info {
  211. display: flex;
  212. align-items: center;
  213. margin-bottom: 12rpx;
  214. }
  215. .province {
  216. font-size: 26rpx;
  217. color: #666;
  218. margin-right: 20rpx;
  219. }
  220. .level-tag {
  221. font-size: 22rpx;
  222. padding: 4rpx 12rpx;
  223. border-radius: 6rpx;
  224. background: #f0f0f0;
  225. color: #666;
  226. }
  227. .tag-vip {
  228. background: #e6f7ff;
  229. color: #1890ff;
  230. }
  231. .tag-l2 {
  232. background: #f6ffed;
  233. color: #52c41a;
  234. }
  235. .tag-l3 {
  236. background: #fff7e6;
  237. color: #fa8c16;
  238. }
  239. .row3-nature {
  240. font-size: 26rpx;
  241. color: #666;
  242. margin-bottom: 12rpx;
  243. }
  244. .row4-manager {
  245. font-size: 26rpx;
  246. color: #666;
  247. }
  248. .right-info {
  249. display: flex;
  250. align-items: center;
  251. align-self: center;
  252. /* Center vertically relative to card */
  253. }
  254. .alert-count {
  255. background: #fff2f0;
  256. color: #ff4d4f;
  257. font-size: 24rpx;
  258. padding: 8rpx 20rpx;
  259. border-radius: 30rpx;
  260. font-weight: bold;
  261. }
  262. .loading-more {
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. padding: 20rpx 0;
  267. }
  268. .loading-icon {
  269. width: 32rpx;
  270. height: 32rpx;
  271. margin-right: 10rpx;
  272. animation: spin 1s linear infinite;
  273. }
  274. .empty-data {
  275. display: flex;
  276. justify-content: center;
  277. padding-top: 100rpx;
  278. }
  279. .no-more {
  280. text-align: center;
  281. color: #999;
  282. font-size: 24rpx;
  283. padding: 20rpx 0;
  284. }
  285. @keyframes spin {
  286. from {
  287. transform: rotate(0deg);
  288. }
  289. to {
  290. transform: rotate(360deg);
  291. }
  292. }
  293. </style>