index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <u-swiper :radius="0" :list="config.file" height="240px" indicator indicatorMode="dot" circular></u-swiper>
  5. </view>
  6. <view class="two" v-if="config.notice">
  7. <up-notice-bar :text="config.notice" duration="3000"></up-notice-bar>
  8. </view>
  9. <view class="thr">
  10. <view class="list" v-for="(item, index) in typeList" :key="index">
  11. <text class="t-icon" :class="[item.icon]"></text>
  12. <view class="text">{{item.name}}</view>
  13. </view>
  14. </view>
  15. <view class="four">
  16. <up-tabs :list="subjectList" keyName="label" @click="toTab"></up-tabs>
  17. </view>
  18. <view class="five">
  19. <up-list @scrolltolower="scrolltolower">
  20. <up-list-item v-for="(item, index) in list" :key="index">
  21. <view class="list">
  22. <view class="left">
  23. <image v-if="item.icon&&item.icon.length>0&&item.icon" class="image"
  24. :src="item.icon[0].url">
  25. </image>
  26. <image v-else class="image" :src="config.icon[0].url"></image>
  27. </view>
  28. <view class="right">
  29. <view class="right_1">
  30. <view class="leftR">
  31. {{item.nick_name||'暂无昵称'}}
  32. </view>
  33. <view class="rightR">
  34. <view class="text">
  35. <span class="text_1">最近可约:</span>
  36. <span class="text_2">{{item.time||'休息中'}}</span>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="right_2">
  41. <view class="text"> 所在院校: </view>
  42. <view class="value"> {{item.college||'暂无'}} </view>
  43. </view>
  44. <view class="right_2">
  45. <view class="text"> 学历: </view>
  46. <view class="value">{{getDict(item.education,'education')}}</view>
  47. </view>
  48. <view class="right_3">
  49. <view class="money">¥{{item.money||'免费'}} </view>
  50. <view class="button">
  51. <button type="warn" size="mini" @click="toBuy(item)">预约</button>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </up-list-item>
  57. </up-list>
  58. </view>
  59. <up-overlay :show="show">
  60. <login @showChange='showChange'></login>
  61. </up-overlay>
  62. </view>
  63. </template>
  64. <script setup lang="ts">
  65. import login from "@/components/login.vue"
  66. import { inject, computed, ref } from 'vue';
  67. //该依赖已内置不需要单独安装
  68. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  69. // 请求接口
  70. const $api = inject('$api');
  71. const $apifile = inject('$apifile');
  72. // 基本信息
  73. const typeList = ref([
  74. { name: '兴趣', icon: 't-icon-xingqu', type: '0' },
  75. { name: '小学', icon: 't-icon-xiaoxue', type: '1' },
  76. { name: '中学', icon: 't-icon-zhongxue', type: '2' },
  77. { name: '高中', icon: 't-icon-gaozhong', type: '3' },
  78. ]);
  79. const config = ref({ icon: [], logo: [], file: [] });
  80. // 列表
  81. const list = ref([]);
  82. const total = ref(0);
  83. const skip = ref(0);
  84. const limit = ref(5);
  85. const page = ref(0);
  86. // 数据是否触底
  87. const is_bottom = ref(false);
  88. // 字典表
  89. const subjectList = ref([]);
  90. const educationList = ref([]);
  91. // 遮罩层
  92. const show = ref(false);
  93. // user
  94. const user = computed(() => {
  95. return uni.getStorageSync('user');
  96. })
  97. onShow(async () => {
  98. await searchConfig();
  99. await searchOther();
  100. await clearPage();
  101. await search();
  102. if (!user.value) show.value = true
  103. })
  104. onPullDownRefresh(async () => {
  105. await clearPage();
  106. await search();
  107. uni.stopPullDownRefresh();
  108. })
  109. // config信息
  110. const searchConfig = async () => {
  111. config.value = uni.getStorageSync('config');
  112. };
  113. // 其他查询信息
  114. const searchOther = async () => {
  115. let res;
  116. // 学科
  117. res = await $api(`dictData`, 'GET', { code: 'subject', is_use: '0' });
  118. if (res.errcode === 0) subjectList.value = res.data;
  119. subjectList.value.unshift({ label: '全部', value: '-1', is_show: true })
  120. // 学历
  121. res = await $api(`dictData`, 'GET', { code: 'education', is_use: '0' });
  122. if (res.errcode === 0) educationList.value = res.data;
  123. };
  124. // 查询
  125. const search = async () => {
  126. const info : any = {
  127. skip: skip.value,
  128. limit: limit.value,
  129. status: '1',
  130. is_show: '0'
  131. }
  132. const res = await $api('teacher', 'GET', info);
  133. if (res.errcode === 0) {
  134. list.value = list.value.concat(res.data)
  135. total.value = res.total
  136. } else {
  137. uni.showToast({
  138. title: res.errmsg || '',
  139. icon: 'error',
  140. });
  141. }
  142. };
  143. // 改变标签
  144. const toTab = async (data) => {
  145. console.log(data);
  146. };
  147. const getDict = (data, model) => {
  148. let res
  149. if (model == 'education') res = educationList.value.find((f) => f.value == data)
  150. return res.label || '暂无'
  151. }
  152. const showChange = () => {
  153. show.value = false
  154. }
  155. // 去预约
  156. const toBuy = (item) => {
  157. console.log(item);
  158. }
  159. const scrolltolower = () => {
  160. if (total.value > list.value.length) {
  161. uni.showLoading({
  162. title: '加载中',
  163. mask: true
  164. })
  165. page.value = page.value + 1;
  166. skip.value = page.value * limit.value;
  167. search();
  168. uni.hideLoading();
  169. } else is_bottom.value = true
  170. };
  171. // 清空列表
  172. const clearPage = () => {
  173. list.value = []
  174. skip.value = 0
  175. limit.value = 6
  176. page.value = 0
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. .content {
  181. display: flex;
  182. flex-direction: column;
  183. background-color: var(--f1Color);
  184. .two {
  185. margin: 2vw 2vw 0 2vw;
  186. border-radius: 5px;
  187. }
  188. .thr {
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. background-color: var(--mainColor);
  193. margin: 2vw;
  194. border-radius: 5px;
  195. padding: 4vw;
  196. .list {
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. .text {
  201. margin: 2vw 0 0 0;
  202. font-size: var(--font14Size);
  203. }
  204. }
  205. }
  206. .four {
  207. margin: 0 2vw;
  208. border-radius: 5px;
  209. background-color: var(--mainColor);
  210. }
  211. .five {
  212. margin: 0 2vw;
  213. .list {
  214. display: flex;
  215. margin: 2vw 0 0 0;
  216. padding: 2vw;
  217. border-radius: 5px;
  218. background-color: var(--mainColor);
  219. .left {
  220. width: 28%;
  221. margin: 0 2vw 0 0;
  222. .image {
  223. width: 25vw;
  224. height: 25vw;
  225. border-radius: 25vw;
  226. }
  227. }
  228. .right {
  229. width: 70%;
  230. .right_1 {
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. .leftR {
  235. width: 40%;
  236. font-size: var(--font16Size);
  237. font-weight: bold;
  238. }
  239. .rightR {
  240. width: 60%;
  241. text-align: right;
  242. font-size: var(--font12Size);
  243. .text {
  244. text-align: center;
  245. border: 1px solid var(--3c9Color);
  246. border-radius: 4px;
  247. padding: 1vw;
  248. background: linear-gradient(to right, #ffffff, #3c9cff59);
  249. .text_1 {
  250. color: var(--3c9Color);
  251. font-weight: bold;
  252. }
  253. .text_2 {
  254. color: var(--ff0Color);
  255. }
  256. }
  257. }
  258. }
  259. .right_2 {
  260. display: flex;
  261. align-items: center;
  262. margin: 1vw 0 0 0;
  263. .text {
  264. font-size: var(--font14Size);
  265. margin: 0 1vw 0 0;
  266. }
  267. .value {
  268. text-align: right;
  269. color: var(--f85Color);
  270. font-size: var(--font12Size);
  271. }
  272. }
  273. .right_3 {
  274. display: flex;
  275. align-items: center;
  276. justify-content: space-between;
  277. .money {
  278. width: 50%;
  279. font-size: var(--font14Size);
  280. color: var(--ff0Color);
  281. }
  282. .button {
  283. width: 50%;
  284. text-align: right;
  285. button {
  286. color: var(--mainColor);
  287. background: linear-gradient(to right, #1e3fdc, #3c9cff);
  288. font-size: var(--font12Size);
  289. border-radius: 5vw;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. </style>