index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="content">
  3. <view class="top-content">
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="/static/images/icon_search.png" mode=""></image>
  8. <input type="text" v-model="keyword" placeholder="输入关键字搜索" confirm-type="search" @confirm="doSearch" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  9. </view>
  10. </view>
  11. <view class="cate-list">
  12. <Menu :list="cates" @menuClick="menuClick" v-if="cates.length>0" style="width:100%;"></Menu>
  13. </view>
  14. </view>
  15. <mescroll-body v-if="top!=null" :top="top" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  16. <view class="package-box" >
  17. <view class="item" @click="navTo('/pages_index/packageDetails?packageId='+item.packageId)" v-for="(item,index) in dataList">
  18. <view class="top">
  19. <image :src="item.imgUrl"></image>
  20. </view>
  21. <view class="bottom">
  22. <view class="title ellipsis2">
  23. {{item.packageName}}
  24. </view>
  25. <view class="price-box">
  26. <view class="price">¥{{item.price.toFixed(2)}}元/日</view>
  27. <view class="count">{{item.sales}}人已购</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </mescroll-body>
  33. </view>
  34. </template>
  35. <script>
  36. import Menu from '@/components/Menu.vue'
  37. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  38. import {getPackageList,getPackagCateList} from '@/api/package.js'
  39. export default {
  40. components: {Menu},
  41. mixins: [MescrollMixin], // 使用mixin
  42. data() {
  43. return {
  44. top:null,
  45. cates:[],
  46. diseaseType:0,
  47. keyword: '',
  48. mescroll:null,
  49. downOption: { //下拉刷新
  50. use:true,
  51. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  52. },
  53. upOption: {
  54. onScroll:false,
  55. use: true, // 是否启用上拉加载; 默认true
  56. page: {
  57. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  58. size: 10 // 每页数据的数量,默认10
  59. },
  60. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  61. textNoMore:"已经到底了",
  62. empty: {
  63. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  64. tip: '暂无数据'
  65. }
  66. },
  67. dataList: []
  68. }
  69. },
  70. onLoad() {
  71. this.getPackagCateList(1);
  72. },
  73. methods: {
  74. menuClick(item){
  75. this.diseaseType = item.cateCode;
  76. this.mescroll.resetUpScroll()
  77. },
  78. getPackagCateList(type){
  79. var data={type:type}
  80. var that=this;
  81. getPackagCateList(data).then(
  82. res => {
  83. if(res.code==200){
  84. this.cates=res.data;
  85. var query = uni.createSelectorQuery().in(that);
  86. setTimeout(function(){
  87. query.select('.top-content').boundingClientRect(data => {
  88. if (data) {
  89. console.log('View height:', data.height+"px");
  90. that.top=data.height+"px";
  91. }
  92. }).exec();
  93. },500);
  94. }
  95. },
  96. err => {
  97. }
  98. );
  99. },
  100. doSearch(){
  101. this.mescroll.resetUpScroll()
  102. },
  103. navTo(url){
  104. uni.navigateTo({
  105. url: url
  106. })
  107. },
  108. mescrollInit(mescroll) {
  109. this.mescroll = mescroll;
  110. },
  111. /*下拉刷新的回调 */
  112. downCallback() {
  113. this.mescroll.resetUpScroll()
  114. },
  115. /*上拉加载的回调*/
  116. upCallback(page) {
  117. //联网加载数据
  118. var that = this;
  119. var data = {
  120. isShow:1,
  121. diseaseType:this.diseaseType,
  122. keyword:this.keyword,
  123. pageNum: page.num,
  124. pageSize: page.size
  125. };
  126. getPackageList(data).then(res => {
  127. if(res.code==200){
  128. if (page.num == 1) {
  129. that.dataList = res.data.list;
  130. } else {
  131. that.dataList = that.dataList.concat(res.data.list);
  132. }
  133. that.mescroll.endBySize(res.data.list.length, res.data.total);
  134. }else{
  135. uni.showToast({
  136. icon:'none',
  137. title: "请求失败",
  138. });
  139. that.dataList = null;
  140. that.mescroll.endErr();
  141. }
  142. });
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. page{
  149. height: 100%;
  150. background: #f6f6f6;
  151. }
  152. </style>
  153. <style scoped lang="scss">
  154. page{
  155. height: 100%;
  156. background-color: #f5f5f5;
  157. }
  158. .content{
  159. height: 100%;
  160. .top-content{
  161. width: 100%;
  162. position: fixed;
  163. top: 0;
  164. left: 0;
  165. z-index: 10;
  166. }
  167. .top-title{
  168. height: 88upx;
  169. line-height: 88upx;
  170. font-size: 42upx;
  171. font-family: Source Han Sans CN;
  172. font-weight: bold;
  173. color: #222222;
  174. padding-left: 41upx;
  175. background-color: #FFFFFF;
  176. }
  177. .search-cont{
  178. padding: 16upx 30upx;
  179. background-color: #FFFFFF;
  180. .inner{
  181. box-sizing: border-box;
  182. width: 100%;
  183. height: 72upx;
  184. background: #F7F7F7;
  185. border-radius: 36upx;
  186. display: flex;
  187. align-items: center;
  188. padding: 0 30upx;
  189. .icon-search{
  190. width: 28upx;
  191. height: 28upx;
  192. margin-right: 20upx;
  193. }
  194. input{
  195. height: 60upx;
  196. line-height: 60upx;
  197. flex: 1;
  198. }
  199. }
  200. }
  201. .cate-list{
  202. box-sizing: border-box;
  203. background: #fff;
  204. }
  205. .package-box{
  206. display: flex;
  207. align-items: flex-start;
  208. justify-content: flex-start;
  209. flex-wrap: wrap;
  210. .item{
  211. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  212. background-color: #fff;
  213. width: calc(50% - 30rpx);
  214. border-radius: 15rpx;
  215. margin: 15rpx;
  216. display: flex;
  217. flex-direction: column;
  218. align-items: flex-start;
  219. justify-content: flex-start;
  220. &:last-child{
  221. }
  222. .top{
  223. width:100%;
  224. height:340rpx;
  225. image{
  226. border-radius: 15rpx 15rpx 0rpx 0rpx;
  227. width:100%;
  228. height:100%;
  229. }
  230. }
  231. .bottom{
  232. padding: 15rpx 10rpx;
  233. width: 100%;
  234. .title{
  235. font-weight: bold;
  236. font-size: 28upx;
  237. font-family: PingFang SC;
  238. color: #111111;
  239. }
  240. .price-box{
  241. margin-top: 10rpx;
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. width: 100%;
  246. .price{
  247. padding: 5rpx 10rpx;
  248. background-color: #C39A58;
  249. border-radius: 30rpx;
  250. font-size: 20upx;
  251. font-family: PingFang SC;
  252. color: #ffffff;
  253. }
  254. .count{
  255. font-size: 24upx;
  256. font-family: PingFang SC;
  257. color: #333333;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>