Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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. },
  49. method: 'POST',
  50. showLoading: true,
  51. }
  52. request(getEquityListApi, options).then((res) => {
  53. // const data = stringToJson(res.bizContent);
  54. state.list = [ ...state.list,...stringToJson(res.bizContent).data]
  55. // console.log("222", data.data)
  56. })
  57. }
  58. const add = (equtyId) => {
  59. navTo(`/subpackage/after-sale/add-equity/choice-order?equtyId=${equtyId}`, true)
  60. }
  61. // 触底加载
  62. onReachBottom(() => {
  63. if (state.list.length < state.pageNo * 15) return state.flags = true
  64. console.log("触底了")
  65. state.pageNo++
  66. getList()
  67. })
  68. </script>
  69. <style scoped lang="scss">
  70. .content {
  71. width: 100%;
  72. }
  73. .item {
  74. width: 90%;
  75. margin: 20rpx auto;
  76. background-color: rgb(41, 199, 207);
  77. border-radius: 20rpx;
  78. padding: 20rpx;
  79. box-sizing: border-box;
  80. color: white;
  81. font-size: 32rpx;
  82. }
  83. .item>.title {
  84. width: 100%;
  85. display: flex;
  86. justify-content: space-between;
  87. align-items: center;
  88. }
  89. .add {
  90. background: white;
  91. border-radius: 10rpx;
  92. padding: 6rpx 14rpx;
  93. color: #000;
  94. white-space: nowrap;
  95. display: inline-block;
  96. margin-left: 20rpx;
  97. }
  98. .bottom-line {
  99. text-align: center;
  100. margin: 30rpx 0 50rpx 0;
  101. }
  102. </style>