index.vue 7.3 KB

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