index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="top">
  3. <view style="margin: 20px 15px 15px 15px; border: 1px solid #a4a4a4;border-radius: 10px;">
  4. <u--input v-model="text" placeholder="姓名 / 手机号" prefixIcon="search"
  5. prefixIconStyle="font-size: 22px;color: #909399" @focus="searchFocus" @blur="searchBlur"
  6. @input="doSearch()">
  7. </u--input>
  8. </view>
  9. <view v-if="showSearch">
  10. <u-row v-for="item in groupList" customStyle="margin: 5px 0" @click="toGroupAbPage(item.groupMember)">
  11. <u-col span="2">
  12. <view class="demo-layout bg-purple-light">
  13. <image src="../../static/img/msg/gzqz.png" style="margin-left: 10px;width: 50px;height: 50px;">
  14. </image>
  15. </view>
  16. </u-col>
  17. <u-col span="9">
  18. <view class="demo-layout bg-purple">
  19. <u-text :text="item.groupName" size="14"></u-text>
  20. </view>
  21. </u-col>
  22. </u-row>
  23. </view>
  24. <view v-if="showSearch">
  25. <view style="color: #a4a4a4;padding: 5px;background-color: #ffffff;">部门分类</view>
  26. <uni-list v-for="item in bmList">
  27. <uni-list-item :clickable="true" @click="toAbListPage(item.deptId)" :title="item.deptName" />
  28. </uni-list>
  29. </view>
  30. <view v-if="!showSearch" style="border-top: 1px solid #eeeeee;">
  31. <view class="row uni-flex uni-row" v-for="friend in result">
  32. <view style="padding: 5rpx 0 0 20rpx" @click="toVisitingCard(friend)">
  33. <u-text :text="friend.name+' '+friend.phone" size="18" color="#a5a5a5"></u-text>
  34. </view>
  35. </view>
  36. <view style="height: 40px;">
  37. </view>
  38. </view>
  39. <view style="height: 40px;">
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. text: '',
  48. result: [],
  49. data: [],
  50. showSearch: true,
  51. BaseUrl: this.$BASE_URL,
  52. list: [],
  53. qiyes: [{
  54. id: 1,
  55. name: '中山大学',
  56. src: '../../static/img/tab-icon/me-active.png'
  57. },
  58. {
  59. id: 2,
  60. name: '阿里巴巴',
  61. src: '../../static/img/tab-icon/me-active.png'
  62. }
  63. ],
  64. stars: [{
  65. id: 1,
  66. name: '1',
  67. src: '../../static/img/tab-icon/me-active.png'
  68. },
  69. {
  70. id: 2,
  71. name: '2',
  72. src: '../../static/img/tab-icon/me-active.png'
  73. }
  74. ],
  75. friends: [],
  76. bmList: [],
  77. groupList: [],
  78. isSearch: false,
  79. searchCount: 0
  80. }
  81. },
  82. onLoad() {
  83. this.getBmData()
  84. },
  85. onShow() {
  86. this.getBmData()
  87. this.getabData()
  88. this.getGcData()
  89. },
  90. methods: {
  91. toVisitingCard(friend) {
  92. console.log(this.result)
  93. uni.setStorageSync('data', friend)
  94. uni.navigateTo({
  95. url: '/pageA/msg/visitingCard'
  96. })
  97. },
  98. doSearch(value) {
  99. let that = this
  100. let count = this.searchCount++
  101. if (value) {
  102. this.result = []
  103. this.data.forEach(i => {
  104. if (that.isSearch) {
  105. // setTimeout(() => {
  106. i.children.forEach(t => {
  107. if (that.isSearch) {
  108. var tc = t
  109. if (that.isZhOrNumber(value) === 'ZH') {
  110. if (tc.name.indexOf(value) != -1) {
  111. that.result.push(tc)
  112. }
  113. } else if (that.isZhOrNumber(value) === 'NUM') {
  114. if (value.length >= 2) {
  115. let zzbds = new RegExp("^" + value + "[0-9]+")
  116. if (zzbds.test(tc.phone)) {
  117. that.result.push(tc)
  118. }
  119. } else {
  120. this.result = []
  121. }
  122. }
  123. }
  124. })
  125. // }, 10)
  126. }
  127. })
  128. }
  129. },
  130. isZhOrNumber(str) {
  131. //验证是否是汉字
  132. var pattern = new RegExp("[\u4E00-\u9FA5]+");
  133. if (pattern.test(str)) {
  134. return 'ZH'
  135. }
  136. //验证是否是数字
  137. var pattern3 = new RegExp("[0-9]+");
  138. if (pattern3.test(str)) {
  139. return 'NUM'
  140. }
  141. },
  142. searchFocus() {
  143. this.showSearch = false
  144. this.isSearch = true
  145. this.result = []
  146. },
  147. searchBlur() {
  148. this.isSearch = false
  149. this.text = null
  150. this.showSearch = true
  151. },
  152. toAbListPage(deptId) {
  153. uni.setStorageSync("deptId", deptId)
  154. this.$goto("abList")
  155. },
  156. toGroupAbPage(data) {
  157. uni.setStorageSync("groupUserCode", data)
  158. this.$goto("groupAb")
  159. },
  160. bindClick(e) {
  161. console.log('点击item,返回数据' + JSON.stringify(e))
  162. },
  163. async getGcData() {
  164. const {
  165. data: res
  166. } = await this.$httpRequest({
  167. url: '/api/ci/gl?un=' + uni.getStorageSync('userInfo').userName,
  168. method: 'get',
  169. })
  170. if (res.code == 200) {
  171. this.groupList = res.data
  172. } else {
  173. uni.showToast({
  174. icon: 'none',
  175. title: res.msg
  176. })
  177. }
  178. },
  179. async getBmData() {
  180. const {
  181. data: res
  182. } = await this.$httpRequest({
  183. url: '/api/ci/abDepts?un=' + uni.getStorageSync('userInfo').userName + "&oc=" + uni
  184. .getStorageSync("orgInfo").organizationCode,
  185. method: 'get',
  186. })
  187. if (res.code == 200) {
  188. this.bmList = res.data
  189. } else {
  190. uni.showToast({
  191. icon: 'none',
  192. title: res.msg
  193. })
  194. }
  195. },
  196. async getabData() {
  197. const {
  198. data: res
  199. } = await this.$httpRequest({
  200. url: '/api/ci/ab?un=all',
  201. method: 'get',
  202. })
  203. if (res.code == 200) {
  204. this.data = res.data
  205. }
  206. },
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. page {
  212. background: #fefefe;
  213. }
  214. .row {
  215. background: white;
  216. display: flex;
  217. width: 100%;
  218. height: 80rpx;
  219. border-bottom: 1px solid #eeeeee;
  220. .row_logo {
  221. width: 20%;
  222. display: flex;
  223. align-items: center;
  224. image {
  225. width: 80px;
  226. height: 80px;
  227. margin: auto;
  228. border-radius: 5px;
  229. }
  230. }
  231. .row_left {
  232. height: 100%;
  233. width: 40%;
  234. display: flex;
  235. align-items: center;
  236. border: {
  237. bottom: 1px solid #DDDDDD;
  238. }
  239. text {
  240. font-size: 16px;
  241. font-family: 'syht';
  242. display: block;
  243. }
  244. }
  245. .row_right {
  246. height: 100%;
  247. width: 40%;
  248. display: flex;
  249. align-items: center;
  250. border: {
  251. bottom: 1px solid #DDDDDD;
  252. }
  253. text {
  254. font-size: 16px;
  255. font-family: 'syht';
  256. display: block;
  257. }
  258. }
  259. }
  260. .row:last-child {
  261. .row_right {
  262. border: 0;
  263. }
  264. }
  265. .qu {
  266. .tip {
  267. margin: 3px 0;
  268. font-size: 14px;
  269. font-family: 'syht';
  270. text {
  271. margin-left: 13px;
  272. }
  273. }
  274. }
  275. </style>