index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. uni.navigateBack({
  91. delta: 1
  92. });
  93. }else{
  94. uni.navigateTo({
  95. url:`./result?type=${this.type}&val=${e}`
  96. })
  97. }
  98. },
  99. // 客户审批搜索
  100. async handleCustome() {
  101. const res = await apiCustomeSearch({
  102. Keyword: this.value,
  103. })
  104. if (res.code === 200) {
  105. this.list = res.data
  106. if(res.data.length===0){
  107. this.empty=true
  108. }else{
  109. this.empty=false
  110. }
  111. }
  112. },
  113. // 合同审批搜索
  114. async handleContract() {
  115. const res = await apiContractSearch({
  116. Keyword: this.value,
  117. })
  118. if (res.code === 200) {
  119. this.list = res.data
  120. if(res.data.length===0){
  121. this.empty=true
  122. }else{
  123. this.empty=false
  124. }
  125. }
  126. },
  127. //用印搜索
  128. async handleSeal(){
  129. const res=await apiSealSearch({
  130. Keyword: this.value,
  131. })
  132. if (res.code === 200) {
  133. this.list = res.data
  134. if(res.data.length===0){
  135. this.empty=true
  136. }else{
  137. this.empty=false
  138. }
  139. }
  140. },
  141. /* 路演客户名称搜索 */
  142. async companySearchHandle() {
  143. const { code,data } = await companySearch({
  144. KeyWord: this.value
  145. })
  146. if(code !== 200) return
  147. this.list = data;
  148. if(data.length===0){
  149. this.empty=true
  150. }else{
  151. this.empty=false
  152. }
  153. },
  154. onChange(e) {
  155. this.value = e.detail
  156. },
  157. /* 跳回问答和评论 */
  158. questionBackHandle() {
  159. uni.$emit('questionListUpdate', {
  160. key_word: this.value
  161. })
  162. uni.navigateBack({
  163. delta: 1
  164. });
  165. },
  166. //跳回视频社区问题
  167. videoBackHandle(){
  168. uni.$emit('videoCommentUpdate', {
  169. key_word: this.value
  170. })
  171. uni.navigateBack({
  172. delta: 1
  173. });
  174. },
  175. onSearch() {
  176. if(!this.value){
  177. uni.showToast({
  178. title:'请输入搜索关键字',
  179. icon:'none'
  180. })
  181. return
  182. }
  183. const handleFn = {
  184. custome: this.handleCustome,
  185. contract: this.handleContract,
  186. seal: this.handleSeal,
  187. roadshow: this.companySearchHandle,
  188. question: this.questionBackHandle,
  189. comment: this.questionBackHandle,
  190. videoComment:this.videoBackHandle
  191. }
  192. handleFn[this.type]();
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .search-page {
  199. width: 100%;
  200. min-height: 100vh;
  201. // padding: 20rpx 34rpx;
  202. }
  203. .search-box {
  204. border: 1px solid #3385FF;
  205. padding: 0 !important;
  206. border-radius: 60rpx;
  207. background-color: #fff !important;
  208. }
  209. .search-con {
  210. background-color: #fff !important;
  211. }
  212. .van-search__content {
  213. background-color: #fff !important;
  214. padding-left: 30rpx !important;
  215. }
  216. .search-btn {
  217. position: relative;
  218. color: #3385FF;
  219. &::before {
  220. content: '';
  221. display: block;
  222. width: 1px;
  223. height: 60%;
  224. background-color: #D1D1D1;
  225. position: absolute;
  226. left: -16rpx;
  227. top: 20%;
  228. }
  229. }
  230. .search-icon {
  231. width: 40rpx;
  232. height: 40rpx;
  233. display: block;
  234. position: relative;
  235. top: 4rpx;
  236. margin-right: 20rpx;
  237. }
  238. .click-icon {
  239. width: 24rpx;
  240. height: 24rpx;
  241. }
  242. .search-result{
  243. padding: 20rpx 34rpx;
  244. }
  245. .result-item {
  246. align-items: center;
  247. padding: 20rpx 0;
  248. border-bottom: 1px solid #EBEBEB;
  249. .con {
  250. flex: 1;
  251. margin-right: 20rpx;
  252. }
  253. }
  254. </style>