search.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="index-content" :style="{'--status-bar-': statusBarHeight}">
  3. <view class="index-content-info">
  4. <!-- 头部主要内容 开始 -->
  5. <view class="index-content-header">
  6. <customNavbar
  7. title="搜索"
  8. bgColor="rgba(0,0,0,0)"
  9. :is-left="true"
  10. :leftStyle="{ color: '#fff' }"
  11. :customNavbarInfo='{}'></customNavbar>
  12. <u-search
  13. v-model="keyValue"
  14. :showAction="true"
  15. bgColor="#fff"
  16. actionText="搜索"
  17. @search="search"
  18. @custom="search"
  19. ></u-search>
  20. </view>
  21. <!-- 头部主要内容 结束 -->
  22. <!-- 列表主要内容 开始 -->
  23. <view class="index-content-list">
  24. <customScrollList
  25. ref="customScrollList"
  26. @load="load"
  27. @paging="paging"
  28. @refresh="refresh"
  29. >
  30. <view class="index-content-list-info" v-if="retailIndex.length>0">
  31. <text class="index-content-list-class">剧目</text>
  32. <view
  33. class="index-content-list-item"
  34. v-for="(item,index) in retailIndex"
  35. :key="index">
  36. <view class="index-content-list-content">
  37. <image
  38. class="index-content-list-image"
  39. :src="item.showImg" mode="scaleToFill"></image>
  40. <view class="index-content-list-tool">
  41. <text class="index-content-list-title">{{ item.name }}</text>
  42. <text
  43. class="index-content-list-but"
  44. @click="navigateToFun('/pages/publicSharingDetails/index',item)"
  45. >查看</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </customScrollList>
  51. </view>
  52. <!-- 列表主要内容 结束 -->
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. navigateTo
  59. } from "@/utils/util.js"
  60. export default {
  61. data() {
  62. return {
  63. title: '全民分享',
  64. loading: false,
  65. statusBarHeight: 0, // 状态栏安全距离
  66. retailIndex: [], // 剧目列表
  67. keyValue: ''
  68. }
  69. },
  70. onLoad() {
  71. },
  72. onShow() {
  73. this.statusBarHeight = getApp().globalData.statusBarHeight
  74. //this.load()
  75. },
  76. methods: {
  77. /** 搜索 */
  78. search(){
  79. if(!this.keyValue) {
  80. uni.showToast({
  81. title: "请输入关键字",
  82. icon: 'none'
  83. })
  84. return
  85. }
  86. this.$refs.customScrollList.refresh()
  87. },
  88. async load(paging){
  89. if(!this.keyValue) {
  90. this.$refs.customScrollList.loadSuccess({
  91. list: [],
  92. total: 100
  93. })
  94. return
  95. }
  96. console.log("上拉 加载数据")
  97. try{
  98. let res = await this.$u.api.retailIndex({
  99. "page": paging.page,
  100. "pages": paging.size,
  101. "name": this.keyValue
  102. })
  103. if(res && res.code ===200) {
  104. this.retailIndex = this.retailIndex.concat(res.data.performList)
  105. // this.retailIndex = null
  106. this.$refs.customScrollList.loadSuccess({
  107. list: this.retailIndex,
  108. total: this.retailIndex.length
  109. })
  110. } else {
  111. this.$refs.customScrollList.loadSuccess({
  112. list: [],
  113. total: 0
  114. })
  115. }
  116. }catch(e){
  117. //TODO handle the exception
  118. console.error("e===",e)
  119. this.$refs.customScrollList.loadSuccess({
  120. list: [],
  121. total: 0
  122. })
  123. }
  124. },
  125. paging(){
  126. console.log("下拉 加载数据")
  127. },
  128. /**
  129. * 下拉触底
  130. */
  131. async refresh(paging){
  132. console.log("上拉 加载数据",this.retailIndex)
  133. //this.$refs.customScrollList.showEmpty = true
  134. try{
  135. //this.$refs.customScrollList.showPullUp = true
  136. let res = await this.$u.api.retailIndex({
  137. pageNum: paging.page,
  138. pageSize: paging.size,
  139. name: this.keyValue
  140. })
  141. if(res && res.code ===200) {
  142. if(res.data.performList){
  143. this.retailIndex = [].concat(res.data.performList)
  144. }else {
  145. this.retailIndex = []
  146. }
  147. this.$refs.customScrollList.refreshSuccess({
  148. list: this.retailIndex,
  149. total:this.retailIndex.length
  150. })
  151. } else {
  152. this.$refs.customScrollList.refreshSuccess({
  153. list: [],
  154. total: 0
  155. })
  156. }
  157. }catch(e){
  158. //TODO handle the exception
  159. console.error("e===",e)
  160. this.$refs.customScrollList.refreshSuccess({
  161. list: [],
  162. total: 0
  163. })
  164. }
  165. },
  166. /**
  167. * @author ygh
  168. * @data 2023-12-20
  169. */
  170. navigateToFun(url,data) {
  171. navigateTo(url,{performId:data.id})
  172. },
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .index-content {
  178. display: flex;
  179. flex-direction: column;
  180. align-items: center;
  181. justify-content: center;
  182. box-sizing: border-box;
  183. --header-h: 170rpx;
  184. // background-color:
  185. .index-content-info {
  186. width: 100%;
  187. box-sizing: border-box;
  188. }
  189. }
  190. /** 头部主要内容 开始 */
  191. .index-content-header {
  192. width: 100%;
  193. height: var(--header-h);
  194. box-sizing: border-box;
  195. background-color: var(--gd-bgm-color);
  196. ::v-deep .u-search {
  197. padding: 0 30rpx !important;
  198. }
  199. ::v-deep .u-search__action {
  200. color: #fff !important;
  201. }
  202. }
  203. /** 头部主要内容 结束 **/
  204. /** 列表主要内容 开始 */
  205. .index-content-list {
  206. width: 100%;
  207. height: calc( 100% - var(--header-h) - var(--status-bar-h) );
  208. }
  209. .index-content-list-info {
  210. width: 100%;
  211. box-sizing: border-box;
  212. padding: 32rpx 32rpx 20rpx;
  213. .index-content-list-class {
  214. font-size: 32rpx;
  215. font-family: SourceHanSansCN, SourceHanSansCN;
  216. font-weight: bold;
  217. color: #2D2D2D;
  218. }
  219. .index-content-list-item {
  220. width: 100%;
  221. box-sizing: border-box;
  222. background: #FFFFFF;
  223. box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(200,200,200,0.5);
  224. border-radius: 24rpx;
  225. overflow: hidden;
  226. margin-top: 40rpx;
  227. .index-content-list-content {
  228. width: 100%;
  229. box-sizing: border-box;
  230. .index-content-list-image {
  231. width: 100%;
  232. height: 242rpx;
  233. }
  234. .index-content-list-tool {
  235. display: flex;
  236. width: 100%;
  237. justify-content: space-between;
  238. align-items: center;
  239. padding:42rpx 28rpx 46rpx;
  240. box-sizing: border-box;
  241. .index-content-list-title {
  242. font-size: 28rpx;
  243. font-family: SourceHanSansCN, SourceHanSansCN;
  244. font-weight: bold;
  245. color: #363636;
  246. }
  247. .index-content-list-but {
  248. width: 160rpx;
  249. height: 51rpx;
  250. background: #ED0000;
  251. border-radius: 24rpx;
  252. font-size: 20rpx;
  253. font-family: PingFangSC, PingFang SC;
  254. font-weight: 400;
  255. color: #FFFFFF;
  256. display: flex;
  257. justify-content: center;
  258. align-items: center;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. /** 列表主要内容 结束 **/
  265. </style>