insurance-list.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <scroll-view class="container" scroll-y :style="{ '--font-scale': fontScale }">
  3. <!-- 状态过滤 -->
  4. <view class="filter-tabs">
  5. <view
  6. v-for="(tab, index) in filterTabs"
  7. :key="index"
  8. class="filter-tab"
  9. :class="{ active: currentFilter === tab.value }"
  10. @click="currentFilter = tab.value; loadPolicies()">
  11. <text>{{ tab.label }}</text>
  12. </view>
  13. </view>
  14. <!-- 保单列表 -->
  15. <view v-if="policies.length === 0" class="empty-state">
  16. <text class="empty-icon">📋</text>
  17. <text class="empty-text">暂无保单</text>
  18. <text class="empty-hint">点击下方按钮添加保单</text>
  19. </view>
  20. <view
  21. v-for="(item, index) in policies"
  22. :key="index"
  23. class="policy-card"
  24. @click="viewDetail(item)">
  25. <view class="policy-header">
  26. <text class="policy-name">{{ item.policyName }}</text>
  27. <text class="policy-status" :class="item.status === 'active' ? 'status-active' : item.status === 'expired' ? 'status-expired' : 'status-cancelled'">{{ getStatusLabel(item.status) }}</text>
  28. </view>
  29. <view class="policy-body">
  30. <view class="policy-row">
  31. <text class="policy-label">保险公司</text>
  32. <text class="policy-value">{{ item.insuranceCompany || '未知' }}</text>
  33. </view>
  34. <view class="policy-row">
  35. <text class="policy-label">被保人</text>
  36. <text class="policy-value">{{ item.insuredPerson }}</text>
  37. </view>
  38. <view class="policy-row">
  39. <text class="policy-label">保费</text>
  40. <text class="policy-value orange">{{ formatPriceWithSymbol(item.premium || 0) }}</text>
  41. </view>
  42. <view class="policy-row">
  43. <text class="policy-label">到期日</text>
  44. <text class="policy-value">{{ item.endDate ? item.endDate.substring(0, 10) : '长期' }}</text>
  45. </view>
  46. </view>
  47. <view class="policy-footer" @click.stop="deletePolicy(item)">
  48. <text class="delete-btn">删除</text>
  49. </view>
  50. </view>
  51. <!-- 新增按钮 -->
  52. <view class="add-btn-wrap">
  53. <button class="add-btn" @click="addPolicy">+ 新增保单</button>
  54. </view>
  55. </scroll-view>
  56. </template>
  57. <script>
  58. import { getInsuranceList, deleteInsurance } from '../../utils/api'
  59. import fontScaleMixin from '@/mixins/font-scale.js'
  60. export default {
  61. mixins: [fontScaleMixin],
  62. data() {
  63. return {
  64. filterTabs: [
  65. { label: '全部', value: '' },
  66. { label: '有效', value: 'active' },
  67. { label: '已过期', value: 'expired' },
  68. { label: '已取消', value: 'cancelled' }
  69. ],
  70. currentFilter: '',
  71. policies: []
  72. }
  73. },
  74. onShow() {
  75. this.loadPolicies()
  76. },
  77. methods: {
  78. async loadPolicies() {
  79. try {
  80. const res = await getInsuranceList({ status: this.currentFilter || undefined })
  81. if (res && res.code === 200) {
  82. this.policies = res.data || []
  83. }
  84. } catch (e) {
  85. console.error('加载保单失败', e)
  86. }
  87. },
  88. viewDetail(item) {
  89. uni.navigateTo({
  90. url: '/pages/wealth/insurance-add?id=' + item.id
  91. })
  92. },
  93. addPolicy() {
  94. uni.navigateTo({
  95. url: '/pages/wealth-sub/insurance-add'
  96. })
  97. },
  98. deletePolicy(item) {
  99. var self = this
  100. uni.showModal({
  101. title: '提示',
  102. content: '确定删除该保单?',
  103. success: async function(res) {
  104. if (res.confirm) {
  105. try {
  106. const result = await deleteInsurance(item.id)
  107. if (result && result.code === 200) {
  108. uni.showToast({ title: '已删除', icon: 'success' })
  109. self.loadPolicies()
  110. }
  111. } catch (e) {
  112. console.error('删除失败', e)
  113. }
  114. }
  115. }
  116. })
  117. },
  118. getStatusClass(status) {
  119. return status === 'active' ? 'status-active' : status === 'expired' ? 'status-expired' : 'status-cancelled'
  120. },
  121. getStatusLabel(status) {
  122. return status === 'active' ? '有效' : status === 'expired' ? '已过期' : '已取消'
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. .container {
  129. min-height: 100vh;
  130. background: $app-bg;
  131. padding: 20rpx $uni-space-page 120rpx;
  132. width: 100%;
  133. box-sizing: border-box;
  134. overflow-x: hidden;
  135. }
  136. .filter-tabs {
  137. display: flex;
  138. flex-direction: row;
  139. background: $app-surface;
  140. border-radius: 16rpx;
  141. padding: 12rpx;
  142. margin-bottom: 24rpx;
  143. }
  144. .filter-tab {
  145. flex: 1;
  146. text-align: center;
  147. padding: 12rpx 0;
  148. font-size: calc(26rpx * var(--font-scale, 1));
  149. color: $facade-text-body;
  150. border-radius: 16rpx;
  151. }
  152. .filter-tab.active {
  153. background: $brand-primary;
  154. color: $app-surface;
  155. font-weight: 600;
  156. }
  157. .empty-state {
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. padding: 80rpx 0;
  162. }
  163. .empty-icon {
  164. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  165. margin-bottom: 20rpx;
  166. }
  167. .empty-text {
  168. font-size: calc(30rpx * var(--font-scale, 1));
  169. color: $facade-text-muted;
  170. }
  171. .empty-hint {
  172. font-size: calc(24rpx * var(--font-scale, 1));
  173. color: $facade-text-ghost;
  174. margin-top: 8rpx;
  175. }
  176. .policy-card {
  177. background: $app-surface;
  178. border-radius: 24rpx;
  179. padding: 24rpx;
  180. margin-bottom: 20rpx;
  181. }
  182. .policy-header {
  183. display: flex;
  184. flex-direction: row;
  185. justify-content: space-between;
  186. align-items: center;
  187. margin-bottom: 16rpx;
  188. padding-bottom: 16rpx;
  189. border-bottom: 2rpx solid $facade-fill-2;
  190. }
  191. .policy-name {
  192. font-size: calc(30rpx * var(--font-scale, 1));
  193. font-weight: 600;
  194. color: $facade-text-strong;
  195. }
  196. .policy-status {
  197. font-size: calc(24rpx * var(--font-scale, 1));
  198. padding: 4rpx 16rpx;
  199. border-radius: 8rpx;
  200. }
  201. .status-active {
  202. background: $status-success-soft-2;
  203. color: $status-success-strong-2;
  204. }
  205. .status-expired {
  206. background: $status-danger-tint-2;
  207. color: $status-danger-deep;
  208. }
  209. .status-cancelled {
  210. background: $facade-fill-2;
  211. color: $facade-text-muted;
  212. }
  213. .policy-body {
  214. margin-bottom: 12rpx;
  215. }
  216. .policy-row {
  217. display: flex;
  218. flex-direction: row;
  219. justify-content: space-between;
  220. padding: 8rpx 0;
  221. }
  222. .policy-label {
  223. font-size: calc(26rpx * var(--font-scale, 1));
  224. color: $facade-text-muted;
  225. }
  226. .policy-value {
  227. font-size: calc(26rpx * var(--font-scale, 1));
  228. color: $facade-text-strong;
  229. }
  230. .policy-value.orange {
  231. color: $brand-primary;
  232. font-weight: 600;
  233. }
  234. .policy-footer {
  235. display: flex;
  236. flex-direction: row;
  237. justify-content: flex-end;
  238. padding-top: 12rpx;
  239. border-top: 2rpx solid $facade-fill-2;
  240. }
  241. .delete-btn {
  242. font-size: calc(24rpx * var(--font-scale, 1));
  243. color: $status-danger-deep;
  244. padding: 8rpx 20rpx;
  245. }
  246. .add-btn-wrap {
  247. padding: 20rpx 0 40rpx;
  248. }
  249. .add-btn {
  250. width: 100%;
  251. height: 88rpx;
  252. line-height: 88rpx;
  253. text-align: center;
  254. background: $brand-primary;
  255. color: $app-surface;
  256. font-size: calc(30rpx * var(--font-scale, 1));
  257. font-weight: 600;
  258. border-radius: 24rpx;
  259. border: none;
  260. }
  261. .add-btn::after {
  262. border: none;
  263. }
  264. </style>