packageList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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/store/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(res => {
  90. if(res.code==200){
  91. this.cates=res.data;
  92. var query = uni.createSelectorQuery().in(that);
  93. setTimeout(function(){
  94. query.select('.top-content').boundingClientRect(data => {
  95. if (data) {
  96. console.log('View height:', data.height+"px");
  97. that.top=data.height+"px";
  98. }
  99. }).exec();
  100. },500);
  101. }
  102. },
  103. err => {
  104. }
  105. );
  106. },
  107. // 关键词选择
  108. choseType(item) {
  109. this.diseaseType = item.cateCode;
  110. this.mescroll.resetUpScroll()
  111. },
  112. doSearch(){
  113. this.mescroll.resetUpScroll()
  114. },
  115. navTo(url){
  116. uni.navigateTo({
  117. url: url
  118. })
  119. },
  120. mescrollInit(mescroll) {
  121. this.mescroll = mescroll;
  122. },
  123. /*下拉刷新的回调 */
  124. downCallback() {
  125. this.mescroll.resetUpScroll()
  126. },
  127. /*上拉加载的回调*/
  128. upCallback(page) {
  129. //联网加载数据
  130. var that = this;
  131. var data = {
  132. isShow:1,
  133. diseaseType:this.diseaseType,
  134. keyword:this.keyword,
  135. pageNum: page.num,
  136. pageSize: page.size
  137. };
  138. getPackageList(data).then(res => {
  139. if(res.code==200){
  140. if (page.num == 1) {
  141. that.dataList = res.data.list;
  142. } else {
  143. that.dataList = that.dataList.concat(res.data.list);
  144. }
  145. that.mescroll.endBySize(res.data.list.length, res.data.total);
  146. }else{
  147. uni.showToast({
  148. icon:'none',
  149. title: "请求失败",
  150. });
  151. that.dataList = null;
  152. that.mescroll.endErr();
  153. }
  154. });
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. page{
  161. height: 100%;
  162. background: #f6f6f6;
  163. }
  164. </style>
  165. <style scoped lang="scss">
  166. page{
  167. height: 100%;
  168. background-color: #f5f5f5;
  169. }
  170. .content{
  171. height: 100%;
  172. .top-content{
  173. width: 100%;
  174. position: fixed;
  175. top: 0;
  176. left: 0;
  177. z-index: 10;
  178. }
  179. .top-title{
  180. height: 88upx;
  181. line-height: 88upx;
  182. font-size: 42upx;
  183. font-family: Source Han Sans CN;
  184. font-weight: bold;
  185. color: #222222;
  186. padding-left: 41upx;
  187. background-color: #FFFFFF;
  188. }
  189. .search-cont{
  190. padding: 16upx 30upx;
  191. background-color: #FFFFFF;
  192. .inner{
  193. box-sizing: border-box;
  194. width: 100%;
  195. height: 72upx;
  196. background: #F7F7F7;
  197. border-radius: 36upx;
  198. display: flex;
  199. align-items: center;
  200. padding: 0 30upx;
  201. .icon-search{
  202. width: 28upx;
  203. height: 28upx;
  204. margin-right: 20upx;
  205. }
  206. input{
  207. height: 60upx;
  208. line-height: 60upx;
  209. flex: 1;
  210. }
  211. }
  212. }
  213. .cate-list{
  214. box-sizing: border-box;
  215. background: #fff;
  216. .inner{
  217. display: flex;
  218. flex-wrap: wrap;
  219. align-items: star;
  220. justify-content: flex-start;
  221. }
  222. .item{
  223. width: 25%;
  224. margin-bottom: 15rpx;
  225. flex-shrink: 0;
  226. padding: 0 24upx;
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. justify-content: center;
  231. .icon{
  232. width:58rpx;
  233. height:58rpx;
  234. }
  235. .title{
  236. font-size: 24upx;
  237. font-family: PingFang SC;
  238. font-weight: 500;
  239. color: #111;
  240. margin-top: 10rpx;
  241. }
  242. &.active{
  243. .title{
  244. color: #FF5C03;
  245. }
  246. }
  247. }
  248. }
  249. .package-box{
  250. display: flex;
  251. align-items: flex-start;
  252. justify-content: flex-start;
  253. flex-wrap: wrap;
  254. .item{
  255. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  256. background-color: #fff;
  257. width: calc(50% - 20rpx);
  258. border-radius: 15rpx;
  259. margin: 10rpx;
  260. display: flex;
  261. flex-direction: column;
  262. align-items: flex-start;
  263. justify-content: flex-start;
  264. &:last-child{
  265. }
  266. .top{
  267. width:100%;
  268. height:300rpx;
  269. image{
  270. border-radius: 15rpx 15rpx 0rpx 0rpx;
  271. width:100%;
  272. height:300rpx;
  273. }
  274. }
  275. .bottom{
  276. padding: 15rpx 10rpx;
  277. width: 100%;
  278. .title{
  279. font-weight: bold;
  280. font-size: 28upx;
  281. font-family: PingFang SC;
  282. color: #111111;
  283. }
  284. .price-box{
  285. margin-top: 10rpx;
  286. display: flex;
  287. align-items: center;
  288. justify-content: space-between;
  289. width: 100%;
  290. .price{
  291. padding: 5rpx 10rpx;
  292. background-color: #FF5C03;
  293. border-radius: 30rpx;
  294. font-size: 20upx;
  295. font-family: PingFang SC;
  296. color: #ffffff;
  297. }
  298. .count{
  299. font-size: 24upx;
  300. font-family: PingFang SC;
  301. color: #333333;
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. </style>