record.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="record" v-if="lotteryList.length">
  4. <view class="record-list" v-for="item in lotteryList" :key="item.id">
  5. <image class="goods-img" :src="item.prize.image" mode=""></image>
  6. <view class="right-data">
  7. <view class="title line1">
  8. {{item.prize.name}}
  9. </view>
  10. <view class="goods-msg">
  11. {{$t(`奖品类型`)}}:
  12. <text class="num">
  13. {{item.prize.type | typeName}}
  14. </text>
  15. </view>
  16. <view class="goods-msg exchange" v-if="item.type == 6 && !item.receive_time"
  17. @click="fromAddress(item)">
  18. {{$t(`立即兑换`)}}
  19. </view>
  20. <view class="goods-msg" v-else>
  21. {{$t(`兑换时间`)}}:
  22. {{item.receive_time || '--'}}
  23. </view>
  24. <view class="goods-msg" v-if="item.deliver_info.deliver_name">
  25. {{$t(`快递公司`)}}:
  26. {{item.deliver_info.deliver_name || '--'}}
  27. </view>
  28. <view class="goods-msg" v-if="item.deliver_info.deliver_number">
  29. {{$t(`快递单号`)}}:
  30. {{item.deliver_info.deliver_number || '--'}}
  31. <!-- #ifndef H5 -->
  32. <view v-if="item.deliver_info.deliver_number" class='copy'
  33. @tap='copyOrderId(item.deliver_info.deliver_number)'>{{$t(`复制`)}}</view>
  34. <!-- #endif -->
  35. <!-- #ifdef H5 -->
  36. <view v-if="item.deliver_info.deliver_number" class='copy copy-data'
  37. :data-clipboard-text="item.deliver_info.deliver_number">{{$t(`复制`)}}</view>
  38. <!-- #endif -->
  39. <!-- <view v-if="item.deliver_info.deliver_number" class='copy' @tap='copyOrderId(item.deliver_info.deliver_number)'>复制</view> -->
  40. </view>
  41. </view>
  42. </view>
  43. <view class='loadingicon acea-row row-center-wrapper' v-if='lotteryList.length > 0'>
  44. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  45. </view>
  46. </view>
  47. <block v-if="lotteryList.length === 0 && !loading">
  48. <emptyPage :title="$t(`暂无中奖记录`)"></emptyPage>
  49. </block>
  50. <userAddress :aleartStatus="addressModel" @getAddress="getAddress" @close="()=>{addressModel = false}">
  51. </userAddress>
  52. <view v-if="addressModel" class="mask" @close="()=>{addressModel = false}"></view>
  53. </view>
  54. </template>
  55. <script>
  56. import ClipboardJS from "@/plugin/clipboard/clipboard.js";
  57. import {
  58. getLotteryList,
  59. receiveLottery
  60. } from '@/api/lottery.js'
  61. import userAddress from '../components/userAddress.vue'
  62. import emptyPage from '@/components/emptyPage.vue'
  63. import colors from '@/mixins/color.js';
  64. export default {
  65. components: {
  66. emptyPage,
  67. userAddress
  68. },
  69. mixins: [colors],
  70. data() {
  71. return {
  72. loading: false,
  73. addressModel: false,
  74. where: {
  75. page: 1,
  76. limit: 20,
  77. },
  78. lotteryList: [],
  79. loadTitle: ''
  80. }
  81. },
  82. onLoad() {
  83. this.getLotteryList()
  84. },
  85. filters: {
  86. typeName(type) {
  87. if (type == 2) {
  88. return '积分'
  89. } else if (type == 3) {
  90. return '余额'
  91. } else if (type == 4) {
  92. return '红包'
  93. } else if (type == 5) {
  94. return '优惠券'
  95. } else if (type == 6) {
  96. return '商品'
  97. }
  98. }
  99. },
  100. onReady: function() {
  101. // #ifdef H5 || APP-PLUS
  102. this.$nextTick(function() {
  103. const clipboard = new ClipboardJS(".copy-data");
  104. clipboard.on("success", () => {
  105. this.$util.Tips({
  106. title: this.$t(`复制成功`)
  107. });
  108. });
  109. });
  110. // #endif
  111. },
  112. methods: {
  113. getAddress(data) {
  114. let addData = data
  115. addData.id = this.addid
  116. addData.address = data.address.province + data.address.city + data.address.district + data.detail
  117. receiveLottery(addData).then(res => {
  118. this.$util.Tips({
  119. title: this.$t(`领取成功`)
  120. });
  121. this.addressModel = false
  122. this.where.page = 1
  123. this.loadend = false;
  124. this.lotteryList = [];
  125. this.getLotteryList()
  126. }).catch(err => {
  127. this.$util.Tips({
  128. title: err
  129. });
  130. })
  131. },
  132. fromAddress(item) {
  133. this.addid = item.id
  134. this.addressModel = true
  135. },
  136. // #ifndef H5
  137. copyOrderId: function(data) {
  138. let that = this;
  139. uni.setClipboardData({
  140. data: data
  141. });
  142. },
  143. // #endif
  144. getLotteryList() {
  145. let that = this;
  146. if (this.loadend) return;
  147. if (this.loading) return;
  148. this.loading = true;
  149. this.loadTitle = '';
  150. getLotteryList(this.where).then(res => {
  151. let list = res.data;
  152. let lotteryList = this.$util.SplitArray(list, this.lotteryList);
  153. let loadend = list.length < this.where.limit;
  154. this.loadend = loadend;
  155. this.loading = false;
  156. this.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  157. this.$set(this, 'lotteryList', lotteryList);
  158. this.$set(this.where, 'page', this.where.page + 1);
  159. }).catch(err => {
  160. that.loading = false;
  161. that.loadTitle = that.$t(`加载更多`);
  162. });
  163. }
  164. },
  165. onReachBottom() {
  166. if (this.lotteryList.length > 0) {
  167. this.getLotteryList();
  168. } else {
  169. this.getLotteryList();
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .record {
  176. background-color: #eee;
  177. }
  178. .record-list {
  179. display: flex;
  180. align-items: center;
  181. background-color: #fff;
  182. padding: 30rpx;
  183. border-bottom: 1px solid #EEEEEE;
  184. height: 100%;
  185. .goods-img {
  186. width: 170rpx;
  187. height: 170rpx;
  188. border-radius: 6rpx;
  189. margin-right: 15rpx;
  190. }
  191. .right-data {
  192. display: flex;
  193. flex-direction: column;
  194. justify-content: space-between;
  195. min-height: 170rpx;
  196. .title {
  197. font-size: 28rpx;
  198. }
  199. .goods-msg {
  200. font-size: 24rpx;
  201. color: #999;
  202. .num {
  203. color: var(--view-theme);
  204. }
  205. .copy {
  206. display: -webkit-inline-box;
  207. display: -webkit-inline-flex;
  208. width: 60rpx;
  209. margin-left: 10rpx;
  210. padding: 0rpx 4rpx;
  211. border: 2rpx solid;
  212. }
  213. }
  214. .exchange {
  215. color: #fff;
  216. background-color: var(--view-theme);
  217. border-radius: 30rpx;
  218. text-align: center;
  219. padding: 4rpx 0;
  220. }
  221. }
  222. .mask {
  223. position: fixed;
  224. top: 0;
  225. left: 0;
  226. right: 0;
  227. bottom: 0;
  228. background-color: rgba(0, 0, 0, 0.8);
  229. z-index: 9;
  230. }
  231. }
  232. </style>