insurance-list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. width: 100%;
  131. box-sizing: border-box;
  132. overflow-x: hidden;
  133. }
  134. .filter-tabs {
  135. display: flex;
  136. flex-direction: row;
  137. background: #fff;
  138. border-radius: 16rpx;
  139. padding: 12rpx;
  140. margin-bottom: 24rpx;
  141. }
  142. .filter-tab {
  143. flex: 1;
  144. text-align: center;
  145. padding: 12rpx 0;
  146. font-size: 26rpx;
  147. color: #666;
  148. border-radius: 12rpx;
  149. }
  150. .filter-tab.active {
  151. background: #F97316;
  152. color: #fff;
  153. font-weight: 600;
  154. }
  155. .empty-state {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. padding: 80rpx 0;
  160. }
  161. .empty-icon {
  162. font-size: 80rpx;
  163. margin-bottom: 20rpx;
  164. }
  165. .empty-text {
  166. font-size: 30rpx;
  167. color: #999;
  168. }
  169. .empty-hint {
  170. font-size: 24rpx;
  171. color: #ccc;
  172. margin-top: 8rpx;
  173. }
  174. .policy-card {
  175. background: #fff;
  176. border-radius: 20rpx;
  177. padding: 24rpx;
  178. margin-bottom: 20rpx;
  179. }
  180. .policy-header {
  181. display: flex;
  182. flex-direction: row;
  183. justify-content: space-between;
  184. align-items: center;
  185. margin-bottom: 16rpx;
  186. padding-bottom: 16rpx;
  187. border-bottom: 2rpx solid #f5f5f5;
  188. }
  189. .policy-name {
  190. font-size: 30rpx;
  191. font-weight: 600;
  192. color: #333;
  193. }
  194. .policy-status {
  195. font-size: 24rpx;
  196. padding: 4rpx 16rpx;
  197. border-radius: 8rpx;
  198. }
  199. .status-active {
  200. background: #DCFCE7;
  201. color: #16A34A;
  202. }
  203. .status-expired {
  204. background: #FEF2F2;
  205. color: #DC2626;
  206. }
  207. .status-cancelled {
  208. background: #F5F5F5;
  209. color: #999;
  210. }
  211. .policy-body {
  212. margin-bottom: 12rpx;
  213. }
  214. .policy-row {
  215. display: flex;
  216. flex-direction: row;
  217. justify-content: space-between;
  218. padding: 8rpx 0;
  219. }
  220. .policy-label {
  221. font-size: 26rpx;
  222. color: #999;
  223. }
  224. .policy-value {
  225. font-size: 26rpx;
  226. color: #333;
  227. }
  228. .policy-value.orange {
  229. color: #F97316;
  230. font-weight: 600;
  231. }
  232. .policy-footer {
  233. display: flex;
  234. flex-direction: row;
  235. justify-content: flex-end;
  236. padding-top: 12rpx;
  237. border-top: 2rpx solid #f5f5f5;
  238. }
  239. .delete-btn {
  240. font-size: 24rpx;
  241. color: #DC2626;
  242. padding: 8rpx 20rpx;
  243. }
  244. .add-btn-wrap {
  245. padding: 20rpx 0 40rpx;
  246. }
  247. .add-btn {
  248. width: 100%;
  249. height: 88rpx;
  250. line-height: 88rpx;
  251. text-align: center;
  252. background: #F97316;
  253. color: #fff;
  254. font-size: 30rpx;
  255. font-weight: 600;
  256. border-radius: 44rpx;
  257. border: none;
  258. }
  259. .add-btn::after {
  260. border: none;
  261. }
  262. </style>