prize.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <app-layout>
  3. <view v-if="!list || !list.length" class="no-content">暂无中奖记录</view>
  4. <block v-for="(v,k) in list" :key="k">
  5. <view class="dir-left-nowrap line cross-center">
  6. <view class="dir-top-nowrap box-grow-1 main-center">
  7. <view class="name t-omit" v-text="v.name"></view>
  8. <view class="time" v-text="v.created_at"></view>
  9. </view>
  10. <view class="box-grow-0">
  11. <app-button @click="submit(v)" v-if="v.status == 1 && v.type == 4" background="#FFFFFF" height="56" width="170" color="#FF4544" font-size="27" round>立即兑换</app-button>
  12. <app-button v-if="v.status == 2 && v.type == 4" background="#CDCDCD" height="56" width="170" color="#FFFFFF" font-size="27" disabled round>已兑换</app-button>
  13. <app-button v-if="v.status == 2 && v.type != 4" background="#CDCDCD" height="56" width="170" color="#FFFFFF" font-size="27" disabled round>已发放</app-button>
  14. </view>
  15. </view>
  16. </block>
  17. </app-layout>
  18. </template>
  19. <script>
  20. export default {
  21. name: "prize",
  22. components: {},
  23. data() {
  24. return {
  25. list: [],
  26. page: 1,
  27. args: false,
  28. load: false,
  29. }
  30. },
  31. onShow: function () {
  32. const self = this;
  33. self.$showLoading({title: '加载中'});
  34. self.$request({
  35. url: self.$api.scratch.prize,
  36. data: {
  37. page: 1,
  38. }
  39. }).then(info => {
  40. self.$hideLoading();
  41. if (info.code === 0) {
  42. self.list = info.data;
  43. }
  44. }).catch(e => {
  45. self.$hideLoading();
  46. });
  47. },
  48. /**
  49. * 页面上拉触底事件的处理函数
  50. */
  51. onReachBottom: function () {
  52. const self = this;
  53. if (self.args || self.load)
  54. return;
  55. self.load = true;
  56. let page = self.page + 1;
  57. self.$request({
  58. url: self.$api.scratch.prize,
  59. data: {
  60. page: page,
  61. }
  62. }).then(info => {
  63. if (info.code === 0) {
  64. [self.page, self.args, self.list] = [page, info.data.length === 0, self.list.concat(info.data)];
  65. }
  66. self.load = false;
  67. });
  68. },
  69. methods: {
  70. submit: function (list) {
  71. const mchList = [{
  72. "mch_id": 0,
  73. "scratch_id": list.id,
  74. "goods_list": [{
  75. "id": list.goods.id,
  76. "attr": list.attr_list,
  77. "num": 1,
  78. "cart_id": 0,
  79. "goods_attr_id": list.attr_id
  80. }]
  81. }];
  82. uni.navigateTo({
  83. url: `/pages/order-submit/order-submit?mch_list=` +
  84. JSON.stringify(mchList) +
  85. `&preview_url=` + encodeURIComponent(this.$api.scratch.order_preview) +
  86. `&submit_url=` + encodeURIComponent(this.$api.scratch.order_submit)
  87. });
  88. },
  89. }
  90. }
  91. </script>
  92. <style scoped lang="scss">
  93. .no-content {
  94. color: #888;
  95. padding-top: #{100rpx};
  96. text-align: center;
  97. }
  98. .line {
  99. height: #{140rpx};
  100. padding: 0 #{24rpx};
  101. border-bottom: 1px solid $uni-weak-color-one;
  102. background: #FFFFFF;
  103. .name {
  104. font-size: #{28rpx};
  105. color: #353535;
  106. margin-right: #{80rpx};
  107. }
  108. .time {
  109. margin-top: #{22rpx};
  110. font-size: #{24rpx};
  111. color: #666666;
  112. }
  113. }
  114. </style>