add.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view>
  3. <uni-nav-bar statusBar backgroundColor="#fafafa" fixed title="添加好友" left-icon="left" @clickLeft="utils.navigateBack()" />
  4. <form @submit="formSubmit" >
  5. <view class="search fx-r fx-bc" >
  6. <image src="/static/chat/tb-seach.png"></image>
  7. <input name="keyword" v-model="keyword" class="fx-g1" @confirm="tapConfirm" type="text" confirm-type="搜索" placeholder="搜索手机号码" />
  8. <u-icon name="close-circle-fill" @tap="keyword = ''" v-if="keyword.length > 0" size="20"></u-icon>
  9. </view>
  10. </form>
  11. </view>
  12. </template>
  13. <script>
  14. import {mapState,mapMutations } from 'vuex';
  15. export default {
  16. data() {
  17. return {
  18. keyword:""
  19. }
  20. },
  21. onLoad(option){
  22. },
  23. methods: {
  24. formSubmit:function(ev){
  25. var text = this.keyword;
  26. if(text == "") return;
  27. },
  28. tapConfirm:function(ev){
  29. var value = ev.detail.value;
  30. if(value == "") return;
  31. uni.showLoading({ title: '获取数据中..'});
  32. var post = {};
  33. post.usercode = value;
  34. this
  35. .request
  36. .post("chatFindCode",post)
  37. .then(res => {
  38. uni.hideLoading();
  39. if(res.code == 200) {
  40. uni.navigateTo({
  41. url:"info?usercode=" + res.msg
  42. });
  43. } else {
  44. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  45. }
  46. })
  47. .catch(res=>{
  48. uni.hideLoading();
  49. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  50. });
  51. }
  52. }
  53. }
  54. </script>
  55. <style>
  56. .search{background: #fff;border-radius: 6px;margin: 0px 10px;padding: 10px;}
  57. .search image{width: 30px;height: 30px;}
  58. .search input{font-size: 14px;}
  59. </style>