record.vue 6.8 KB

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