chineseMedicineList.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="content">
  3. <view class="top-box">
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <view class="inner">
  7. <image class="icon-search" src="/static/images/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="tabs">
  12. <u-tabs
  13. :scrollable="false"
  14. :list="tabs"
  15. lineColor="#018C39"
  16. @change="tabChange">
  17. </u-tabs>
  18. </view>
  19. </view>
  20. <view class="cont-box">
  21. <view class="left">
  22. <view class="items">
  23. <view v-if="tabIndex==1" @click="flavorClick(item)" v-for="item in flavorOptions" :class="item.dictValue==flavor?'item ellipsis active':'item ellipsis'">
  24. <text class="line" v-if="item.dictValue==flavor"></text>
  25. {{ utils.subString(item.dictLabel) }}
  26. </view>
  27. <view v-if="tabIndex==2" @click="indicationClick(item)" v-for="item in indicationOptions" :class="item.dictLabel==indication?'item ellipsis active':'item ellipsis'">
  28. <text class="line" v-if="item.dictLabel==indication"></text>
  29. {{ utils.subString(item.dictLabel) }}
  30. </view>
  31. </view>
  32. </view>
  33. <view class="right" >
  34. <view class="title">{{title}}</view>
  35. <scroll-view @scrolltolower="scrolltolower" scroll-y="true" style="height: calc(100vh - 180rpx);">
  36. <view class="items">
  37. <view class="r-item" @click="showDetail(item)" v-for="item in dataList">
  38. <view class="r-left">{{item.medicineName}}</view>
  39. <view class="r-right">
  40. <image src="/static/images/fire.png"></image>
  41. </view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {getDictByKey} from '@/api/common.js'
  51. import {getChineseMedicineList} from '@/api/index.js'
  52. export default {
  53. data() {
  54. return {
  55. tabIndex:1,
  56. indication:"",
  57. flavor:"",
  58. vessel:"",
  59. title:"",
  60. pageNum:1,
  61. pageSize:20,
  62. flavorOptions:[],
  63. indicationOptions:[],
  64. tabs: [
  65. {name:"按五味",id:"1"},
  66. {name:"按疾病",id:"2"},
  67. ],
  68. keyword: '',
  69. dataList: []
  70. };
  71. },
  72. onLoad() {
  73. this.getDictByKey("sys_chinese_medicine_flavor");
  74. this.getDictByKey("sys_indication");
  75. this.getChineseMedicineList()
  76. },
  77. methods:{
  78. scrolltolower(e){
  79. this.pageNum++;
  80. this.getChineseMedicineList()
  81. },
  82. indicationClick(item){
  83. this.flavor="";
  84. this.indication=item.dictLabel;
  85. this.title=item.dictLabel;
  86. this.pageNum=1;
  87. this.getChineseMedicineList()
  88. },
  89. flavorClick(item){
  90. this.indication=""
  91. this.flavor=item.dictLabel;
  92. this.title=item.dictLabel;
  93. this.pageNum=1;
  94. this.getChineseMedicineList()
  95. },
  96. getDictByKey(key){
  97. var data={key:key}
  98. getDictByKey(data).then(
  99. res => {
  100. if(res.code==200){
  101. if(key=="sys_indication"){
  102. this.indicationOptions=res.data;
  103. }
  104. if(key=="sys_chinese_medicine_flavor"){
  105. this.flavorOptions=res.data;
  106. }
  107. }
  108. },
  109. err => {
  110. }
  111. );
  112. },
  113. tabChange(item) {
  114. this.tabIndex = item.id
  115. this.getChineseMedicineList()
  116. },
  117. doSearch(){
  118. this.pageNum=1;
  119. this.getChineseMedicineList()
  120. },
  121. getChineseMedicineList() {
  122. //联网加载数据
  123. var that = this;
  124. var data = {
  125. indication:this.indication,
  126. flavor:this.flavor,
  127. vessel:this.vessel,
  128. keyword:this.keyword,
  129. pageNum: this.pageNum,
  130. pageSize: this.pageSize
  131. };
  132. uni.showLoading({
  133. title:"加载中..."
  134. })
  135. getChineseMedicineList(data).then(res => {
  136. uni.hideLoading()
  137. if(res.code==200){
  138. //设置列表数据
  139. if (this.pageNum == 1) {
  140. that.dataList = res.data.list;
  141. } else {
  142. that.dataList = that.dataList.concat(res.data.list);
  143. }
  144. }else{
  145. uni.showToast({
  146. icon:'none',
  147. title: "请求失败",
  148. });
  149. that.dataList = [];
  150. }
  151. });
  152. },
  153. // 查看详情
  154. showDetail(item) {
  155. uni.navigateTo({
  156. url: './chineseMedicineDetails?id=' + item.id
  157. })
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .content{
  164. height: 100%;
  165. overflow: hidden;
  166. }
  167. .top-box{
  168. width: 100%;
  169. height: 180rpx;
  170. background-color: #FFFFFF;
  171. .search-cont{
  172. padding: 16upx 30upx;
  173. .inner{
  174. box-sizing: border-box;
  175. width: 100%;
  176. height: 72upx;
  177. background: #F7F7F7;
  178. border-radius: 36upx;
  179. display: flex;
  180. align-items: center;
  181. padding: 0 30upx;
  182. .icon-search{
  183. width: 28upx;
  184. height: 28upx;
  185. margin-right: 20upx;
  186. }
  187. input{
  188. height: 60upx;
  189. line-height: 60upx;
  190. flex: 1;
  191. }
  192. }
  193. }
  194. .tabs{
  195. }
  196. }
  197. .cont-box{
  198. height: calc(100% - 180rpx);
  199. display: flex;
  200. align-items: flex-start;
  201. justify-content: flex-start;
  202. .left{
  203. padding: 30rpx 0rpx;
  204. width: 240rpx;
  205. height: 100%;
  206. overflow-y: auto;
  207. display: flex;
  208. flex-direction: column;
  209. align-items: flex-start;
  210. justify-content: flex-start;
  211. .items{
  212. width: 240rpx;
  213. width: 100%;
  214. display: flex;
  215. flex-direction: column;
  216. align-items: center;
  217. justify-content: flex-start;
  218. .item{
  219. width: 240rpx;
  220. padding: 0rpx 20rpx;
  221. display: flex;
  222. align-items: center;
  223. justify-content: flex-start;
  224. font-size: 32upx;
  225. font-family: PingFang SC;
  226. font-weight: normal;
  227. color: #111111;
  228. font-weight: 500;
  229. line-height: 80upx;
  230. .line{
  231. margin-right: 15rpx;
  232. border-radius: 5rpx;
  233. width: 8rpx;
  234. height:30rpx;
  235. background-color: #018C39;
  236. }
  237. }
  238. .active{
  239. background-color: #fff;
  240. font-weight: bold;
  241. color: #018C39;
  242. }
  243. }
  244. }
  245. .right{
  246. padding: 30rpx 15rpx;
  247. background-color: #fff;
  248. height: 100%;
  249. overflow-y: auto;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: flex-start;
  253. justify-content: flex-start;
  254. width: calc(100% - 240rpx);
  255. .title{
  256. font-size: 40upx;
  257. font-family: PingFang SC;
  258. font-weight: bold;
  259. color: #018C39;
  260. line-height: 80upx;
  261. }
  262. .items{
  263. width: 100%;
  264. display: flex;
  265. flex-direction: column;
  266. align-items: flex-start;
  267. justify-content: flex-start;
  268. .r-item{
  269. line-height: 80rpx;
  270. width: 100%;
  271. display: flex;
  272. align-items: center;
  273. justify-content: flex-start;
  274. .r-left{
  275. flex: 1;
  276. font-size: 32upx;
  277. font-family: PingFang SC;
  278. font-weight: 500;
  279. color: #080808;
  280. }
  281. .r-right{
  282. padding: 0rpx 20rpx;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. image{
  287. width: 22rpx;
  288. height:30rpx;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>