index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="page-content experts">
  3. <view class="page-header experts-header">
  4. <view class="experts-header-field">
  5. <picker @change="bindPickerChange"
  6. :value="expertsFieldIndex"
  7. :range="expertsFieldList">
  8. <view class="field-content">
  9. <view class="field-img">
  10. <u-icon name="list"
  11. size="54"
  12. class="field-icon"></u-icon>
  13. </view>
  14. <view class="field-text">{{ expertsFieldList[expertsFieldIndex] }}</view>
  15. </view>
  16. </picker>
  17. </view>
  18. </view>
  19. <view class="page-main experts-content">
  20. <view class="experts-content-main">
  21. <scroll-view scroll-y="true"
  22. class="scroll-Y"
  23. @scrolltolower="handleScrolltolower">
  24. <view class="experts-content-main-listbody">
  25. <template v-if="expertsMainObj.list_empty">
  26. <view class="experts-content-main-nodata">
  27. <text class="expertsmain-nodata">暂无数据</text>
  28. </view>
  29. </template>
  30. <template>
  31. <u-row gutter="16"
  32. class="listbody-row">
  33. <u-col span="12"
  34. class="listbody-col"
  35. v-for="expertsModalItem in expertsMainObj.expertsModalList"
  36. :key="expertsModalItem.id">
  37. <view class="listbody-item"
  38. @click="handleExpertsModalItemClick(expertsModalItem)"
  39. :class="expertsModalItem.isCheckedItem?'listbody-checkeditem':''">
  40. <view class="item-content">
  41. <view class="item-content-sub item-content-left">
  42. <text class="item-content-text">姓名:{{ expertsModalItem.professorName }}</text>
  43. </view>
  44. <view class="item-content-sub item-content-right">
  45. <text class="item-content-text">职称:{{ expertsModalItem.title }}</text>
  46. </view>
  47. </view>
  48. <view class="item-content">
  49. <view class="item-content-sub item-content-left">
  50. <text class="item-content-text">年龄:{{ expertsModalItem.age }}</text>
  51. </view>
  52. <view class="item-content-sub item-content-right">
  53. <text class="item-content-text">性别:{{ expertsModalItem.sex }}</text>
  54. </view>
  55. </view>
  56. <view class="item-content">
  57. <view class="item-content-sub item-content-field">
  58. <text class="item-content-text">专业领域:{{ expertsModalItem.professorField }}</text>
  59. </view>
  60. </view>
  61. <view class="item-content">
  62. <view class="item-content-sub item-content-institution">
  63. <text class="item-content-text">供职单位:{{ expertsModalItem.institution }}</text>
  64. </view>
  65. </view>
  66. </view>
  67. </u-col>
  68. </u-row>
  69. </template>
  70. <uni-load-more :status="expertsMainObj.loadStatus"
  71. v-if="!expertsMainObj.list_empty"></uni-load-more>
  72. </view>
  73. </scroll-view>
  74. </view>
  75. <view class="experts-content-btn">
  76. <view class="experts-consultbtn">
  77. <view class="consultbtn-text"
  78. @click="handleConsultExpertsClick">咨询专家</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. expertsMainListData,
  87. expertsMainFieldListData
  88. } from '@/agrcloud-api/expertsmodal';
  89. import uniLoadMore from "@/agrcloud-components/uni-load-more/uni-load-more"
  90. export default {
  91. name: 'experts',
  92. components: {
  93. uniLoadMore
  94. },
  95. data() {
  96. return {
  97. expertsFieldIndex: 0,
  98. expertsFieldList: ["全部"],
  99. currExpertsFieldValue: '',
  100. expertsMainObj: {
  101. loadStatus: 'more',
  102. list_empty: false,
  103. pageTotal: 0,
  104. pageCount: 0,
  105. pagination: {
  106. pageNum: 1,
  107. pageSize: 10
  108. },
  109. listData: []
  110. }
  111. };
  112. },
  113. onLoad() {
  114. this.initData();
  115. },
  116. methods: {
  117. initData() {
  118. this.getExpertsMainFieldListData();
  119. },
  120. getExpertsMainFieldListData() {
  121. expertsMainFieldListData().then((res) => {
  122. this.expertsFieldList = [...this.expertsFieldList, ...res.data || []];
  123. this.getExpertsMainListData();
  124. });
  125. },
  126. bindPickerChange: function(e) {
  127. this.expertsFieldIndex = e.target.value;
  128. const currPickerChangeField = this.expertsFieldList[e.target.value];
  129. this.currExpertsFieldValue = (currPickerChangeField != '全部') ? currPickerChangeField : '';
  130. this.expertsMainObj.pagination.pageNum = 1;
  131. this.getExpertsMainListData();
  132. },
  133. getExpertsMainListData() {
  134. this.expertsMainObj = {
  135. ...this.expertsMainObj,
  136. list_empty: false,
  137. loadStatus: 'loading',
  138. pageTotal: 0
  139. };
  140. // 请求获取列表数据
  141. expertsMainListData({
  142. ...this.expertsMainObj.pagination,
  143. professorField: this.currExpertsFieldValue
  144. }).then(res => {
  145. // 数据总条数
  146. this.expertsMainObj.pageTotal = res.total || 0;
  147. // 如果列表为第一页,返回列表数据清空
  148. if (this.expertsMainObj.pagination.pageNum == 1) {
  149. this.expertsMainObj.expertsModalList = [];
  150. };
  151. // 处理返回结果
  152. if ((res.rows || []).length <= 0) { // 返回结果没有数据
  153. if ((this.expertsMainObj.expertsModalList || []).length <= 0) {
  154. this.expertsMainObj.loadStatus = 'noMores';
  155. this.expertsMainObj.list_empty = true;
  156. } else {
  157. this.expertsMainObj.loadStatus = 'noMores';
  158. }
  159. } else { //返回结果有数据
  160. //返回历史咨询列表存在
  161. this.expertsMainObj.list_empty = false;
  162. // 获取列表数据分页数量
  163. this.expertsMainObj.pageCount = Math.ceil((res.total || 0) / this.expertsMainObj.pagination.pageSize);
  164. if ((res.total || 0) % this.expertsMainObj.pagination.pageSize == 0) {
  165. this.expertsMainObj.pageCount = Math.ceil((res.total || 0) / this.expertsMainObj.pagination.pageSize);
  166. if (this.expertsMainObj.pageCount == 1) {
  167. this.expertsMainObj.pageCount--;
  168. }
  169. } else {
  170. this.expertsMainObj.pageCount--;
  171. };
  172. // 处理页面状态
  173. if (this.expertsMainObj.pageCount === 0) {
  174. this.expertsMainObj.loadStatus = 'noMores'
  175. } else {
  176. this.expertsMainObj.loadStatus = 'more'
  177. }
  178. // 组装返回数据
  179. this.expertsMainObj.expertsModalList.push.apply(this.expertsMainObj.expertsModalList, res.rows || []);
  180. uni.stopPullDownRefresh();
  181. }
  182. }).catch(err => {
  183. this.expertsMainObj.loadStatus = 'noMores';
  184. });
  185. },
  186. handleScrolltolower() {
  187. this.expertsMainObj.loadStatus = 'loading'
  188. if (this.expertsMainObj.pagination.pageNum - 1 >= this.expertsMainObj.pageCount) {
  189. this.expertsMainObj.loadStatus = 'noMores';
  190. return
  191. } else {
  192. this.expertsMainObj.pagination.pageNum++;
  193. this.getExpertsMainListData();
  194. }
  195. },
  196. handleConsultExpertsClick() {
  197. uni.navigateTo({
  198. url: '/pages/experts/modal/index'
  199. });
  200. },
  201. handleExpertsModalItemClick(itemParam) {
  202. debugger
  203. for (let itemIndex = 0; itemIndex < (this.expertsMainObj.expertsModalList || []).length; itemIndex++) {
  204. if (itemParam.id == this.expertsMainObj.expertsModalList[itemIndex].id) {
  205. this.expertsMainObj.expertsModalList[itemIndex].isCheckedItem = true;
  206. } else {
  207. this.expertsMainObj.expertsModalList[itemIndex].isCheckedItem = false;
  208. }
  209. }
  210. this.expertsMainObj = {
  211. ...this.expertsMainObj,
  212. expertsModalList: this.expertsMainObj.expertsModalList
  213. };
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss"
  219. scoped>
  220. .experts {
  221. padding: 0;
  222. &-header {
  223. width: 100%;
  224. background: #ffffff;
  225. &-field {
  226. margin: 24rpx;
  227. width: 100%;
  228. height: 56rpx;
  229. line-height: 56rpx;
  230. .field-content {
  231. display: flex;
  232. .field-img {
  233. flex: 1;
  234. margin-top: 4rpx;
  235. }
  236. .field-text {
  237. flex: 10;
  238. height: 56rpx;
  239. font-size: 34rpx;
  240. font-family: PingFangSC-Medium, PingFang SC;
  241. font-weight: 500;
  242. color: #333333;
  243. line-height: 56rpx;
  244. }
  245. }
  246. }
  247. }
  248. &-content {
  249. width: 100%;
  250. .experts-content-main {
  251. .scroll-Y {
  252. height: calc(100vh - 88rpx - 236rpx - env(safe-area-inset-bottom) - var(--status-bar-height));
  253. }
  254. .experts-content-main-listbody {
  255. .experts-content-main-nodata {
  256. text-align: center;
  257. margin-top: 20rpx;
  258. .expertsmain-nodata {
  259. font-size: 30rpx;
  260. color: #777777;
  261. }
  262. }
  263. .listbody-row {
  264. .listbody-col {
  265. padding: 24rpx 0 0 0 !important;
  266. .listbody-checkeditem {
  267. border-top: 2rpx solid #bae5fa;
  268. border-bottom: 2rpx solid #bae5fa;
  269. }
  270. .listbody-item {
  271. background: #ffffff;
  272. min-height: 288rpx;
  273. width: 100%;
  274. padding-bottom: 24rpx;
  275. .item-content {
  276. display: flex;
  277. padding-top: 24rpx;
  278. &-sub {
  279. flex: 1;
  280. }
  281. &-left {
  282. padding-left: 24rpx;
  283. }
  284. &-right {
  285. padding-right: 24rpx;
  286. }
  287. &-field {
  288. padding: 0rpx 24rpx 0rpx 24rpx;
  289. }
  290. &-institution {
  291. padding: 0rpx 24rpx 0rpx 24rpx;
  292. }
  293. &-text {
  294. height: 42rpx;
  295. font-size: 30rpx;
  296. font-family: PingFangSC-Regular, PingFang SC;
  297. font-weight: 400;
  298. color: #666666;
  299. line-height: 42rpx;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. &-btn {
  308. width: 100%;
  309. position: fixed;
  310. bottom: 40rpx;
  311. padding: 16rpx 32rpx;
  312. .experts-consultbtn {
  313. width: 686rpx;
  314. height: 88rpx;
  315. background: #53a0fd;
  316. border-radius: 4rpx;
  317. width: 100%;
  318. display: flex;
  319. flex-direction: column;
  320. align-items: center;
  321. justify-content: center;
  322. .consultbtn-text {
  323. height: 50rpx;
  324. font-size: 36rpx;
  325. font-family: PingFangSC-Regular, PingFang SC;
  326. font-weight: 400;
  327. color: #ffffff;
  328. line-height: 50rpx;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. </style>