medicatedFoodList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  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. <!-- 关键字列表 -->
  13. <scroll-view scroll-x="true" >
  14. <view class="inner">
  15. <view v-for="(item,index) in foodOptions" :key="index" :class="food == item.dictLabel?'item active':'item'" @click="choseFood(item)">
  16. {{ item.dictLabel }}
  17. </view>
  18. </view>
  19. </scroll-view>
  20. <scroll-view scroll-x="true" >
  21. <view class="inner">
  22. <view v-for="(item,index) in actionOptions" :key="index" :class="action == item.dictLabel?'item active':'item'" @click="choseAction(item)">
  23. {{ item.dictLabel }}
  24. </view>
  25. </view>
  26. </scroll-view>
  27. <scroll-view scroll-x="true" >
  28. <view class="inner">
  29. <view v-for="(item,index) in indicationOptions" :key="index" :class="indications == item.dictLabel?'item active':'item'" @click="choseIndications(item)">
  30. {{ item.dictLabel }}
  31. </view>
  32. </view>
  33. </scroll-view>
  34. </view>
  35. </view>
  36. <mescroll-body top="376rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  37. <view class="article-list">
  38. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  39. <view class="top">
  40. <image :src="item.imgUrl" mode="aspectFill"></image>
  41. </view>
  42. <view class="title ellipsis">{{ item.foodName }}</view>
  43. <view class="desc ellipsis">{{ item.actionTitle }}</view>
  44. </view>
  45. </view>
  46. </mescroll-body>
  47. </view>
  48. </template>
  49. <script>
  50. import {getDictByKey} from '@/api/common.js'
  51. import {getMedicatedFoodList} from '@/api/index.js'
  52. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  53. export default {
  54. mixins: [MescrollMixin],
  55. data() {
  56. return {
  57. foodOptions:[],
  58. actionOptions:[],
  59. indicationOptions:[],
  60. action:"",
  61. food:"",
  62. indications:"",
  63. keyword: '',
  64. mescroll:null,
  65. downOption: { //下拉刷新
  66. use:true,
  67. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  68. },
  69. upOption: {
  70. onScroll:false,
  71. use: true, // 是否启用上拉加载; 默认true
  72. page: {
  73. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  74. size: 10 // 每页数据的数量,默认10
  75. },
  76. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  77. textNoMore:"已经到底了",
  78. empty: {
  79. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  80. tip: '暂无数据'
  81. }
  82. },
  83. dataList: []
  84. };
  85. },
  86. onShow() {
  87. this.getDictByKey("sys_medicated_food");
  88. this.getDictByKey("sys_medicated_food_action");
  89. this.getDictByKey("sys_indication");
  90. },
  91. methods:{
  92. getDictByKey(key){
  93. var data={key:key}
  94. getDictByKey(data).then(
  95. res => {
  96. if(res.code==200){
  97. if(key=="sys_medicated_food"){
  98. this.foodOptions=res.data;
  99. }
  100. if(key=="sys_medicated_food_action"){
  101. this.actionOptions=res.data;
  102. }
  103. if(key=="sys_indication"){
  104. this.indicationOptions=res.data;
  105. }
  106. }
  107. },
  108. err => {
  109. }
  110. );
  111. },
  112. doSearch(){
  113. this.mescroll.resetUpScroll()
  114. },
  115. mescrollInit(mescroll) {
  116. this.mescroll = mescroll;
  117. },
  118. /*下拉刷新的回调 */
  119. downCallback(mescroll) {
  120. mescroll.resetUpScroll()
  121. },
  122. upCallback(page) {
  123. //联网加载数据
  124. var that = this;
  125. var data = {
  126. food:this.food,
  127. action:this.action,
  128. indications:this.indications,
  129. keyword:this.keyword,
  130. pageNum: page.num,
  131. pageSize: page.size
  132. };
  133. getMedicatedFoodList(data).then(res => {
  134. if(res.code==200){
  135. //设置列表数据
  136. if (page.num == 1) {
  137. that.dataList = res.data.list;
  138. } else {
  139. that.dataList = that.dataList.concat(res.data.list);
  140. }
  141. that.mescroll.endBySize(res.data.list.length, res.data.total);
  142. }else{
  143. uni.showToast({
  144. icon:'none',
  145. title: "请求失败",
  146. });
  147. that.dataList = null;
  148. that.mescroll.endErr();
  149. }
  150. });
  151. },
  152. choseAction(item) {
  153. this.action = item.dictLabel;
  154. this.mescroll.resetUpScroll()
  155. },
  156. choseFood(item) {
  157. this.food = item.dictLabel;
  158. this.mescroll.resetUpScroll()
  159. },
  160. choseIndications(item) {
  161. this.indications = item.dictLabel;
  162. this.mescroll.resetUpScroll()
  163. },
  164. // 查看详情
  165. showDetail(item) {
  166. uni.navigateTo({
  167. url: './medicatedFoodDetails?id=' + item.id
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. .top-content{
  175. width: 100%;
  176. position: fixed;
  177. top: 0;
  178. left: 0;
  179. z-index: 10;
  180. }
  181. .search-cont{
  182. padding: 16upx 30upx;
  183. background-color: #FFFFFF;
  184. .inner{
  185. box-sizing: border-box;
  186. width: 100%;
  187. height: 72upx;
  188. background: #F7F7F7;
  189. border-radius: 36upx;
  190. display: flex;
  191. align-items: center;
  192. padding: 0 30upx;
  193. .icon-search{
  194. width: 28upx;
  195. height: 28upx;
  196. margin-right: 20upx;
  197. }
  198. input{
  199. height: 60upx;
  200. line-height: 60upx;
  201. flex: 1;
  202. }
  203. }
  204. }
  205. .cate-list{
  206. box-sizing: border-box;
  207. background: #fff;
  208. padding: 10upx 27upx;
  209. .inner{
  210. display: flex;
  211. }
  212. .item{
  213. flex-shrink: 0;
  214. padding: 0 24upx;
  215. height: 64upx;
  216. line-height: 64upx;
  217. font-size: 28upx;
  218. font-family: PingFang SC;
  219. font-weight: 500;
  220. color: #C39A58;
  221. background: #ffffff;
  222. border: 1px solid #E2C99E;
  223. border-radius: 32upx;
  224. margin: 0 20upx 20upx 0;
  225. &.active{
  226. color: #FFFFFF;
  227. background: #E2C99E;
  228. border: 1px solid #E2C99E;
  229. }
  230. }
  231. }
  232. .article-list{
  233. padding: 0 10upx;
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. flex-wrap: wrap;
  238. .item{
  239. width: 50%;
  240. box-sizing: border-box;
  241. padding: 15upx;
  242. display: flex;
  243. flex-direction: column;
  244. align-items: center;
  245. justify-content: space-between;
  246. margin-bottom: 20upx;
  247. .top{
  248. width: 100%;
  249. height: 240upx;
  250. image{
  251. border-radius: 20upx;
  252. width: 100%;
  253. height: 100%;
  254. }
  255. }
  256. .title{
  257. text-align: center;
  258. width: 100%;
  259. margin-top: 15rpx;
  260. font-size: 32upx;
  261. font-family: PingFang SC;
  262. font-weight: 500;
  263. color: #111111;
  264. }
  265. .desc{
  266. text-align: center;
  267. width: 100%;
  268. margin-top: 15rpx;
  269. font-size: 28upx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #999999;
  273. }
  274. }
  275. }
  276. </style>