index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="list" v-for="(item, index) in list" :key="index">
  5. <view class="list_1">
  6. <view class="number">第 {{index+1}} 步</view>
  7. <image class="image" :src="item.icon&&item.icon.length>0?item.icon[0].url:''">
  8. </image>
  9. <view class="name textOver">{{item.name||'暂无'}}</view>
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script setup lang="ts">
  16. import { getCurrentInstance, ref } from 'vue';
  17. //该依赖已内置不需要单独安装
  18. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  19. // 请求接口
  20. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  21. // 基本信息
  22. const config = ref({ logo: [] });
  23. // 列表
  24. const list = ref([]);
  25. const total = ref(0);
  26. onShow(async () => {
  27. await searchConfig();
  28. await search();
  29. })
  30. onPullDownRefresh(async () => {
  31. await search();
  32. uni.stopPullDownRefresh();
  33. })
  34. // config信息
  35. const searchConfig = async () => {
  36. config.value = uni.getStorageSync('config');
  37. };
  38. // 查询
  39. const search = async () => {
  40. const res = await $api('path', 'GET', {
  41. is_use: '0'
  42. });
  43. if (res.errcode === 0) {
  44. list.value = list.value.concat(res.data)
  45. total.value = res.total
  46. } else {
  47. uni.showToast({
  48. title: res.errmsg || '',
  49. icon: 'error',
  50. });
  51. }
  52. };
  53. </script>
  54. <style lang="scss" scoped>
  55. .content {
  56. display: flex;
  57. flex-direction: column;
  58. .one {
  59. margin: 2vw;
  60. .list {
  61. margin: 0 0 2vw 0;
  62. padding: 2vw;
  63. border-radius: 5px;
  64. background: var(--fFFColor);
  65. border: 1px solid var(--f5Color);
  66. .list_1 {
  67. position: relative;
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. justify-content: center;
  72. .number {
  73. position: absolute;
  74. top: -2px;
  75. left: 2px;
  76. font-size: var(--font14Size);
  77. color: var(--mainColor);
  78. }
  79. .image {
  80. width: 15vw;
  81. height: 15vw;
  82. }
  83. .name {
  84. color: var(--mainColor);
  85. margin: 2vw 0;
  86. font-size: var(--font16Size);
  87. }
  88. }
  89. }
  90. }
  91. }
  92. </style>