codePars.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="IDCard-box">
  3. <view class="pages-box">
  4. <view class="fs32 fc99">请输入您要查询的文字</view>
  5. <view class="inp-box">
  6. <input @input="codeFun" 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 bd-n">
  18. <view class="pg-l fs32">电码:</view>
  19. <view class="pg-r fs32">{{ getdata.telecodes }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. code: '',
  29. show: false,
  30. getdata: {
  31. telecodes: ''
  32. }
  33. };
  34. },
  35. onShareAppMessage: function () {},
  36. methods: {
  37. codeFun: function (t) {
  38. this.code=t.detail.value;
  39. },
  40. getdataFun: function (t) {
  41. var that = this;
  42. uni.showLoading({
  43. title: '加载中'
  44. });
  45. var e = this.code;
  46. uni.request({
  47. url: 'https://v.juhe.cn/telecode/to_telecodes.php?chars=' + e + '&key=3aa4901b44d02790f816f414284a1391',
  48. data: {},
  49. header: {
  50. 'content-type': 'application/json'
  51. },
  52. success: function (t) {
  53. uni.hideLoading();
  54. if ('success' == t.data.reason) {
  55. that.show=true;
  56. that.getdata=t.data.result;
  57. } else {
  58. uni.showModal({
  59. title: '提示',
  60. content: '查询失败',
  61. success: function (t) {
  62. that.show=false;
  63. }
  64. });
  65. }
  66. }
  67. });
  68. }
  69. }
  70. };
  71. </script>
  72. <style>
  73. @import './codePars.css';
  74. </style>