record.vue 5.9 KB

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