index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!-- 我的奖品 -->
  2. <template>
  3. <s-layout title="我的奖品">
  4. <view class="ss-m-t-20">
  5. <view
  6. class="ss-order-card-warp bg-white"
  7. style="border-radius: 10rpx; margin-bottom: 20rpx;"
  8. v-for="val in state.pagination.list" :key="val.record.id"
  9. >
  10. <view class="ss-flex ss-col-stretch ss-row-between border-bottom ss-p-b-20">
  11. <view class="img-box ss-m-r-24">
  12. <image class="order-img" :src="sheep.$url.cdn(val.prize.image)" mode="aspectFill"></image>
  13. </view>
  14. <view class="box-right ss-flex-col ss-row-between">
  15. <view class="title-text ss-line-2">{{ val.prize.name }}</view>
  16. <view class="ss-flex">
  17. <view class="ss-flex ss-col-center">
  18. <view class="price-text ss-flex ss-col-center">
  19. {{ val.prize.extend.provinceName + ' ' + (val.prize.extend.cityName ? val.prize.extend.cityName : '') + ' ' + (val.prize.extend.districtName ? val.prize.extend.districtName : '') }}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="spec-text">中奖时间: {{ val.record.createTime }}</view>
  24. <view v-if="orderReceiveInfo(val)" class="spec-text">收货信息:{{ orderReceiveInfo(val) }}</view>
  25. <view class="spec-text" v-if="val.record.deliverInfo">
  26. 发货信息:{{ val.record.deliverInfo ? JSON.parse(val.record.deliverInfo).name + '-' + JSON.parse(val.record.deliverInfo).no : ''}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="tool-box">
  31. <view v-if="!val.record.isReceive && !val.record.receiveInfo" class="ss-flex">
  32. <button class="tool-btn ss-reset-button" @tap.stop="handleReceive(val.record.id)">领取</button>
  33. <button class="tool-btn ss-reset-button" @tap.stop="handleGiveUp(val)" style="color: #ff3000">放弃</button>
  34. </view>
  35. <view style="color: #00897B" class="ss-m-x-20" v-else-if="val.record.deliverInfo">已发货</view>
  36. <view style="color: #fb8c00" class="ss-m-x-20" v-else>等待发货</view>
  37. </view>
  38. </view>
  39. </view>
  40. <uni-load-more
  41. v-if="state.pagination.total > 0"
  42. :status="state.loadStatus"
  43. :content-text="{
  44. contentdown: '上拉加载更多',
  45. }"
  46. @tap="loadMore"
  47. />
  48. <s-empty v-if="!state.pagination.list.length" text="暂无奖品" icon="/static/collect-empty.png" />
  49. </s-layout>
  50. </template>
  51. <script setup>
  52. import sheep from '@/sheep';
  53. import { reactive, computed } from 'vue';
  54. import { onShow, onReachBottom } from '@dcloudio/uni-app';
  55. import _ from 'lodash-es';
  56. import PrizeApi from '@/sheep/api/prizeDraw/index';
  57. const state = reactive({
  58. pagination: {
  59. list: [],
  60. total: 0,
  61. pageNo: 1,
  62. pageSize: 6,
  63. },
  64. loadStatus: '',
  65. });
  66. async function getData() {
  67. state.loadStatus = 'loading';
  68. const { code, data } = await PrizeApi.getLuckLotteryRecordPage({
  69. pageNo: state.pagination.pageNo,
  70. pageSize: state.pagination.pageSize,
  71. });
  72. if (code !== 0) {
  73. return;
  74. }
  75. state.pagination.list = _.concat(state.pagination.list, data.list);
  76. state.pagination.total = data.total;
  77. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  78. }
  79. // 加载更多
  80. function loadMore() {
  81. if (state.loadStatus === 'noMore') {
  82. return;
  83. }
  84. state.pagination.pageNo++;
  85. getData();
  86. }
  87. // 收货信息
  88. const orderReceiveInfo = computed(() => (item) => {
  89. const info = item.record.receiveInfo ? JSON.parse(item.record.receiveInfo) : {}
  90. if (!info || !Object.keys(info).length) return ''
  91. return `${info.name},${info.mobile},${info.areaName} ${info.detailAddress}`
  92. })
  93. // 领取
  94. const handleReceive = (id) => {
  95. sheep.$router.go('/pages/user/prize/receive', { id });
  96. }
  97. // 放弃
  98. async function handleGiveUp (item) {
  99. await PrizeApi.luckyLotteryRecordGiveUp(item.record.id)
  100. uni.showToast({
  101. title: '操作成功',
  102. icon: 'none',
  103. duration: 2000
  104. })
  105. getData()
  106. }
  107. onReachBottom(() => {
  108. loadMore();
  109. });
  110. onShow(() => {
  111. getData();
  112. });
  113. </script>
  114. <style lang="scss" scoped>
  115. .tool-btn {
  116. width: 160rpx;
  117. height: 60rpx;
  118. background: #f6f6f6;
  119. font-size: 26rpx;
  120. border-radius: 30rpx;
  121. margin-right: 10rpx;
  122. &:last-of-type {
  123. margin-right: 0;
  124. }
  125. }
  126. .point-img {
  127. width: 36rpx;
  128. height: 36rpx;
  129. margin: 0 4rpx;
  130. }
  131. .ss-order-card-warp {
  132. padding: 20rpx;
  133. .img-box {
  134. width: 164rpx;
  135. height: 164rpx;
  136. border-radius: 10rpx;
  137. overflow: hidden;
  138. .order-img {
  139. width: 164rpx;
  140. height: 164rpx;
  141. }
  142. }
  143. .box-right {
  144. flex: 1;
  145. }
  146. .title-text {
  147. font-size: 28rpx;
  148. font-weight: 500;
  149. line-height: 40rpx;
  150. }
  151. .spec-text {
  152. font-size: 24rpx;
  153. font-weight: 400;
  154. color: $dark-9;
  155. min-width: 0;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. display: -webkit-box;
  159. -webkit-line-clamp: 1;
  160. -webkit-box-orient: vertical;
  161. }
  162. .price-text {
  163. font-size: 24rpx;
  164. font-weight: 500;
  165. font-family: OPPOSANS;
  166. }
  167. .total-text {
  168. font-size: 24rpx;
  169. font-weight: 400;
  170. line-height: 24rpx;
  171. color: $dark-9;
  172. margin-left: 8rpx;
  173. }
  174. }
  175. .tool-box {
  176. display: flex;
  177. justify-content: flex-end;
  178. margin-top: 10px;
  179. }
  180. </style>