addressbook.vue 3.8 KB

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