Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

add-equity.vue 2.5KB

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