search.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <u-search
  4. class="changes"
  5. placeholder="搜索课程 题库"
  6. v-model="searchData"
  7. shape="square"
  8. :show-action="true"
  9. bg-color="#F3F4F6"
  10. :adjust-position="false"
  11. :focus="true"
  12. height="70"
  13. action-text="取消"
  14. @clear="changeClear"
  15. @search="getDatas"
  16. @custom="backHome"
  17. ></u-search>
  18. <view class="big_searchBox" v-if="searchStatus">
  19. <view class="classword" v-if="list1.length">
  20. <view class="titles">课程</view>
  21. <view class="listWord">
  22. <view class="listA" v-for="(item, index) in list1" :key="index" @click="jumpPage(1,item)">{{ item.courseName }}</view>
  23. </view>
  24. <view class="moreClassword" v-if="list1.length === 10">
  25. <view class="left">查看更多课程</view>
  26. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  27. </view>
  28. </view>
  29. <view class="classword" v-if="list2.length">
  30. <view class="titles">题库</view>
  31. <view class="listWord">
  32. <view class="listA" v-for="(item, index) in list2" :key="index" @click="jumpPage(2,item)">{{ item.bankName }}</view>
  33. </view>
  34. <view class="moreClassword" v-if="list2.length === 10">
  35. <view class="left">查看更多课程</view>
  36. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  37. </view>
  38. </view>
  39. <view class="classword" v-if="list3.length">
  40. <view class="titles">重点考点</view>
  41. <view class="listWord">
  42. <view class="listA" v-for="(item, index) in list3" :key="index" @click="jumpPage(3,item)">{{ item.name }}</view>
  43. </view>
  44. <view class="moreClassword" v-if="list3.length === 10">
  45. <view class="left">查看更多课程</view>
  46. <u-icon name="arrow-right" color="#999" size="28"></u-icon>
  47. </view>
  48. </view>
  49. <view v-if="list1.length === 0 && list2.length === 0 && list3.length === 0"><u-empty text="暂无搜索结果" mode="list"></u-empty></view>
  50. </view>
  51. <view v-else><u-empty text="暂无搜索结果" mode="list"></u-empty></view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. searchData: '',
  59. list1: [],
  60. list2: [],
  61. list3: [],
  62. searchStatus: false
  63. };
  64. },
  65. onLoad(option) {},
  66. onShow() {},
  67. methods: {
  68. jumpPage(int,item){
  69. if (int == 1) {
  70. this.$navTo.togo('/pages2/course/detail', {
  71. id: item.courseId
  72. });
  73. return;
  74. }
  75. if (int == 2) {
  76. this.$navTo.togo('/pages2/bank/detail', {
  77. id: item.bankId
  78. });
  79. return;
  80. }
  81. if (int == 3) {
  82. this.$navTo.togo('/pages2/course/keynote', {
  83. id: item.fileId
  84. });
  85. return;
  86. }
  87. },
  88. // 取消
  89. backHome() {
  90. uni.navigateBack({
  91. delta: 1
  92. });
  93. },
  94. // 搜索框清空
  95. changeClear() {},
  96. getDatas() {
  97. var self = this;
  98. if(this.searchData.length === 0){
  99. uni.showToast({
  100. title: '请输入搜索内容',
  101. icon: 'none'
  102. })
  103. return
  104. }
  105. this.gitCourseLists();
  106. this.gitBankList();
  107. this.gitNoteLists();
  108. },
  109. gitCourseLists() {
  110. var self = this;
  111. this.$api
  112. .courselist({
  113. courseName: this.searchData,
  114. pageNum: 1,
  115. pageSize: 10
  116. })
  117. .then(res => {
  118. self.list1 = res.data.rows;
  119. if (res.data.rows.length > 0) {
  120. self.searchStatus = true;
  121. }
  122. });
  123. },
  124. gitBankList() {
  125. var self = this;
  126. this.$api
  127. .banklist({
  128. bankName: this.searchData,
  129. pageNum: 1,
  130. pageSize: 10
  131. })
  132. .then(res => {
  133. self.list2 = res.data.rows;
  134. if (res.data.rows.length > 0) {
  135. self.searchStatus = true;
  136. }
  137. });
  138. },
  139. gitNoteLists() {
  140. var self = this;
  141. this.$api
  142. .notelist({
  143. name: this.searchData,
  144. pageNum: 1,
  145. pageSize: 10
  146. })
  147. .then(res => {
  148. self.list3 = res.data.rows;
  149. if (res.data.rows.length > 0) {
  150. self.searchStatus = true;
  151. }
  152. });
  153. }
  154. }
  155. };
  156. </script>
  157. <style scope>
  158. .classword {
  159. color: #666;
  160. }
  161. .titles {
  162. margin-top: 30upx;
  163. padding-left: 32upx;
  164. padding-bottom: 11upx;
  165. border-bottom: 1upx solid #d6d6db;
  166. color: #666;
  167. }
  168. .listWord {
  169. border-bottom: 1upx solid #eee;
  170. }
  171. .listA {
  172. margin-left: 32upx;
  173. height: 88upx;
  174. line-height: 88upx;
  175. padding: 0upx 35upx;
  176. border-bottom: 1upx solid #eee;
  177. white-space: nowrap;
  178. text-overflow: ellipsis;
  179. overflow: hidden;
  180. word-break: break-all;
  181. }
  182. .listA:last-of-type {
  183. border-bottom: none;
  184. }
  185. .moreClassword {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. padding-left: 65upx;
  190. padding-right: 32upx;
  191. height: 88upx;
  192. border-bottom: 1upx solid #eee;
  193. margin-bottom: 46upx;
  194. }
  195. page {
  196. background: #ffffff;
  197. }
  198. </style>