selectcompany.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="center">
  3. <!-- <view class="fixed1"></view> -->
  4. <luo-nav-bar @leftClick='navback' :searchText='searchText' @rightClick='cancel' @input='companyInput'
  5. :isSearch="true" :isPlaceText='true' placeText='输入企业名称' rightText='取消' leftIcon='back'></luo-nav-bar>
  6. <view v-if='searching' style='padding:10px;'>
  7. <view style='color:#999;margin-bottom:40px;font-size:14px;' v-if='more'>#输入更多关键字精准获取企业</view>
  8. <view @click='checkcompany(item)' class='company' v-for='item in companyList'>
  9. <rich-text :nodes="item.colorcompanyName"></rich-text>
  10. <view class='flex items-center align-center'>
  11. <view class='legal_person'>法人</view>
  12. <view>{{item.legalPersonName1}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view style='margin-left:20px;' v-if='!searching'>
  17. <view>最近搜索</view>
  18. <view @click='clicksearch(item)' class='historysearch' :style="{'margin-left':index==0 ? '0':'10px'}"
  19. v-for='(item,index) in history'>{{item.searchContent}}</view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapState
  26. } from 'vuex';
  27. import luoNavBar from '@/components/luo-navBar/components/luo-navBar/luo-navBar.vue';
  28. export default {
  29. data() {
  30. return {
  31. more: false,
  32. companyList: [],
  33. lastTime: 0,
  34. history: [],
  35. searching: false,
  36. searchText: ''
  37. }
  38. },
  39. components: {
  40. luoNavBar
  41. },
  42. computed: {
  43. ...mapState(['hasLogin', 'userInfo']),
  44. },
  45. onLoad() {
  46. this.$request.baseRequest('get', '/searchRecordsInfo/selectSearchRecordsInfo', {
  47. functionType: 1,
  48. commonId: this.userInfo.id
  49. }).then(res => {
  50. this.history = res.data.records
  51. })
  52. .catch(res => {
  53. uni.showToast({
  54. title: res.message,
  55. icon: 'none',
  56. duration: 2000
  57. })
  58. });
  59. },
  60. methods: {
  61. navback() {
  62. uni.navigateBack({})
  63. },
  64. cancel() {
  65. this.searchText = ''
  66. this.searching = false
  67. this.companyList = []
  68. },
  69. join(str, key) {
  70. var reg = new RegExp((`(${key})`), "gm");
  71. var replace = '<span style="color:#2772FB;">$1</span>';
  72. return str.replace(reg, replace);
  73. },
  74. clicksearch(item) {
  75. this.searchText = item.searchContent
  76. this.companyInput('', this.searchText)
  77. // this.s
  78. },
  79. checkcompany(item) {
  80. var that=this
  81. // console.log(item,this.userInfo)
  82. uni.showLoading({
  83. title: '加载中',
  84. mask: true
  85. })
  86. this.$request.baseRequest('get', '/cargoOwnerInfo/selectCargoOwner', {
  87. commonId: this.userInfo.id
  88. }).then(res => {
  89. uni.hideLoading()
  90. if (res.data) {
  91. if(res.data.name==item.legalPersonName){
  92. uni.showToast({
  93. title: '您已经具备该公司货主身份',
  94. icon: 'none',
  95. duration: 2000
  96. })
  97. }else if(res.data.hyCargoOwnerCompInfoList){
  98. res.data.hyCargoOwnerCompInfoList.every(items=>{
  99. console.log(items.company,item.companyName)
  100. })
  101. if(res.data.hyCargoOwnerCompInfoList.every(items=>{
  102. return items.company!=item.companyName
  103. })){
  104. uni.setStorageSync('currectcompany', item)
  105. that.goDetailPage('pages/mine/cargoowner/addEnerprise')
  106. }else{
  107. for (var i = 0; i < res.data.hyCargoOwnerCompInfoList.length; i++) {
  108. if(res.data.hyCargoOwnerCompInfoList[i].company==item.companyName){
  109. uni.showToast({
  110. title: '该企业已认证过,删除后才可以再次选中该企业',
  111. icon: 'none',
  112. duration: 2000
  113. })
  114. }
  115. }
  116. }
  117. }else{
  118. uni.setStorageSync('currectcompany', item)
  119. that.goDetailPage('pages/mine/cargoowner/addEnerprise')
  120. }
  121. }
  122. })
  123. .catch(res => {
  124. uni.hideLoading()
  125. uni.showToast({
  126. title: res.message,
  127. icon: 'none',
  128. duration: 2000
  129. })
  130. });
  131. // if(){
  132. // }
  133. console.log(12331)
  134. },
  135. goDetailPage(src) {
  136. // uni.$u.route(src);
  137. uni.navigateBack({
  138. delta:1
  139. })
  140. },
  141. currectsearch(value) {
  142. var _this = this
  143. var arr = [],
  144. filterArr = []
  145. if(value){
  146. this.$request.baseRequest('post', '/searchRecordsInfo/api/addInfo', {
  147. functionType: 1,
  148. commonId: this.userInfo.id,
  149. searchContent: value
  150. }).then(res => {})
  151. .catch(res => {
  152. uni.showToast({
  153. title: res.message,
  154. icon: 'none',
  155. duration: 2000
  156. })
  157. });
  158. }
  159. this.$request.baseRequest('get', '/companyInfo/selectAllCompany', {
  160. searchKeyWord: value
  161. }).then(res => {
  162. uni.hideLoading()
  163. var len = 0
  164. console.log(res)
  165. if (res.data.records.length > 10) {
  166. _this.more = true
  167. len = 10
  168. } else {
  169. len = res.data.records.length
  170. _this.more = false
  171. }
  172. for (var i = 0; i < len; i++) {
  173. var len2=res.data.records[i].legalPersonName.length
  174. var name=''
  175. for (var q = 0; q < len2; q++) {
  176. name+='*'
  177. }
  178. res.data.records[i].legalPersonName1=name.substr(0, name.length - 1) + res.data.records[i].legalPersonName[len2-1]
  179. // console.log(res.data.records[i])
  180. res.data.records[i].colorcompanyName = res.data.records[i].companyName
  181. res.data.records[i].colorcompanyName = _this.join(res.data.records[i].colorcompanyName,
  182. value)
  183. arr.push(res.data.records[i])
  184. }
  185. _this.companyList = arr
  186. console.log(arr)
  187. })
  188. .catch(res => {
  189. uni.hideLoading()
  190. uni.showToast({
  191. title: res.message,
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. });
  196. },
  197. companyInput(e, value) {
  198. var _this = this
  199. this.searching = true
  200. uni.showLoading({
  201. title: '加载中',
  202. mask: true
  203. })
  204. if (this.lastTime == 0) {
  205. this.lastTime = setTimeout(() => {
  206. if(e){
  207. _this.currectsearch(e.detail.value)
  208. }else{
  209. _this.currectsearch(value)
  210. }
  211. }, 2000)
  212. } else {
  213. clearTimeout(this.lastTime)
  214. this.lastTime = setTimeout(() => {
  215. if(e){
  216. _this.currectsearch(e.detail.value)
  217. }else{
  218. _this.currectsearch(value)
  219. }
  220. }, 2000)
  221. }
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang='scss' scoped>
  227. /deep/.u-navbar__content {
  228. /deep/>.u-nav-solt {
  229. width: 90%;
  230. }
  231. }
  232. .center{
  233. margin-top:30px;
  234. }
  235. .legal_person {
  236. color: #2772FB;
  237. font-size: 20rpx;
  238. border: 1px solid #2772FB;
  239. padding: 4rpx 6rpx;
  240. border-radius: 10rpx;
  241. margin: 8rpx 10rpx 8rpx 0;
  242. }
  243. .company {
  244. padding-bottom: 80rpx;
  245. }
  246. .historysearch {
  247. background: #F5F6FA;
  248. display: inline-block;
  249. padding: 10rpx 20rpx;
  250. margin: 15rpx 20rpx;
  251. border-radius: 10rpx;
  252. }
  253. .fixed1 {
  254. top: 0;
  255. height: var(--status-bar-height);
  256. }
  257. </style>