index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="search-page white-wrap">
  3. <van-sticky>
  4. <view class="white-wrap" style="padding: 20rpx 34rpx 10rpx 34rpx;">
  5. <van-search use-left-icon-slot use-action-slot shape="round" focus :placeholder="placeholder" @change="onChange"
  6. @search="onSearch" custom-class="search-box" field-class="search-con">
  7. <view slot="left-icon">
  8. <image src="../static/search-icon.png" mode="aspectFill" class="search-icon"></image>
  9. </view>
  10. <view slot="action" @click="onSearch" class="search-btn">搜索</view>
  11. </van-search>
  12. </view>
  13. </van-sticky>
  14. <van-empty description="未找到搜索结果" :image="require('@/static/empty.png')" v-if="empty" />
  15. <view class="search-result" v-else>
  16. <view class="result-item flex" v-for="item in list" :key="item" @click="handleGoDetail(item)">
  17. <image src="../static/search-icon.png" mode="aspectFill" class="search-icon"></image>
  18. <view class="con van-ellipsis">{{ type==='roadshow' ? item.CompanyName : item}}</view>
  19. <image src="../static/click-icon.png" mode="aspectFill" class="click-icon"></image>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {apiCustomeSearch} from '@/api/approve/custome.js'
  26. import {apiContractSearch} from '@/api/approve/contract.js'
  27. import {apiSealSearch} from '@/api/approve/seal.js'
  28. import { companySearch } from '@/api/roadshow/index.js';
  29. export default {
  30. data() {
  31. return {
  32. value: '',
  33. placeholder: '',
  34. type: '',
  35. list: [],
  36. empty:false,
  37. }
  38. },
  39. onLoad(options) {
  40. this.type = options.type;
  41. this.initPage(options.type)
  42. },
  43. methods: {
  44. // 初始化界面
  45. initPage(type) {
  46. let navBarTitle = ''
  47. switch (type) {
  48. case 'custome':
  49. navBarTitle = '客户审批'
  50. this.placeholder = '客户名称/社会信用码'
  51. break;
  52. case 'contract':
  53. navBarTitle = '合同审批'
  54. this.placeholder = '客户名称/社会信用码'
  55. break;
  56. case 'seal':
  57. navBarTitle = '用印审批'
  58. this.placeholder = '客户名称/社会信用码'
  59. break;
  60. case 'roadshow':
  61. navBarTitle = '客户搜索'
  62. this.placeholder = '客户名称'
  63. break;
  64. case 'question':
  65. navBarTitle = '分配提问'
  66. this.placeholder = '提问内容'
  67. break;
  68. case 'comment':
  69. navBarTitle = '评论管理'
  70. this.placeholder = '评论管理'
  71. break;
  72. case 'videoComment':
  73. navBarTitle = '评论管理'
  74. this.placeholder = '评论管理'
  75. break;
  76. }
  77. uni.setNavigationBarTitle({
  78. title: navBarTitle
  79. })
  80. },
  81. //跳转搜索结果页
  82. handleGoDetail(e) {
  83. // 如果是合同则跳转合同搜索结果页 否则跳转公共的搜索结果页
  84. if(this.type==='contract'){
  85. uni.navigateTo({
  86. url:"/pages-approve/contract/search?val="+e
  87. })
  88. }else if(this.type==='roadshow'){
  89. let id = uni.setStorageSync('roadshow_compantyId',e.CompanyId)
  90. let englishCompany = uni.setStorageSync('roadshow_isEnglishCompany',e.EnglishCompany)
  91. uni.navigateBack({
  92. delta: 1
  93. });
  94. }else{
  95. uni.navigateTo({
  96. url:`./result?type=${this.type}&val=${e}`
  97. })
  98. }
  99. },
  100. // 客户审批搜索
  101. async handleCustome() {
  102. const res = await apiCustomeSearch({
  103. Keyword: this.value,
  104. })
  105. if (res.code === 200) {
  106. this.list = res.data
  107. if(res.data.length===0){
  108. this.empty=true
  109. }else{
  110. this.empty=false
  111. }
  112. }
  113. },
  114. // 合同审批搜索
  115. async handleContract() {
  116. const res = await apiContractSearch({
  117. Keyword: this.value,
  118. })
  119. if (res.code === 200) {
  120. this.list = res.data
  121. if(res.data.length===0){
  122. this.empty=true
  123. }else{
  124. this.empty=false
  125. }
  126. }
  127. },
  128. //用印搜索
  129. async handleSeal(){
  130. const res=await apiSealSearch({
  131. Keyword: this.value,
  132. })
  133. if (res.code === 200) {
  134. this.list = res.data
  135. if(res.data.length===0){
  136. this.empty=true
  137. }else{
  138. this.empty=false
  139. }
  140. }
  141. },
  142. /* 路演客户名称搜索 */
  143. async companySearchHandle() {
  144. const { code,data } = await companySearch({
  145. KeyWord: this.value
  146. })
  147. if(code !== 200) return
  148. this.list = data;
  149. if(data.length===0){
  150. this.empty=true
  151. }else{
  152. this.empty=false
  153. }
  154. },
  155. onChange(e) {
  156. this.value = e.detail
  157. },
  158. /* 跳回问答和评论 */
  159. questionBackHandle() {
  160. uni.$emit('questionListUpdate', {
  161. key_word: this.value
  162. })
  163. uni.navigateBack({
  164. delta: 1
  165. });
  166. },
  167. //跳回视频社区问题
  168. videoBackHandle(){
  169. uni.$emit('videoCommentUpdate', {
  170. key_word: this.value
  171. })
  172. uni.navigateBack({
  173. delta: 1
  174. });
  175. },
  176. onSearch() {
  177. if(!this.value){
  178. uni.showToast({
  179. title:'请输入搜索关键字',
  180. icon:'none'
  181. })
  182. return
  183. }
  184. const handleFn = {
  185. custome: this.handleCustome,
  186. contract: this.handleContract,
  187. seal: this.handleSeal,
  188. roadshow: this.companySearchHandle,
  189. question: this.questionBackHandle,
  190. comment: this.questionBackHandle,
  191. videoComment:this.videoBackHandle
  192. }
  193. handleFn[this.type]();
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. .search-page {
  200. width: 100%;
  201. min-height: 100vh;
  202. // padding: 20rpx 34rpx;
  203. }
  204. .search-box {
  205. border: 1px solid #3385FF;
  206. padding: 0 !important;
  207. border-radius: 60rpx;
  208. background-color: #fff !important;
  209. }
  210. .search-con {
  211. background-color: #fff !important;
  212. }
  213. .van-search__content {
  214. background-color: #fff !important;
  215. padding-left: 30rpx !important;
  216. }
  217. .search-btn {
  218. position: relative;
  219. color: #3385FF;
  220. padding-right: 10rpx;
  221. &::before {
  222. content: '';
  223. display: block;
  224. width: 1px;
  225. height: 60%;
  226. background-color: #D1D1D1;
  227. position: absolute;
  228. left: -16rpx;
  229. top: 20%;
  230. }
  231. }
  232. .search-icon {
  233. width: 40rpx;
  234. height: 40rpx;
  235. display: block;
  236. position: relative;
  237. top: 4rpx;
  238. margin-right: 20rpx;
  239. }
  240. .click-icon {
  241. width: 24rpx;
  242. height: 24rpx;
  243. }
  244. .search-result{
  245. padding: 20rpx 34rpx;
  246. }
  247. .result-item {
  248. align-items: center;
  249. padding: 20rpx 0;
  250. border-bottom: 1px solid #EBEBEB;
  251. .con {
  252. flex: 1;
  253. margin-right: 20rpx;
  254. }
  255. }
  256. </style>