index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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" @click="toList(item)">
  11. <text class="t-icon" :class="[item.remark]"></text>
  12. <view class="text">{{item.label}}</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" v-if="total>0">
  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 textOne">
  30. {{item.name||'暂无'}}
  31. </view>
  32. <view class="right_2">
  33. <view class="text">老师: </view>
  34. <view class="value"> {{item.teacher_name||'暂无'}} </view>
  35. </view>
  36. <view class="right_3">
  37. <view class="text">
  38. <span class="text_1">最近可约:</span>
  39. <span class="text_2">{{item.start_time||'休息中'}}</span>
  40. </view>
  41. </view>
  42. <view class="right_4">
  43. <view class="money">¥{{item.money||'免费'}} </view>
  44. <view class="button">
  45. <button type="warn" size="mini" @click="toBuy(item)">预约</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </up-list-item>
  51. </up-list>
  52. </view>
  53. <up-empty v-else mode="list" icon="/static/list.png"></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. const $apifile = inject('$apifile');
  70. // 基本信息
  71. const typeList = ref([]);
  72. const config = ref({ icon: [], logo: [], file: [] });
  73. // 列表
  74. const list = ref([]);
  75. const total = ref(0);
  76. const skip = ref(0);
  77. const limit = ref(5);
  78. const page = ref(0);
  79. // 数据是否触底
  80. const is_bottom = ref(false);
  81. // 字典表
  82. const subjectList = ref([]);
  83. const educationList = ref([]);
  84. // 遮罩层
  85. const show = ref(false);
  86. // user
  87. const user = computed(() => {
  88. return uni.getStorageSync('user');
  89. })
  90. onShow(async () => {
  91. await searchConfig();
  92. await searchOther();
  93. await clearPage();
  94. await search();
  95. if (!user.value) show.value = true
  96. })
  97. onPullDownRefresh(async () => {
  98. await clearPage();
  99. await search();
  100. uni.stopPullDownRefresh();
  101. })
  102. // config信息
  103. const searchConfig = async () => {
  104. config.value = uni.getStorageSync('config');
  105. };
  106. // 其他查询信息
  107. const searchOther = async () => {
  108. let res;
  109. // 学科
  110. res = await $api(`dictData`, 'GET', { code: 'subject', is_use: '0' });
  111. if (res.errcode === 0) subjectList.value = res.data;
  112. subjectList.value.unshift({ label: '全部', value: '-1', is_show: true })
  113. // 学历
  114. res = await $api(`dictData`, 'GET', { code: 'education', is_use: '0' });
  115. if (res.errcode === 0) educationList.value = res.data;
  116. // 类型
  117. res = await $api(`dictData`, 'GET', { code: 'courseType', is_use: '0' });
  118. if (res.errcode === 0) typeList.value = res.data;
  119. };
  120. // 查询
  121. const search = async () => {
  122. const info : any = {
  123. skip: skip.value,
  124. limit: limit.value,
  125. status: '1',
  126. is_show: '0'
  127. }
  128. const res = await $api('course/appHome', 'GET', info);
  129. if (res.errcode === 0) {
  130. list.value = list.value.concat(res.data)
  131. total.value = res.total
  132. } else {
  133. uni.showToast({
  134. title: res.errmsg || '',
  135. icon: 'error',
  136. });
  137. }
  138. };
  139. // 改变标签
  140. const toTab = async (data) => {
  141. console.log(data);
  142. };
  143. const showChange = () => {
  144. show.value = false
  145. }
  146. // 去预约
  147. const toBuy = (item) => {
  148. uni.navigateTo({
  149. url: `/pagesHome/course/index?id=${item._id}`
  150. })
  151. }
  152. // 去查看
  153. const toList = (item) => {
  154. uni.navigateTo({
  155. url: `/pagesHome/list/index?type=${item.value}&name=${item.label}`
  156. })
  157. }
  158. const scrolltolower = () => {
  159. if (total.value > list.value.length) {
  160. uni.showLoading({
  161. title: '加载中',
  162. mask: true
  163. })
  164. page.value = page.value + 1;
  165. skip.value = page.value * limit.value;
  166. search();
  167. uni.hideLoading();
  168. } else is_bottom.value = true
  169. };
  170. // 清空列表
  171. const clearPage = () => {
  172. list.value = []
  173. skip.value = 0
  174. limit.value = 6
  175. page.value = 0
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .content {
  180. display: flex;
  181. flex-direction: column;
  182. min-height: 100vh;
  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: 2vw 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: 2vw;
  226. }
  227. }
  228. .right {
  229. width: 70%;
  230. .right_1 {
  231. font-size: var(--font16Size);
  232. font-weight: bold;
  233. }
  234. .right_2 {
  235. display: flex;
  236. align-items: center;
  237. margin: 1vw 0 0 0;
  238. .text {
  239. font-size: var(--font14Size);
  240. margin: 0 1vw 0 0;
  241. }
  242. .value {
  243. text-align: right;
  244. color: var(--f85Color);
  245. font-size: var(--font12Size);
  246. }
  247. }
  248. .right_3 {
  249. margin: 1vw 0;
  250. .text {
  251. font-size: var(--font12Size);
  252. text-align: center;
  253. border: 1px solid var(--3c9Color);
  254. border-radius: 4px;
  255. padding: 1vw;
  256. background: linear-gradient(to right, #ffffff, #3c9cff59);
  257. .text_1 {
  258. color: var(--3c9Color);
  259. font-weight: bold;
  260. }
  261. .text_2 {
  262. color: var(--ff0Color);
  263. }
  264. }
  265. }
  266. .right_4 {
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. .money {
  271. width: 50%;
  272. font-size: var(--font14Size);
  273. color: var(--ff0Color);
  274. }
  275. .button {
  276. width: 50%;
  277. text-align: right;
  278. button {
  279. color: var(--mainColor);
  280. background: linear-gradient(to right, #1e3fdc, #3c9cff);
  281. font-size: var(--font12Size);
  282. border-radius: 5vw;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. .is_bottom {
  290. width: 100%;
  291. text-align: center;
  292. text {
  293. padding: 2vw 0;
  294. display: inline-block;
  295. color: var(--f85Color);
  296. font-size: var(--font12Size);
  297. }
  298. }
  299. }
  300. </style>