IP.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="ip-box">
  3. <view class="pages-box">
  4. <view class="fs32 fc99">请输入您要查询的IP地址</view>
  5. <view class="inp-box">
  6. <input @input="ipFun" class="inp" placeholder="例如:188.188.188.188" placeholderStyle="font-size:30rpx" />
  7. <view class="inpimg">
  8. <image class="pagesimg" src="@/static/images/search.png"></image>
  9. </view>
  10. </view>
  11. <view class="btn-box">
  12. <button @tap="getdataFun" class="btn fs32">查 询</button>
  13. </view>
  14. </view>
  15. <view :class="'det-box ' + (show ? '' : 'dp-n')">
  16. <view class="pg-t fs36 fc99">详细信息</view>
  17. <view class="pglist fc99">
  18. <view class="pg-l fs32">国家:</view>
  19. <view class="pg-r fs32">{{ getdata.Country }}</view>
  20. </view>
  21. <view class="pglist fc99">
  22. <view class="pg-l fs32">省份:</view>
  23. <view class="pg-r fs32">{{ getdata.Province }}</view>
  24. </view>
  25. <view class="pglist fc99">
  26. <view class="pg-l fs32">城市:</view>
  27. <view class="pg-r fs32">{{ getdata.City }}</view>
  28. </view>
  29. <view class="pglist fc99 bd-n">
  30. <view class="pg-l fs32">运营商:</view>
  31. <view class="pg-r fs32">{{ getdata.Isp }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. ip: '',
  41. show: false,
  42. getdata: {
  43. Country: '',
  44. Province: '',
  45. City: '',
  46. Isp: ''
  47. }
  48. };
  49. },
  50. onShareAppMessage: function () {},
  51. methods: {
  52. ipFun: function (t) {
  53. this.ip=t.detail.value;
  54. },
  55. getdataFun: function (t) {
  56. var that = this;
  57. uni.showLoading({
  58. title: '加载中'
  59. });
  60. var e = this.ip;
  61. if ('' == e) {
  62. uni.showToast({
  63. title: '输入不合法',
  64. icon: 'none',
  65. image: '/static/images/error.png',
  66. duration: 2000
  67. });
  68. return false;
  69. }
  70. uni.request({
  71. url: 'https://apis.juhe.cn/ip/ipNew?ip=' + e + '&key=9a77a7c215a0b4dbdf2854fd2e02202c',
  72. data: {},
  73. header: {
  74. 'Content-Type': 'application/json'
  75. },
  76. success: function (t) {
  77. uni.hideLoading();
  78. if ('200' == t.data.resultcode) {
  79. this.show=true;
  80. this.getdata=t.data.result;
  81. } else {
  82. uni.showModal({
  83. title: '提示',
  84. content: '查询失败',
  85. success: function (t) {
  86. that.show=false;
  87. }
  88. });
  89. }
  90. }
  91. });
  92. }
  93. }
  94. };
  95. </script>
  96. <style>
  97. @import './IP.css';
  98. </style>