record.vue 5.2 KB

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