family.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <view class="top-back"></view>
  4. <view class="content">
  5. <view v-if="!family_list || Object.keys(family_list).length === 0" class="no_data"></view>
  6. <view v-else v-for="(value, key) in family_list" :key="key" class="family-item">
  7. <view @longpress="check_del_family(key)" @click="$util.navigateTo(`/pages/my/family/family_info/family_info?id=${key}`)" class="flex justify-between">
  8. <view>
  9. <view class="flex justify-start margin-bottom-xs">
  10. <text class="name center">{{value['name']}}</text>
  11. <text v-if="value['relationship']" class="relationship center">{{value['relationship']}}</text>
  12. </view>
  13. <text class="gender">性别:{{ value['gender'] === 0 ? '男' : (value['gender'] === 1 ? '女' : '未知') }}</text>
  14. <text v-if="value['age']" class="age">年龄:{{value['age']}}岁</text>
  15. </view>
  16. <text class="cuIcon-right center"></text>
  17. </view>
  18. </view>
  19. <uv-gap height="60"></uv-gap>
  20. <button @click="$util.navigateTo('/pages/my/family/family_info/family_info')" class="bottom-button center">新增成员</button>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. onShow() {
  27. this.family_list = uni.getStorageSync('family_list');
  28. },
  29. onPullDownRefresh() {
  30. this.family_list = uni.getStorageSync('family_list');
  31. },
  32. data() {
  33. return {
  34. family_list: null,
  35. }
  36. },
  37. methods: {
  38. check_del_family(key){
  39. uni.showModal({
  40. title: '删除成员',
  41. content: ' 是否要删除此成员?',
  42. success: (res) => {
  43. if (res.confirm) this.del_family(key);
  44. }
  45. })
  46. },
  47. del_family(key){
  48. let family_list = uni.getStorageSync('family_list');
  49. delete family_list[key];
  50. this.family_list = family_list;
  51. uni.setStorageSync('family_list', family_list);
  52. this.$forceUpdate();
  53. },
  54. }
  55. }
  56. </script>
  57. <style lang="less" scoped>
  58. .family-item{
  59. background-color: #fff;
  60. border-radius: 20px;
  61. height: 80px;
  62. margin-top: 20px;
  63. padding: 15px;
  64. color: #666;
  65. letter-spacing: 1px;
  66. .name{
  67. letter-spacing: 2px;
  68. font-size: 20px;
  69. font-weight: 550;
  70. color: #555;
  71. }
  72. .gender{
  73. margin-right: 20px;
  74. }
  75. .relationship{
  76. color: #555;
  77. font-size: 17px;
  78. height: 28px;
  79. width: 75px;
  80. border-radius: 10px;
  81. letter-spacing: 0px;
  82. margin-left: 20px;
  83. background-color: #ebf6ff;
  84. }
  85. }
  86. .top-back{
  87. height: 35px;
  88. background-color: #1678ff;
  89. color: #fff;
  90. margin-bottom: -25px;
  91. }
  92. .content{
  93. padding: 10px 20px;
  94. border-radius: 25px 25px 0 0;
  95. border: none;
  96. background-color: #f6f6f6;
  97. height: 100vh;
  98. }
  99. </style>