family.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="">
  3. <view style="width: 100%;text-align: center;margin-top: 20rpx;" v-show="length==0">暂无数据</view>
  4. <uni-swipe-action>
  5. <uni-swipe-action-item :options="options" @click="onClick(item)" @change="change" v-for="(item,index) in data" :key="index">
  6. <view class="item">
  7. <view class="left" >
  8. <image src="../../static/youer.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-if="IdCard(item.cardNo)<=6"></image>
  9. <image src="../../static/shaonian.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-else-if="IdCard(item.cardNo)>=7 && IdCard(item.cardNo)<=12"></image>
  10. <image src="../../static/qingShao.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-else-if="IdCard(item.cardNo)>=13 && IdCard(item.cardNo)<=17"></image>
  11. <image src="../../static/young.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-else-if="IdCard(item.cardNo)>=18 && IdCard(item.cardNo)<=45"></image>
  12. <image src="../../static/zhongnian.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-else-if="IdCard(item.cardNo)>=46 && IdCard(item.cardNo)<=69"></image>
  13. <image src="../../static/old.png" style="width:140rpx;height:140rpx;border-radius: 20rpx;" v-else-if="IdCard(item.cardNo)>69"></image>
  14. </view>
  15. <view class="right">
  16. <view class="name">{{item.personName}}</view>
  17. <view class="phone">
  18. <text>手机号 :</text><text style="margin-left:15rpx">{{item.phoneNum}}</text>
  19. </view>
  20. <view class="idNumber">
  21. <text>身份证号 :</text><text style="margin-left:15rpx">{{item.cardNo}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </uni-swipe-action-item>
  26. </uni-swipe-action>
  27. <!-- 添加家人信息 -->
  28. <view class="btn" @tap="addFamily">添加家人信息</view>
  29. </view>
  30. </template>
  31. <script>
  32. import uniSwipeAction from '../../components/uni-swipe-action/uni-swipe-action.vue'
  33. import uniSwipeActionItem from '../../components/uni-swipe-action-item/uni-swipe-action-item.vue'
  34. export default {
  35. data() {
  36. return {
  37. length:0,//数据判断值
  38. data: [],//列表数据
  39. options: [{//左滑动数据
  40. text: '删除',
  41. style: {
  42. backgroundColor: '#dd524d'
  43. }
  44. }]
  45. }
  46. },
  47. mounted() {
  48. this.getListData()
  49. },
  50. components: {
  51. uniSwipeAction,
  52. uniSwipeActionItem
  53. },
  54. computed:{
  55. },
  56. methods: {
  57. //根据身份证号获取年龄
  58. IdCard(UUserCard) {
  59. var myDate = new Date();
  60. var month = myDate.getMonth() + 1;
  61. var day = myDate.getDate();
  62. var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
  63. if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
  64. age++;
  65. }
  66. return age
  67. },
  68. // 点击删除
  69. onClick(item) {
  70. uni.showModal({
  71. title: '提示',
  72. content: '您确定要删除当前数据吗?',
  73. success: (res) => {
  74. // 判断用户是选择确定还是取消
  75. if (res.confirm) {
  76. this.http.httpRequest('/wxapplet/owner/peopleInfor/family/del', 'post', {
  77. cardNo: item.cardNo,
  78. comtyId: item.comtyId,
  79. zzjgid: item.zzjgid
  80. }, true).then((res) => {
  81. console.log(res)
  82. // 判断接口是否请求成功
  83. if (res.code == 0) {
  84. uni.showToast({
  85. title:'删除成功',
  86. 'icon':'success'
  87. })
  88. this.getListData()
  89. } else {
  90. uni.showToast({
  91. title: res.msg,
  92. 'icon': 'none'
  93. })
  94. }
  95. })
  96. } else if (res.cancel) {
  97. }
  98. }
  99. })
  100. },
  101. // 获取列表数据
  102. getListData() {
  103. uni.showLoading({
  104. mask:true,
  105. title:'加载中'
  106. })
  107. this.http.httpRequest('/wxapplet/owner/peopleInfor/getfamily', 'get', {
  108. cardNo: uni.getStorageSync('idNumber'),
  109. comtyId: uni.getStorageSync('comtyId')
  110. }, true).then((res) => {
  111. console.log(res)
  112. if (res.code == 0) {
  113. uni.hideLoading()
  114. this.data = res.data.rows
  115. this.length=this.data.length
  116. } else {
  117. uni.hideLoading()
  118. uni.showToast({
  119. title: res.msg,
  120. 'icon': 'none'
  121. })
  122. }
  123. }).catch(()=>{
  124. uni.hideLoading()
  125. })
  126. },
  127. // 添加家人信息
  128. addFamily() {
  129. uni.navigateTo({
  130. url: "addFamily"
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style>
  137. .btn {
  138. width: 702rpx;
  139. height: 90rpx;
  140. background: rgba(41, 138, 253, 1);
  141. opacity: 1;
  142. border-radius: 18rpx;
  143. font-size: 32rpx;
  144. font-family: PingFang SC;
  145. font-weight: bold;
  146. line-height: 90rpx;
  147. color: rgba(255, 255, 255, 1);
  148. text-align: center;
  149. position: fixed;
  150. left: 26rpx;
  151. bottom: 56rpx;
  152. }
  153. .idNumber {
  154. width: 100%;
  155. height: 34rpx;
  156. font-size: 24rpx;
  157. font-family: PingFang SC;
  158. font-weight: 400;
  159. line-height: 34rpx;
  160. color: rgba(51, 51, 51, 1);
  161. }
  162. .name {
  163. width: 100%;
  164. height: 44rpx;
  165. font-size: 32rpx;
  166. font-family: PingFang SC;
  167. font-weight: bold;
  168. line-height: 44px;
  169. color: rgba(51, 51, 51, 1);
  170. }
  171. .phone {
  172. width: 100%;
  173. height: 34rpx;
  174. font-size: 24rpx;
  175. font-family: PingFang SC;
  176. font-weight: 400;
  177. line-height: 34rpx;
  178. color: rgba(51, 51, 51, 1);
  179. margin-top: 28rpx;
  180. margin-left: 26rpx;
  181. }
  182. .left {
  183. width: 140rpx;
  184. height: 140rpx;
  185. border-radius: 20rpx;
  186. margin-top: 40rpx;
  187. }
  188. .right {
  189. width: 100%;
  190. margin-left: 20rpx;
  191. margin-top: 40rpx;
  192. }
  193. .item {
  194. width: 680rpx;
  195. height: 220rpx;
  196. border-bottom: 2rpx solid rgba(247, 247, 247, 1);
  197. ;
  198. margin: 0 auto;
  199. display: flex;
  200. }
  201. </style>