You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="content" v-if="state.list">
  3. <!-- <view class="item" v-for="(item,index) in state.list" :key='index'>
  4. <view class="title">
  5. <view>
  6. <text><text>{{item.productName}}</text>&nbsp;&nbsp;<text>¥{{item.discountPrice * 0.01}}</text></text>
  7. </view>
  8. <text class="add" @click="add(item.equtyId)">加购</text>
  9. </view>
  10. </view> -->
  11. <view v-for="(item, index) in state.list" :key="index" @click="onClick(item)" :data-code="item" class="item"
  12. style="justify-content: flex-start; display: flex; font-size: 28rpx; min-height: 20px; background-color: #22dbc8; color: white; border-radius: 20rpx; padding: 20px; margin: 20px;">
  13. <view style="display: flex; flex-direction: column; flex: 1;">
  14. <text>{{ item.productName }}</text>
  15. </view>
  16. <view>></view>
  17. </view>
  18. <view class="bottom-line" v-if="state.flags">我是有底线的~~~</view>
  19. </view>
  20. <view v-else>
  21. <empty title='暂无权益列表' />
  22. </view>
  23. </template>
  24. <script setup lang="ts">
  25. import empty from "@/components/empty/empty.vue";
  26. import { onLoad, onReachBottom } from "@dcloudio/uni-app";
  27. import { reactive } from "vue";
  28. import { equityProductsApi, addEquityListApi } from "@/utils/network/api.js";
  29. import { stringToJson } from "@/utils/network/encryption";
  30. import { request } from "@/utils/network/request";
  31. import { msg, navTo } from "@/utils/utils";
  32. import { getEquityListApi } from "@/utils/network/api";
  33. import {
  34. getItem,
  35. StorageKeys,
  36. setItem
  37. } from "@/utils/storage";
  38. const state = reactive({
  39. list: [], //权益数据
  40. pageNo: 1,
  41. pageSize: 15,
  42. flags: false
  43. })
  44. onLoad((option : any) => {
  45. // 获取全部权益列表
  46. getList();
  47. console.log("option", option)
  48. })
  49. const getList = () => {
  50. const options = {
  51. type: 2,
  52. data: {
  53. "pageNo": state.pageNo,
  54. "pageSize": state.pageSize,
  55. 'status': "ENABLE" //可使用
  56. },
  57. method: 'POST',
  58. showLoading: true,
  59. }
  60. request(getEquityListApi, options).then((res) => {
  61. state.list = [...state.list, ...stringToJson(res.bizContent).data]
  62. })
  63. }
  64. const add = (equtyId) => {
  65. navTo(`/subpackage/after-sale/add-equity/choice-order?equtyId=${equtyId}`, true)
  66. }
  67. const onClick = (item) => {
  68. const params = encodeURIComponent(JSON.stringify(item))
  69. navTo(`/subpackage/after-sale/add-equity/add-equity-details?params=${params}`, true)
  70. }
  71. // 触底加载
  72. onReachBottom(() => {
  73. if (state.list.length < state.pageNo * 15) return state.flags = true
  74. console.log("触底了")
  75. state.pageNo++
  76. getList()
  77. })
  78. </script>
  79. <style scoped lang="scss">
  80. .content {
  81. width: 100%;
  82. }
  83. .item {
  84. width: 90%;
  85. margin: 20rpx auto;
  86. background-color: rgb(41, 199, 207);
  87. border-radius: 20rpx;
  88. padding: 20rpx;
  89. box-sizing: border-box;
  90. color: white;
  91. font-size: 32rpx;
  92. }
  93. .item>.title {
  94. width: 100%;
  95. display: flex;
  96. justify-content: space-between;
  97. align-items: center;
  98. }
  99. .add {
  100. background: white;
  101. border-radius: 10rpx;
  102. padding: 6rpx 14rpx;
  103. color: #000;
  104. white-space: nowrap;
  105. display: inline-block;
  106. margin-left: 20rpx;
  107. }
  108. .bottom-line {
  109. text-align: center;
  110. margin: 30rpx 0 50rpx 0;
  111. font-size: 32rpx;
  112. padding-bottom: 10rpx;
  113. }
  114. </style>