addressbook.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <view class="booxbox">
  4. <view class="booxbox_item">
  5. <view class=""> 姓名 </view>
  6. <view class="booxbox_item_input">
  7. <u-input v-model="username" maxlength="15" />
  8. </view>
  9. </view>
  10. <view class="booxbox_item">
  11. <view class=""> 手机号 </view>
  12. <view class="booxbox_item_input">
  13. <u-input v-model="userphone" maxlength="15" />
  14. </view>
  15. </view>
  16. <view class="adduser" @click="add"> 添加 </view>
  17. </view>
  18. <view class="booxlist">
  19. <view class="booxlist_tiele"> 通讯录 </view>
  20. <view class="booxlist_item" v-for="item in userlist" :key="item.d_id">
  21. <view class="booxlist_item_f">
  22. {{ item.liaisons }}
  23. </view>
  24. <view class="booxlist_item_t">
  25. {{ item.phone }}
  26. </view>
  27. <view class="booxlist_item_i">
  28. <u-icon
  29. name="minus-circle"
  30. color="#FB4E4E"
  31. size="34"
  32. @click="del(item.d_id)"
  33. ></u-icon>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. username: '',
  44. userphone: '',
  45. userlist: [],
  46. };
  47. },
  48. methods: {
  49. async getuserlist() {
  50. const res = await this.$myRequest({
  51. url: '/api/api_gateway?method=device.device_sms_alert.user_warning_liaisons_list',
  52. data: {
  53. page: '1',
  54. page_size: '99999999',
  55. },
  56. });
  57. console.log(res);
  58. this.userlist = res.data;
  59. },
  60. async add() {
  61. if (this.username == '') {
  62. uni.showToast({
  63. title: '请填写姓名',
  64. icon: 'none',
  65. });
  66. } else if (this.userphone == '') {
  67. uni.showToast({
  68. title: '请填写手机号',
  69. icon: 'none',
  70. });
  71. } else if (!/^1(1|2|3|4|5|6|7|8|9)\d{9}$/.test(this.userphone)) {
  72. uni.showToast({
  73. title: '请选择正确的手机号格式',
  74. icon: 'none',
  75. });
  76. } else {
  77. const res = await this.$myRequest({
  78. url: '/api/api_gateway?method=device.device_sms_alert.create_user_warning_liaisons',
  79. data: {
  80. phone: this.userphone,
  81. user_name: this.username,
  82. },
  83. });
  84. if (res) {
  85. uni.showToast({
  86. title: '创建成功',
  87. icon: 'none',
  88. });
  89. this.getuserlist();
  90. }
  91. }
  92. },
  93. async del(id) {
  94. const res = await this.$myRequest({
  95. url: '/api/api_gateway?method=device.device_sms_alert.del_user_warning_liaisons',
  96. data: {
  97. d_id: id,
  98. },
  99. });
  100. if (res) {
  101. uni.showToast({
  102. title: '删除成功',
  103. icon: 'none',
  104. });
  105. this.getuserlist();
  106. }
  107. },
  108. },
  109. onLoad() {
  110. this.getuserlist();
  111. },
  112. };
  113. </script>
  114. <style lang="less">
  115. page {
  116. background-color: #f6f6fb;
  117. }
  118. .booxbox {
  119. width: 95%;
  120. margin: 20rpx auto;
  121. background-color: #fff;
  122. padding: 20rpx;
  123. box-sizing: border-box;
  124. border-radius: 5px;
  125. .booxbox_item {
  126. display: flex;
  127. line-height: 70rpx;
  128. justify-content: space-between;
  129. border-bottom: 1rpx solid #f2f2f2;
  130. padding: 20rpx 0;
  131. .booxbox_item_input {
  132. width: 70%;
  133. ::v-deep .uni-input-input {
  134. text-align: right;
  135. }
  136. }
  137. }
  138. .adduser {
  139. margin: 30rpx auto 20rpx;
  140. width: 80%;
  141. background-color: #14a478;
  142. padding: 20rpx 0;
  143. border-radius: 59px;
  144. text-align: center;
  145. color: #fff;
  146. }
  147. }
  148. .booxlist {
  149. width: 95%;
  150. margin: 20rpx auto;
  151. background-color: #fff;
  152. padding: 20rpx;
  153. box-sizing: border-box;
  154. border-radius: 5px;
  155. .booxlist_tiele {
  156. border-left: 8rpx solid #14a478;
  157. padding-left: 30rpx;
  158. margin-bottom: 30rpx;
  159. }
  160. .booxlist_item {
  161. display: flex;
  162. border-top: 1rpx solid #f2f2f2;
  163. padding: 30rpx 0;
  164. .booxlist_item_f {
  165. width: calc(100% - 320rpx);
  166. text-align: left;
  167. overflow: hidden; //溢出隐藏
  168. white-space: nowrap; //禁止换行
  169. text-overflow: ellipsis; //...
  170. }
  171. .booxlist_item_t {
  172. width: 270rpx;
  173. text-align: left;
  174. }
  175. .booxlist_item_i {
  176. width: 50rpx;
  177. text-align: center;
  178. }
  179. }
  180. }
  181. </style>