record.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 this.$t(`积分`)
  89. } else if (type == 3) {
  90. return this.$t(`余额`)
  91. } else if (type == 4) {
  92. return this.$t(`红包`)
  93. } else if (type == 5) {
  94. return this.$t(`优惠券`)
  95. } else if (type == 6) {
  96. return this.$t(`商品`)
  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. }).catch(err => {
  123. this.$util.Tips({
  124. title: err
  125. });
  126. })
  127. },
  128. fromAddress(item) {
  129. this.addid = item.id
  130. this.addressModel = true
  131. },
  132. // #ifndef H5
  133. copyOrderId: function(data) {
  134. let that = this;
  135. uni.setClipboardData({
  136. data: data
  137. });
  138. },
  139. // #endif
  140. getLotteryList() {
  141. let that = this;
  142. if (this.loadend) return;
  143. if (this.loading) return;
  144. this.loading = true;
  145. this.loadTitle = '';
  146. getLotteryList(this.where).then(res => {
  147. let list = res.data;
  148. let lotteryList = this.$util.SplitArray(list, this.lotteryList);
  149. let loadend = list.length < this.where.limit;
  150. this.loadend = loadend;
  151. this.loading = false;
  152. this.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  153. this.$set(this, 'lotteryList', lotteryList);
  154. this.$set(this.where, 'page', this.where.page + 1);
  155. }).catch(err => {
  156. that.loading = false;
  157. that.loadTitle = that.$t(`加载更多`);
  158. });
  159. }
  160. },
  161. onReachBottom() {
  162. if (this.lotteryList.length > 0) {
  163. this.getLotteryList();
  164. } else {
  165. this.getLotteryList();
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .record {
  172. background-color: #eee;
  173. }
  174. .record-list {
  175. display: flex;
  176. align-items: center;
  177. background-color: #fff;
  178. padding: 30rpx;
  179. border-bottom: 1px solid #EEEEEE;
  180. height: 100%;
  181. .goods-img {
  182. width: 170rpx;
  183. height: 170rpx;
  184. border-radius: 6rpx;
  185. margin-right: 15rpx;
  186. }
  187. .right-data {
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: space-between;
  191. min-height: 170rpx;
  192. .title {
  193. font-size: 28rpx;
  194. }
  195. .goods-msg {
  196. font-size: 24rpx;
  197. color: #999;
  198. .num {
  199. color: var(--view-theme);
  200. }
  201. .copy {
  202. display: -webkit-inline-box;
  203. display: -webkit-inline-flex;
  204. width: 60rpx;
  205. margin-left: 10rpx;
  206. padding: 0rpx 4rpx;
  207. border: 2rpx solid;
  208. }
  209. }
  210. .exchange {
  211. color: #fff;
  212. background-color: var(--view-theme);
  213. border-radius: 30rpx;
  214. text-align: center;
  215. padding: 4rpx 0;
  216. }
  217. }
  218. .mask {
  219. position: fixed;
  220. top: 0;
  221. left: 0;
  222. right: 0;
  223. bottom: 0;
  224. background-color: rgba(0, 0, 0, 0.8);
  225. z-index: 9;
  226. }
  227. }
  228. </style>