searchUser.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="container">
  3. <form @submit="searchUserInfo">
  4. <view class="search-form flex-row flex-start">
  5. <input name="phone" class="input" placeholder="手机号码" />
  6. <button form-type="submit" size="mini" type="primary" class="button">搜索</button>
  7. </view>
  8. </form>
  9. <view v-if="userInfo" class="result-form">
  10. <view class="form-item">
  11. <view class="form-label">用户ID</view>
  12. <view class="form-value">{{ userInfo.user_id }}</view>
  13. </view>
  14. <view class="form-item">
  15. <view class="form-label">用户所属总店</view>
  16. <view class="form-value">{{ userInfo.shop_name }}</view>
  17. </view>
  18. <view class="form-item">
  19. <view class="form-label">用户名</view>
  20. <view class="form-value">{{ userInfo.user_name }}</view>
  21. </view>
  22. <view class="form-item">
  23. <view class="form-label">手机</view>
  24. <view class="form-value">{{ userInfo.phone }}</view>
  25. </view>
  26. <view class="form-item no-border">
  27. <view class="form-label">微信昵称</view>
  28. <view class="form-value">{{ userInfo.nickname }}</view>
  29. </view>
  30. </view>
  31. <view v-if="userInfo" class="check-btn">
  32. <button type="warn" plain @tap="bindCheck">确定</button>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. // pages/searchUser/searchUser.js
  38. var config = require('../../common/config.js');
  39. var http = require('../../common/http.js');
  40. var common = require('../../common/common.js');
  41. var storage = require('../../common/storage.js');
  42. export default {
  43. data() {
  44. return {
  45. userInfo: null
  46. };
  47. }
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */,
  51. onLoad: function (options) {},
  52. methods: {
  53. searchUserInfo: function (e) {
  54. const phone = e.detail.value.phone;
  55. if (common.isEmpty(phone)) {
  56. common.simpleToast('请输入手机号码');
  57. return;
  58. }
  59. const that = this;
  60. http.postApi(
  61. config.API_CLIENT_GET_BY_PHONE,
  62. {
  63. phone: phone
  64. },
  65. function (resp) {
  66. if (resp.data.code === 200) {
  67. that.setData({
  68. userInfo: resp.data.data.userInfo
  69. });
  70. } else {
  71. common.simpleToast(resp.data.msg);
  72. }
  73. }
  74. );
  75. },
  76. bindCheck: function () {
  77. storage.setSearchClientUserInfo(this.userInfo);
  78. uni.navigateBack({
  79. delta: 1
  80. });
  81. }
  82. }
  83. };
  84. </script>
  85. <style>
  86. @import './searchUser.css';
  87. </style>