insurance-list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <scroll-view class="container" scroll-y>
  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. export default {
  60. data() {
  61. return {
  62. filterTabs: [
  63. { label: '全部', value: '' },
  64. { label: '有效', value: 'active' },
  65. { label: '已过期', value: 'expired' },
  66. { label: '已取消', value: 'cancelled' }
  67. ],
  68. currentFilter: '',
  69. policies: []
  70. }
  71. },
  72. onShow() {
  73. this.loadPolicies()
  74. },
  75. methods: {
  76. async loadPolicies() {
  77. try {
  78. const res = await getInsuranceList({ status: this.currentFilter || undefined })
  79. if (res && res.code === 200) {
  80. this.policies = res.data || []
  81. }
  82. } catch (e) {
  83. console.error('加载保单失败', e)
  84. }
  85. },
  86. viewDetail(item) {
  87. uni.navigateTo({
  88. url: '/pages/wealth/insurance-add?id=' + item.id
  89. })
  90. },
  91. addPolicy() {
  92. uni.navigateTo({
  93. url: '/pages/wealth/insurance-add'
  94. })
  95. },
  96. deletePolicy(item) {
  97. var self = this
  98. uni.showModal({
  99. title: '提示',
  100. content: '确定删除该保单?',
  101. success: async function(res) {
  102. if (res.confirm) {
  103. try {
  104. const result = await deleteInsurance(item.id)
  105. if (result && result.code === 200) {
  106. uni.showToast({ title: '已删除', icon: 'success' })
  107. self.loadPolicies()
  108. }
  109. } catch (e) {
  110. console.error('删除失败', e)
  111. }
  112. }
  113. }
  114. })
  115. },
  116. getStatusClass(status) {
  117. return status === 'active' ? 'status-active' : status === 'expired' ? 'status-expired' : 'status-cancelled'
  118. },
  119. getStatusLabel(status) {
  120. return status === 'active' ? '有效' : status === 'expired' ? '已过期' : '已取消'
  121. }
  122. }
  123. }
  124. </script>
  125. <style>
  126. .container {
  127. min-height: 100vh;
  128. background: #f5f7fa;
  129. padding: 20rpx 30rpx 120rpx;
  130. }
  131. .filter-tabs {
  132. display: flex;
  133. flex-direction: row;
  134. background: #fff;
  135. border-radius: 16rpx;
  136. padding: 12rpx;
  137. margin-bottom: 24rpx;
  138. }
  139. .filter-tab {
  140. flex: 1;
  141. text-align: center;
  142. padding: 12rpx 0;
  143. font-size: 26rpx;
  144. color: #666;
  145. border-radius: 12rpx;
  146. }
  147. .filter-tab.active {
  148. background: #F97316;
  149. color: #fff;
  150. font-weight: 600;
  151. }
  152. .empty-state {
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. padding: 80rpx 0;
  157. }
  158. .empty-icon {
  159. font-size: 80rpx;
  160. margin-bottom: 20rpx;
  161. }
  162. .empty-text {
  163. font-size: 30rpx;
  164. color: #999;
  165. }
  166. .empty-hint {
  167. font-size: 24rpx;
  168. color: #ccc;
  169. margin-top: 8rpx;
  170. }
  171. .policy-card {
  172. background: #fff;
  173. border-radius: 20rpx;
  174. padding: 24rpx;
  175. margin-bottom: 20rpx;
  176. }
  177. .policy-header {
  178. display: flex;
  179. flex-direction: row;
  180. justify-content: space-between;
  181. align-items: center;
  182. margin-bottom: 16rpx;
  183. padding-bottom: 16rpx;
  184. border-bottom: 2rpx solid #f5f5f5;
  185. }
  186. .policy-name {
  187. font-size: 30rpx;
  188. font-weight: 600;
  189. color: #333;
  190. }
  191. .policy-status {
  192. font-size: 24rpx;
  193. padding: 4rpx 16rpx;
  194. border-radius: 8rpx;
  195. }
  196. .status-active {
  197. background: #DCFCE7;
  198. color: #16A34A;
  199. }
  200. .status-expired {
  201. background: #FEF2F2;
  202. color: #DC2626;
  203. }
  204. .status-cancelled {
  205. background: #F5F5F5;
  206. color: #999;
  207. }
  208. .policy-body {
  209. margin-bottom: 12rpx;
  210. }
  211. .policy-row {
  212. display: flex;
  213. flex-direction: row;
  214. justify-content: space-between;
  215. padding: 8rpx 0;
  216. }
  217. .policy-label {
  218. font-size: 26rpx;
  219. color: #999;
  220. }
  221. .policy-value {
  222. font-size: 26rpx;
  223. color: #333;
  224. }
  225. .policy-value.orange {
  226. color: #F97316;
  227. font-weight: 600;
  228. }
  229. .policy-footer {
  230. display: flex;
  231. flex-direction: row;
  232. justify-content: flex-end;
  233. padding-top: 12rpx;
  234. border-top: 2rpx solid #f5f5f5;
  235. }
  236. .delete-btn {
  237. font-size: 24rpx;
  238. color: #DC2626;
  239. padding: 8rpx 20rpx;
  240. }
  241. .add-btn-wrap {
  242. padding: 20rpx 0 40rpx;
  243. }
  244. .add-btn {
  245. width: 100%;
  246. height: 88rpx;
  247. line-height: 88rpx;
  248. text-align: center;
  249. background: #F97316;
  250. color: #fff;
  251. font-size: 30rpx;
  252. font-weight: 600;
  253. border-radius: 44rpx;
  254. border: none;
  255. }
  256. .add-btn::after {
  257. border: none;
  258. }
  259. </style>