domain-list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="dl-wrap">
  3. <view class="dl-header">
  4. <text class="dl-title">你关心什么问题?</text>
  5. <text class="dl-sub">选择一个你关注的领域,获取定制解决方案</text>
  6. </view>
  7. <view class="dl-list" v-if="loading">
  8. <view class="dl-loading">加载中...</view>
  9. </view>
  10. <view class="dl-list" v-else-if="domains.length === 0">
  11. <view class="dl-empty">暂无可用问题域</view>
  12. </view>
  13. <view class="dl-list" v-else>
  14. <view class="dl-card" v-for="d in domains" :key="getKey(d)" @click="onSelect(d)">
  15. <view class="dl-card-icon">
  16. <text class="dl-card-emoji">{{ d.icon || '🧭' }}</text>
  17. </view>
  18. <view class="dl-card-body">
  19. <text class="dl-card-name">{{ d.name }}</text>
  20. <text class="dl-card-desc">{{ d.description || '了解详情,获取专属方案' }}</text>
  21. </view>
  22. <text class="dl-card-arrow">›</text>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { getProblemDomainList } from '../../utils/api.js'
  29. export default {
  30. data() {
  31. return {
  32. domains: [],
  33. loading: false
  34. }
  35. },
  36. onLoad() {
  37. this.loadDomains()
  38. },
  39. methods: {
  40. getKey(d) {
  41. return d.id || d.code
  42. },
  43. loadDomains() {
  44. var self = this
  45. self.loading = true
  46. uni.showLoading({ title: '加载中...', mask: true })
  47. getProblemDomainList().then(function(res) {
  48. uni.hideLoading()
  49. self.loading = false
  50. var list = res && res.data
  51. self.domains = Array.isArray(list) ? list : []
  52. }).catch(function() {
  53. uni.hideLoading()
  54. self.loading = false
  55. self.domains = []
  56. uni.showToast({ title: '加载失败', icon: 'none' })
  57. })
  58. },
  59. onSelect(d) {
  60. uni.navigateTo({
  61. url: '/pages/problem/flow-intro?code=' + (d.code || '')
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped>
  68. .dl-wrap {
  69. min-height: 100vh;
  70. background: #FFF7ED;
  71. padding: 40rpx 32rpx;
  72. box-sizing: border-box;
  73. }
  74. .dl-header {
  75. margin-bottom: 40rpx;
  76. }
  77. .dl-title {
  78. display: block;
  79. font-size: 40rpx;
  80. font-weight: bold;
  81. color: #333;
  82. text-align: center;
  83. }
  84. .dl-sub {
  85. display: block;
  86. font-size: 26rpx;
  87. color: #999;
  88. text-align: center;
  89. margin-top: 12rpx;
  90. }
  91. .dl-loading, .dl-empty {
  92. text-align: center;
  93. font-size: 28rpx;
  94. color: #999;
  95. padding: 80rpx 0;
  96. }
  97. .dl-card {
  98. display: flex;
  99. align-items: center;
  100. background: #fff;
  101. border-radius: 24rpx;
  102. padding: 32rpx 30rpx;
  103. margin-bottom: 24rpx;
  104. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  105. }
  106. .dl-card:active {
  107. transform: scale(0.98);
  108. }
  109. .dl-card-icon {
  110. width: 100rpx;
  111. height: 100rpx;
  112. border-radius: 24rpx;
  113. background: rgba(249, 115, 22, 0.1);
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. margin-right: 24rpx;
  118. flex-shrink: 0;
  119. }
  120. .dl-card-emoji {
  121. font-size: 48rpx;
  122. }
  123. .dl-card-body {
  124. flex: 1;
  125. }
  126. .dl-card-name {
  127. display: block;
  128. font-size: 32rpx;
  129. font-weight: 600;
  130. color: #333;
  131. }
  132. .dl-card-desc {
  133. display: block;
  134. font-size: 24rpx;
  135. color: #999;
  136. margin-top: 8rpx;
  137. }
  138. .dl-card-arrow {
  139. font-size: 48rpx;
  140. color: #CCC;
  141. margin-left: 12rpx;
  142. }
  143. </style>