index.vue 10 KB

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