packageList.vue 7.3 KB

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