complaint-lists.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <view class="cp-list-page">
  3. <view class="cp-list-nav" :style="{ paddingTop: statusBar + 'px' }">
  4. <view class="cp-list-nav-row">
  5. <view class="cp-list-back" @tap="goBack">
  6. <text class="cp-list-back-icon">←</text>
  7. </view>
  8. <text class="cp-list-nav-title">{{ copy.title }}</text>
  9. <view class="cp-list-nav-placeholder" />
  10. </view>
  11. </view>
  12. <scroll-view
  13. scroll-y
  14. class="cp-list-scroll"
  15. :style="{ height: scrollHeight + 'px' }"
  16. :lower-threshold="120"
  17. @scrolltolower="onScrollToLower"
  18. >
  19. <view class="cp-list-body" :style="{ paddingBottom: safeBottom + 'px' }">
  20. <view v-if="loading && !rows.length" class="cp-list-state">
  21. <text class="cp-list-state-txt">{{ copy.loading }}</text>
  22. </view>
  23. <empty
  24. v-else-if="loaded && !rows.length"
  25. :text="copy.empty"
  26. />
  27. <view v-else class="cp-list-stack">
  28. <view
  29. v-for="item in rows"
  30. :key="item.id"
  31. class="cp-list-card"
  32. >
  33. <view class="cp-list-card-head">
  34. <view class="cp-list-user">
  35. <image
  36. class="cp-list-avatar"
  37. :src="avatarUrl"
  38. mode="aspectFill"
  39. />
  40. <view class="cp-list-user-meta">
  41. <text class="cp-list-user-name">{{ nickname }}</text>
  42. <text class="cp-list-user-time">{{ timeText(item.createtime) }}</text>
  43. </view>
  44. </view>
  45. <text
  46. v-if="item.state_text"
  47. class="cp-list-badge"
  48. >{{ item.state_text }}</text>
  49. </view>
  50. <view
  51. v-if="goodsCard(item)"
  52. class="cp-list-goods"
  53. @tap="openGoods(goodsCard(item))"
  54. >
  55. <image
  56. class="cp-list-goods-cover"
  57. :src="goodsCover(goodsCard(item))"
  58. mode="aspectFill"
  59. />
  60. <view class="cp-list-goods-body">
  61. <text class="cp-list-goods-title">{{ goodsCard(item).title }}</text>
  62. <view class="cp-list-goods-foot">
  63. <text v-if="goodsCard(item).price" class="cp-list-goods-price">{{ goodsCard(item).price }}</text>
  64. <text v-if="item.reason_text" class="cp-list-goods-reason">{{ item.reason_text }}</text>
  65. </view>
  66. </view>
  67. </view>
  68. <text class="cp-list-content">{{ item.content || copy.noContent }}</text>
  69. <view
  70. v-if="item.images && item.images.length"
  71. class="cp-list-images"
  72. :class="'cp-list-images--' + imageColClass(item.images.length)"
  73. >
  74. <view
  75. v-for="(image, index) in item.images"
  76. :key="index"
  77. class="cp-list-img-cell"
  78. @tap="previewImages(item.images, index)"
  79. >
  80. <image
  81. class="cp-list-img"
  82. :src="imageThumb(image)"
  83. mode="aspectFill"
  84. />
  85. </view>
  86. </view>
  87. <view v-if="item.state === 'hidden' && item.receipt" class="cp-list-receipt">
  88. <text class="cp-list-receipt-label">{{ copy.processResult }}</text>
  89. <text class="cp-list-receipt-text">{{ item.receipt }}</text>
  90. </view>
  91. </view>
  92. </view>
  93. <uni-load-more
  94. v-if="rows.length"
  95. :status="loadStatus"
  96. :content-text="loadMoreText"
  97. />
  98. </view>
  99. </scroll-view>
  100. </view>
  101. </template>
  102. <script>
  103. import { mapState } from 'vuex'
  104. import { fetchComplaintListPage } from '@/features/account/complaint-gateway'
  105. export default {
  106. data() {
  107. return {
  108. statusBar: 0,
  109. scrollHeight: 600,
  110. safeBottom: 0,
  111. rows: [],
  112. page: 1,
  113. lastPage: 1,
  114. loading: false,
  115. loaded: false,
  116. loadStatus: 'more'
  117. }
  118. },
  119. computed: {
  120. ...mapState('user', {
  121. profile: (state) => state
  122. }),
  123. copy() {
  124. const t = this.$t.bind(this)
  125. return {
  126. title: t('user.myReports'),
  127. loading: t('complaint-lists.loading'),
  128. empty: t('complaint-lists.no-complaint'),
  129. noContent: t('complaint-lists.no-content'),
  130. processResult: t('complaint-lists.process-result'),
  131. network: t('user.realnameNetworkError')
  132. }
  133. },
  134. nickname() {
  135. return (this.profile && this.profile.nickname) || this.$t('complaint.guest')
  136. },
  137. avatarUrl() {
  138. const raw = (this.profile && this.profile.avatar) || ''
  139. return this.$appKit && this.$appKit.oss
  140. ? this.$appKit.oss(raw, 72, 72, 2, 'avatar')
  141. : raw
  142. },
  143. loadMoreText() {
  144. return {
  145. contentdown: ' ',
  146. contentrefresh: this.copy.loading,
  147. contentnomore: ''
  148. }
  149. }
  150. },
  151. onLoad() {
  152. const sys = uni.getSystemInfoSync()
  153. this.statusBar = sys.statusBarHeight || 0
  154. this.safeBottom = sys.safeAreaInsets ? sys.safeAreaInsets.bottom : 0
  155. const navH = this.statusBar + uni.upx2px(88)
  156. this.scrollHeight = (sys.windowHeight || 667) - navH
  157. this.reloadList()
  158. },
  159. onPullDownRefresh() {
  160. this.reloadList()
  161. },
  162. methods: {
  163. goBack() {
  164. if (getCurrentPages().length > 1) {
  165. uni.navigateBack({ delta: 1 })
  166. } else {
  167. uni.switchTab({
  168. url: '/pages/mine/index',
  169. fail: () => uni.reLaunch({ url: '/pages/mine/index' })
  170. })
  171. }
  172. },
  173. timeText(ts) {
  174. return this.$appKit && this.$appKit.timeToDate
  175. ? this.$appKit.timeToDate(ts)
  176. : ''
  177. },
  178. goodsCard(item) {
  179. if (!item) return null
  180. if (Number(item.type) === 1 && item.goods) return item.goods
  181. if (Number(item.type) === 3 && item.groups) return item.groups
  182. return null
  183. },
  184. goodsCover(goods) {
  185. const raw = goods && goods.image
  186. return this.$appKit && this.$appKit.oss ? this.$appKit.oss(raw, 132, 132) : raw
  187. },
  188. imageColClass(count) {
  189. if (count > 3) return '3'
  190. return String(count || 1)
  191. },
  192. imageThumb(url) {
  193. return this.$appKit && this.$appKit.oss ? this.$appKit.oss(url, 248, 0) : url
  194. },
  195. previewImages(images, index) {
  196. const urls = images.map((item) =>
  197. this.$appKit.oss ? this.$appKit.oss(item, 500) : item
  198. )
  199. uni.previewImage({
  200. urls,
  201. current: urls[index],
  202. indicator: 'number'
  203. })
  204. },
  205. openGoods(goods) {
  206. if (!goods || !goods.id) return
  207. if (typeof this.$appKit.onGoods === 'function') {
  208. this.$appKit.onGoods(goods.id)
  209. }
  210. },
  211. reloadList() {
  212. this.page = 1
  213. this.lastPage = 1
  214. this.rows = []
  215. this.loaded = false
  216. this.loadStatus = 'more'
  217. this.loadPage(true)
  218. },
  219. onScrollToLower() {
  220. if (this.loading || this.page >= this.lastPage) {
  221. this.loadStatus = 'noMore'
  222. return
  223. }
  224. this.page += 1
  225. this.loadStatus = 'loading'
  226. this.loadPage(false)
  227. },
  228. async loadPage(replace) {
  229. if (this.loading) return
  230. this.loading = true
  231. try {
  232. const res = await fetchComplaintListPage(this.page)
  233. this.rows = replace ? res.rows : this.rows.concat(res.rows)
  234. this.page = res.currentPage
  235. this.lastPage = res.lastPage
  236. this.loadStatus = res.total === 0 || this.page >= this.lastPage ? 'noMore' : 'more'
  237. } catch (err) {
  238. this.$appKit.msg((err && err.message) || this.copy.network)
  239. this.loadStatus = 'more'
  240. } finally {
  241. this.loading = false
  242. this.loaded = true
  243. uni.stopPullDownRefresh()
  244. }
  245. }
  246. }
  247. }
  248. </script>
  249. <style scoped>
  250. .cp-list-page {
  251. min-height: 100vh;
  252. background-color: #f4f6fb;
  253. }
  254. .cp-list-nav {
  255. background-color: #ffffff;
  256. border-bottom: 1rpx solid #eef1f6;
  257. }
  258. .cp-list-nav-row {
  259. display: flex;
  260. flex-direction: row;
  261. align-items: center;
  262. height: 88rpx;
  263. padding: 0 24rpx;
  264. box-sizing: border-box;
  265. }
  266. .cp-list-back {
  267. width: 64rpx;
  268. height: 64rpx;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. }
  273. .cp-list-back-icon {
  274. font-size: 40rpx;
  275. color: #1a1d26;
  276. line-height: 1;
  277. }
  278. .cp-list-nav-title {
  279. flex: 1;
  280. text-align: center;
  281. font-size: 32rpx;
  282. font-weight: 600;
  283. color: #1a1d26;
  284. }
  285. .cp-list-nav-placeholder {
  286. width: 64rpx;
  287. }
  288. .cp-list-body {
  289. padding: 24rpx 28rpx 0;
  290. box-sizing: border-box;
  291. }
  292. .cp-list-state {
  293. padding: 80rpx 0;
  294. text-align: center;
  295. }
  296. .cp-list-state-txt {
  297. font-size: 28rpx;
  298. color: #8a8d9e;
  299. }
  300. .cp-list-stack {
  301. display: flex;
  302. flex-direction: column;
  303. }
  304. .cp-list-card {
  305. background-color: #ffffff;
  306. border-radius: 24rpx;
  307. padding: 28rpx;
  308. margin-bottom: 24rpx;
  309. box-shadow: 0 6rpx 24rpx rgba(74, 140, 255, 0.06);
  310. }
  311. .cp-list-card-head {
  312. display: flex;
  313. flex-direction: row;
  314. align-items: flex-start;
  315. justify-content: space-between;
  316. margin-bottom: 20rpx;
  317. }
  318. .cp-list-user {
  319. display: flex;
  320. flex-direction: row;
  321. align-items: center;
  322. flex: 1;
  323. min-width: 0;
  324. }
  325. .cp-list-avatar {
  326. width: 72rpx;
  327. height: 72rpx;
  328. border-radius: 36rpx;
  329. background-color: #eef1f6;
  330. flex-shrink: 0;
  331. }
  332. .cp-list-user-meta {
  333. margin-left: 16rpx;
  334. min-width: 0;
  335. }
  336. .cp-list-user-name {
  337. display: block;
  338. font-size: 28rpx;
  339. font-weight: 600;
  340. color: #1a1d26;
  341. }
  342. .cp-list-user-time {
  343. display: block;
  344. margin-top: 6rpx;
  345. font-size: 24rpx;
  346. color: #8a8d9e;
  347. }
  348. .cp-list-badge {
  349. flex-shrink: 0;
  350. margin-left: 12rpx;
  351. padding: 6rpx 16rpx;
  352. border-radius: 999rpx;
  353. font-size: 22rpx;
  354. color: #ea580c;
  355. background-color: #fff7ed;
  356. }
  357. .cp-list-goods {
  358. display: flex;
  359. flex-direction: row;
  360. align-items: center;
  361. padding: 16rpx;
  362. margin-bottom: 20rpx;
  363. border-radius: 16rpx;
  364. background-color: #f7f9fc;
  365. }
  366. .cp-list-goods-cover {
  367. width: 96rpx;
  368. height: 96rpx;
  369. border-radius: 12rpx;
  370. background-color: #eef1f6;
  371. flex-shrink: 0;
  372. }
  373. .cp-list-goods-body {
  374. flex: 1;
  375. margin-left: 16rpx;
  376. min-width: 0;
  377. }
  378. .cp-list-goods-title {
  379. display: block;
  380. font-size: 28rpx;
  381. color: #1a1d26;
  382. overflow: hidden;
  383. text-overflow: ellipsis;
  384. white-space: nowrap;
  385. }
  386. .cp-list-goods-foot {
  387. display: flex;
  388. flex-direction: row;
  389. align-items: center;
  390. flex-wrap: wrap;
  391. margin-top: 8rpx;
  392. gap: 12rpx;
  393. }
  394. .cp-list-goods-price {
  395. font-size: 26rpx;
  396. font-weight: 600;
  397. color: #ef4444;
  398. }
  399. .cp-list-goods-reason {
  400. font-size: 24rpx;
  401. color: #ea580c;
  402. }
  403. .cp-list-content {
  404. display: block;
  405. font-size: 28rpx;
  406. line-height: 1.55;
  407. color: #374151;
  408. margin-bottom: 16rpx;
  409. }
  410. .cp-list-images {
  411. display: flex;
  412. flex-direction: row;
  413. flex-wrap: wrap;
  414. margin: -6rpx;
  415. margin-bottom: 16rpx;
  416. }
  417. .cp-list-images--1 .cp-list-img-cell {
  418. width: calc(60% - 12rpx);
  419. }
  420. .cp-list-images--2 .cp-list-img-cell,
  421. .cp-list-images--3 .cp-list-img-cell {
  422. width: calc(33.333% - 12rpx);
  423. }
  424. .cp-list-img-cell {
  425. margin: 6rpx;
  426. height: 200rpx;
  427. border-radius: 12rpx;
  428. overflow: hidden;
  429. }
  430. .cp-list-img {
  431. width: 100%;
  432. height: 100%;
  433. }
  434. .cp-list-receipt {
  435. padding: 16rpx 20rpx;
  436. border-radius: 12rpx;
  437. background-color: #f0f7ff;
  438. }
  439. .cp-list-receipt-label {
  440. display: block;
  441. font-size: 24rpx;
  442. font-weight: 600;
  443. color: #4a8cff;
  444. margin-bottom: 8rpx;
  445. }
  446. .cp-list-receipt-text {
  447. display: block;
  448. font-size: 26rpx;
  449. line-height: 1.5;
  450. color: #4b5563;
  451. }
  452. </style>