mycases.nvue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="container">
  3. <scroll-view class="list" scroll-y="true">
  4. <view class="caseItem" v-for="(item, index) in list" :key="index">
  5. <text class="caseName">{{item.name}}</text>
  6. <text class="useBtn" @click="useCase(item.id)">使用</text>
  7. </view>
  8. </scroll-view>
  9. </view>
  10. </template>
  11. <script>
  12. import request from '@/utils/http/request.js'
  13. export default {
  14. data() {
  15. return {
  16. list: []
  17. }
  18. },
  19. onLoad() {
  20. this.getList()
  21. },
  22. methods: {
  23. async getList() {
  24. try {
  25. const res = await request({
  26. url: '/userCare/careList',
  27. method: 'POST',
  28. data: { page: 0, size: 100 }
  29. })
  30. if (res && res.data && res.data.records) {
  31. this.list = res.data.records.map(item => ({
  32. id: item.id,
  33. name: item.title || item.name || ''
  34. }))
  35. }
  36. } catch (e) {
  37. console.error('获取方案列表失败', e)
  38. }
  39. },
  40. useCase(id) {
  41. const deviceId = uni.getStorageSync('deviceId')
  42. if (!deviceId) {
  43. uni.navigateTo({
  44. url: `/pages/device/search/search?case=${id}`
  45. })
  46. } else {
  47. uni.navigateTo({
  48. url: `/pages/device/deviceInfo/deviceInfo?case=${id}&deviceId=${deviceId}`
  49. })
  50. }
  51. }
  52. }
  53. }
  54. </script>
  55. <style>
  56. .container {
  57. flex: 1;
  58. background-color: #ffffff;
  59. }
  60. .list {
  61. flex: 1;
  62. padding-left: 46rpx;
  63. padding-right: 46rpx;
  64. padding-top: 30rpx;
  65. }
  66. .caseItem {
  67. flex-direction: row;
  68. justify-content: space-between;
  69. align-items: center;
  70. width: 658rpx;
  71. height: 118rpx;
  72. background-color: #F3F3F3;
  73. border-radius: 20rpx;
  74. padding-left: 28rpx;
  75. padding-right: 28rpx;
  76. margin-bottom: 24rpx;
  77. }
  78. .caseName {
  79. font-size: 32rpx;
  80. color: #545F71;
  81. }
  82. .useBtn {
  83. font-size: 26rpx;
  84. color: #389588;
  85. }
  86. </style>