record.vue 5.8 KB

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