chineseMedicineList.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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/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="tabs">
  12. <u-tabs
  13. :scrollable="false"
  14. :list="tabs"
  15. lineColor="#C39A58"
  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. {{$parseText(item.dictLabel,4)}}
  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. {{$parseText(item.dictLabel,4)}}
  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. console.log(e)
  82. },
  83. indicationClick(item){
  84. this.flavor="";
  85. this.indication=item.dictLabel;
  86. this.title=item.dictLabel;
  87. this.pageNum=1;
  88. this.getChineseMedicineList()
  89. },
  90. flavorClick(item){
  91. console.log(item)
  92. this.indication=""
  93. this.flavor=item.dictLabel;
  94. this.title=item.dictLabel;
  95. this.pageNum=1;
  96. this.getChineseMedicineList()
  97. },
  98. getDictByKey(key){
  99. var data={key:key}
  100. getDictByKey(data).then(
  101. res => {
  102. if(res.code==200){
  103. if(key=="sys_indication"){
  104. this.indicationOptions=res.data;
  105. }
  106. if(key=="sys_chinese_medicine_flavor"){
  107. this.flavorOptions=res.data;
  108. }
  109. }
  110. },
  111. err => {
  112. }
  113. );
  114. },
  115. tabChange(item) {
  116. this.tabIndex = item.id
  117. this.getChineseMedicineList()
  118. },
  119. doSearch(){
  120. this.pageNum=1;
  121. this.getChineseMedicineList()
  122. },
  123. getChineseMedicineList() {
  124. //联网加载数据
  125. var that = this;
  126. var data = {
  127. indication:this.indication,
  128. flavor:this.flavor,
  129. vessel:this.vessel,
  130. keyword:this.keyword,
  131. pageNum: this.pageNum,
  132. pageSize: this.pageSize
  133. };
  134. // uni.showLoading({
  135. // title:"加载中..."
  136. // })
  137. getChineseMedicineList(data).then(res => {
  138. // uni.hideLoading()
  139. if(res.code==200){
  140. //设置列表数据
  141. if (this.pageNum == 1) {
  142. that.dataList = res.data.list;
  143. } else {
  144. that.dataList = that.dataList.concat(res.data.list);
  145. }
  146. }else{
  147. uni.showToast({
  148. icon:'none',
  149. title: "请求失败",
  150. });
  151. that.dataList = [];
  152. }
  153. });
  154. },
  155. // 查看详情
  156. showDetail(item) {
  157. uni.navigateTo({
  158. url: './chineseMedicineDetails?id=' + item.id
  159. })
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .content{
  166. height: 100%;
  167. overflow: hidden;
  168. }
  169. .top-box{
  170. width: 100%;
  171. height: 180rpx;
  172. background-color: #FFFFFF;
  173. .search-cont{
  174. padding: 16upx 30upx;
  175. .inner{
  176. box-sizing: border-box;
  177. width: 100%;
  178. height: 72upx;
  179. background: #F7F7F7;
  180. border-radius: 36upx;
  181. display: flex;
  182. align-items: center;
  183. padding: 0 30upx;
  184. .icon-search{
  185. width: 28upx;
  186. height: 28upx;
  187. margin-right: 20upx;
  188. }
  189. input{
  190. height: 60upx;
  191. line-height: 60upx;
  192. flex: 1;
  193. }
  194. }
  195. }
  196. .tabs{
  197. }
  198. }
  199. .cont-box{
  200. height: calc(100% - 180rpx);
  201. display: flex;
  202. align-items: flex-start;
  203. justify-content: flex-start;
  204. .left{
  205. padding: 30rpx 0rpx;
  206. width: 240rpx;
  207. height: 100%;
  208. overflow-y: auto;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: flex-start;
  212. justify-content: flex-start;
  213. .items{
  214. width: 240rpx;
  215. width: 100%;
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. justify-content: flex-start;
  220. .item{
  221. width: 240rpx;
  222. padding: 0rpx 20rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: flex-start;
  226. font-size: 32upx;
  227. font-family: PingFang SC;
  228. font-weight: normal;
  229. color: #111111;
  230. font-weight: 500;
  231. line-height: 80upx;
  232. .line{
  233. margin-right: 15rpx;
  234. border-radius: 5rpx;
  235. width: 8rpx;
  236. height:30rpx;
  237. background-color: #C39A58;
  238. }
  239. }
  240. .active{
  241. background-color: #fff;
  242. font-weight: bold;
  243. color: #C39A58;
  244. }
  245. }
  246. }
  247. .right{
  248. padding: 30rpx 15rpx;
  249. background-color: #fff;
  250. height: 100%;
  251. overflow-y: auto;
  252. display: flex;
  253. flex-direction: column;
  254. align-items: flex-start;
  255. justify-content: flex-start;
  256. width: calc(100% - 240rpx);
  257. .title{
  258. font-size: 40upx;
  259. font-family: PingFang SC;
  260. font-weight: bold;
  261. color: #C39A58;
  262. line-height: 80upx;
  263. }
  264. .items{
  265. width: 100%;
  266. display: flex;
  267. flex-direction: column;
  268. align-items: flex-start;
  269. justify-content: flex-start;
  270. .r-item{
  271. line-height: 80rpx;
  272. width: 100%;
  273. display: flex;
  274. align-items: center;
  275. justify-content: flex-start;
  276. .r-left{
  277. flex: 1;
  278. font-size: 32upx;
  279. font-family: PingFang SC;
  280. font-weight: 500;
  281. color: #080808;
  282. }
  283. .r-right{
  284. padding: 0rpx 20rpx;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. image{
  289. width: 22rpx;
  290. height:30rpx;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. </style>