index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. const scrolltolower = () => {
  144. if (total.value > list.value.length) {
  145. uni.showLoading({
  146. title: '加载中',
  147. mask: true
  148. })
  149. page.value = page.value + 1;
  150. skip.value = page.value * limit.value;
  151. search();
  152. uni.hideLoading();
  153. } else is_bottom.value = true
  154. };
  155. // 清空列表
  156. const clearPage = () => {
  157. list.value = []
  158. skip.value = 0
  159. limit.value = 6
  160. page.value = 0
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .content {
  165. display: flex;
  166. flex-direction: column;
  167. min-height: 100vh;
  168. background-color: var(--f1Color);
  169. .one {
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. padding: 2vw;
  174. background-color: var(--mainColor);
  175. .one_1 {
  176. padding: 0 2vw;
  177. width: 75vw;
  178. input {
  179. padding: 2vw;
  180. background-color: var(--f1Color);
  181. font-size: var(--font14Size);
  182. border-radius: 5px;
  183. }
  184. }
  185. .one_2 {
  186. .button {
  187. background-color: var(--3c9Color);
  188. color: var(--mainColor);
  189. }
  190. }
  191. }
  192. .two {
  193. margin: 0 2vw;
  194. .list {
  195. display: flex;
  196. margin: 2vw 0 0 0;
  197. padding: 2vw;
  198. border-radius: 5px;
  199. background-color: var(--mainColor);
  200. .left {
  201. width: 28%;
  202. margin: 0 2vw 0 0;
  203. .image {
  204. width: 25vw;
  205. height: 25vw;
  206. border-radius: 2vw;
  207. }
  208. }
  209. .right {
  210. width: 70%;
  211. .right_1 {
  212. display: flex;
  213. align-items: center;
  214. justify-content: space-between;
  215. .leftR {
  216. width: 40%;
  217. font-size: var(--font16Size);
  218. font-weight: bold;
  219. }
  220. .rightR {
  221. width: 60%;
  222. text-align: right;
  223. font-size: var(--font12Size);
  224. .text {
  225. text-align: center;
  226. border: 1px solid var(--3c9Color);
  227. border-radius: 4px;
  228. padding: 1vw;
  229. background: linear-gradient(to right, #ffffff, #3c9cff59);
  230. .text_1 {
  231. color: var(--3c9Color);
  232. font-weight: bold;
  233. }
  234. .text_2 {
  235. color: var(--ff0Color);
  236. }
  237. }
  238. }
  239. }
  240. .right_2 {
  241. display: flex;
  242. align-items: center;
  243. margin: 1vw 0 0 0;
  244. .text {
  245. font-size: var(--font14Size);
  246. margin: 0 1vw 0 0;
  247. }
  248. .value {
  249. text-align: right;
  250. color: var(--f85Color);
  251. font-size: var(--font12Size);
  252. }
  253. }
  254. .right_3 {
  255. display: flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. .money {
  259. width: 50%;
  260. font-size: var(--font14Size);
  261. color: var(--ff0Color);
  262. }
  263. .button {
  264. width: 50%;
  265. text-align: right;
  266. button {
  267. color: var(--mainColor);
  268. background: linear-gradient(to right, #1e3fdc, #3c9cff);
  269. font-size: var(--font12Size);
  270. border-radius: 5vw;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .is_bottom {
  278. width: 100%;
  279. text-align: center;
  280. text {
  281. padding: 2vw 0;
  282. display: inline-block;
  283. color: var(--f85Color);
  284. font-size: var(--font12Size);
  285. }
  286. }
  287. }
  288. </style>