index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="global-search">
  3. <view class="global-search_input">
  4. <image class="image" src="/static/c+unselected.svg" mode="widthFix" />
  5. <view style="flex:1">
  6. <My_search placeholder="搜索全站关键字" @onSearch="onSearch"></My_search>
  7. </view>
  8. </view>
  9. <view class="content">
  10. <view class="type-tabs">
  11. <u-tabs :scrollable="false" lineColor="#C30D23" :activeStyle="{ color: '#C30D23', fontWeight: 'bold' }" :list="types"
  12. @click="changeType" :current="current" />
  13. </view>
  14. <My_listbox ref="List" @getlist="getList" :bottomHeight="70">
  15. <view class="list-box">
  16. <navigator class="item-box" :url="calcUrl(item)"
  17. v-for="item in list" :key="item.sa_fadid"
  18. hover-class="navigator-hover">
  19. <view class="item">
  20. <u--image radius="5" :lazy-load="true" :width="tovw(100)" :height="tovw(100)" :src="item.attinfos.length ? item.attinfos[0].url : avatar">
  21. <template v-slot:loading>
  22. <u-loading-icon color="red"></u-loading-icon>
  23. </template>
  24. </u--image>
  25. <view class="title">
  26. {{ item.title }}
  27. </view>
  28. </view>
  29. </navigator>
  30. </view>
  31. </My_listbox>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. types: [
  40. {
  41. name:'产品',
  42. value:1,
  43. },
  44. {
  45. name:'效果图',
  46. value:2,
  47. },
  48. {
  49. name:'课件',
  50. value:3,
  51. },
  52. {
  53. name:'资料',
  54. value:4,
  55. }
  56. ],
  57. content: {
  58. "type": 1,
  59. //1:产品:来源单品、案例-电器系统
  60. //2:效果图:来源效果图管理;
  61. //3:课件:来源商学院授权可查看的课程中的课件;
  62. //4:资料:来源装备资源库授权可查看的资料;
  63. "pageNumber": 1,
  64. "pageSize": 12,
  65. "where": {
  66. "condition": ""
  67. }
  68. },
  69. list:[],
  70. current:0,
  71. avatar:''
  72. }
  73. },
  74. methods: {
  75. onSearch (condition) {
  76. this.content.where.condition = condition
  77. this.getList(true)
  78. },
  79. changeType (type) {
  80. this.current = type.index
  81. this.content.type = type.value
  82. this.getList(true)
  83. },
  84. getList(init = false) {
  85. return new Promise((resolve, reject) => {
  86. if (this.paging(this.content, init)) return resolve();
  87. this.$Http.basic({
  88. "id": "20240513085802",
  89. content: this.content
  90. }).then(res => {
  91. this.$refs.List.setHeight()
  92. this.$refs.List.RefreshToComplete()
  93. console.log("获取产品列表", res)
  94. resolve();
  95. if (this.cutoff(res.msg)) return;
  96. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  97. this.content = this.$refs.List.paging(this.content, res)
  98. })
  99. })
  100. },
  101. },
  102. computed: {
  103. calcUrl () {
  104. return (data) => {
  105. switch (this.current) {
  106. case 0:
  107. return '/packageCase/product/detail?id='+data.sa_fadid
  108. break;
  109. case 1:
  110. return '/packageCase/imgs/detail?id='+data.sat_sharematerialid
  111. break;
  112. case 2:
  113. return '/packageA/course/detail?id='+data.sat_coursewaredetailid
  114. break;
  115. case 3:
  116. return '/packageA/resourceLibrary/detail?id='+data.sat_sharematerialid
  117. break;
  118. default:
  119. break;
  120. }
  121. }
  122. }
  123. },
  124. onLoad () {
  125. uni.setNavigationBarTitle({
  126. title: '全站搜索'
  127. });
  128. },
  129. created() {
  130. this.avatar = uni.getStorageSync("site").logo
  131. this.getList()
  132. },
  133. }
  134. </script>
  135. <style lang="scss">
  136. .global-search {
  137. .global-search_input {
  138. margin: 10px;
  139. display: flex;
  140. align-items: center;
  141. .image{
  142. width: 40px;
  143. height: 20px;
  144. margin-right: 10px;
  145. }
  146. }
  147. .content {
  148. background: #ffffff;
  149. .type-tabs {
  150. margin-bottom: 10px;
  151. }
  152. .list-box {
  153. .item-box{
  154. padding: 0 10px;
  155. .item {
  156. display: flex;
  157. align-items: center;
  158. align-content: center;
  159. border-bottom: 0.5px solid #DDDDDd;
  160. padding: 10px 0;
  161. .image-box {
  162. margin-right: 10px;
  163. width: 100px;
  164. height: 100px;
  165. padding: 18px;
  166. background: #F5F5F5;
  167. .image{
  168. width: 100%;
  169. height: 100%;
  170. }
  171. }
  172. .title{
  173. font-family: PingFang SC, PingFang SC;
  174. font-weight: 400;
  175. font-size: 14px;
  176. color: #333333;
  177. margin-left: 10px;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. </style>