MobileHome.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="MH-box">
  3. <view class="pages-box">
  4. <view class="fs32 fc99">请输入您要查询的手机号码</view>
  5. <view class="inp-box">
  6. <input @input="mobileFun" class="inp" placeholder="手机号码" 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.province }}</view>
  20. </view>
  21. <view class="pglist fc99">
  22. <view class="pg-l fs32">城市:</view>
  23. <view class="pg-r fs32">{{ getdata.city }}</view>
  24. </view>
  25. <view class="pglist fc99">
  26. <view class="pg-l fs32">区号:</view>
  27. <view class="pg-r fs32">{{ getdata.areacode }}</view>
  28. </view>
  29. <view class="pglist fc99">
  30. <view class="pg-l fs32">邮编:</view>
  31. <view class="pg-r fs32">{{ getdata.zip }}</view>
  32. </view>
  33. <view class="pglist fc99 bd-n">
  34. <view class="pg-l fs32">运营商:</view>
  35. <view class="pg-r fs32">{{ getdata.company }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. mobile: '',
  45. show: false,
  46. getdata: {
  47. province: '',
  48. city: '',
  49. areacode: '',
  50. zip: '',
  51. company: ''
  52. }
  53. };
  54. },
  55. onShareAppMessage: function () {},
  56. methods: {
  57. mobileFun: function (e) {
  58. this.mobile= e.detail.value;
  59. },
  60. getdataFun: function (e) {
  61. var that = this;
  62. uni.showLoading({
  63. title: '加载中'
  64. });
  65. var a = this.mobile;
  66. if (false === /^1[3|4|5|7|8][0-9]\d{8}$/.test(a)) {
  67. uni.showToast({
  68. title: '输入不合法',
  69. icon: 'none',
  70. image: '/static/images/error.png',
  71. duration: 2000
  72. });
  73. return false;
  74. }
  75. uni.request({
  76. url: 'https://apis.juhe.cn/mobile/get?phone=' + a + '&key=f4e95fef6e241a9964ee5230c5e618fd',
  77. data: {},
  78. header: {
  79. 'content-type': 'application/json'
  80. },
  81. success: function (e) {
  82. uni.hideLoading();
  83. if ('200' == e.data.resultcode) {
  84. this.show=true;
  85. this.getdata=e.data.result;
  86. } else {
  87. uni.showModal({
  88. title: '提示',
  89. content: '查询失败',
  90. success: function (e) {
  91. that.show=false;
  92. }
  93. });
  94. }
  95. }
  96. });
  97. }
  98. }
  99. };
  100. </script>
  101. <style>
  102. @import './MobileHome.css';
  103. </style>