index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="px-20">
  4. <view class="order_card bg--w111-fff rd-24rpx pt-32 pb-32 pl-24 pr-24"
  5. v-for="(item, index) in bargain" :key="index">
  6. <view class="flex-between-center">
  7. <text class="fs-28 lh-40rpx">{{item.add_time}}</text>
  8. <text class="font-color fs-26" v-if="item.status === 1">活动进行中</text>
  9. <text class="font-color fs-26" v-else-if="item.status === 3">砍价成功</text>
  10. <text class="font-color fs-26" v-else>活动已结束</text>
  11. </view>
  12. <view class="flex-between-center mt-26">
  13. <image :src="item.image" class="w-136 h-136 rd-16rpx"></image>
  14. <view class="flex-1 pl-20">
  15. <view class="w-504 line2 fs-28 lh-40rpx">{{item.title}}</view>
  16. <view class="flex items-baseline mt-20">
  17. <text class="fs-24 text--w111-999">已砍至</text>
  18. <baseMoney :money="item.residue_price" symbolSize="20" integerSize="32" decimalSize="20" weight></baseMoney>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="pt-24 bt mt-32 flex-between-center">
  23. <view class="flex-y-center fs-24" v-if="item.status === 1">
  24. <text class="pr-12 text--w111-999">剩余:</text>
  25. <count-down
  26. justify-left="justify-content:left"
  27. :is-day="true"
  28. tip-text=" "
  29. day-text=" "
  30. hour-text="时"
  31. minute-text="分"
  32. second-text="秒"
  33. dotColor="#999"
  34. :datatime="item.datatime"></count-down>
  35. </view>
  36. <text class="pr-12 text--w111-999 fs-24" v-if="item.status === 2">活动已结束</text>
  37. <text class="pr-12 text--w111-999 fs-24" v-if="item.status === 3">砍价已成功</text>
  38. <view class="flex">
  39. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 border_ccc"
  40. v-if="item.status === 1"
  41. @tap="getBargainUserCancel(item.bargain_id)"
  42. >取消活动</view>
  43. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 bg-color text--w111-fff"
  44. v-if="item.status === 1"
  45. @tap="goDetail(item.bargain_id)"
  46. >{{item.pay_status ? '立即付款' : '继续砍价'}}</view>
  47. <view class="btn w-154 h-56 rd-30rpx flex-center fs-24 bg-color text--w111-fff"
  48. v-if="[2,3].includes(item.status)" @tap="goPage('/pages/activity/goods_bargain/index')">重开一个</view>
  49. </view>
  50. </view>
  51. </view>
  52. <Loading :loaded="status" :loading="loadingList"></Loading>
  53. </view>
  54. <view class="px-20 mt-20" v-if="!bargain.length">
  55. <emptyPage title="暂无砍价记录~" src="/statics/images/noOrder.gif"></emptyPage>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import CountDown from "@/components/countDown";
  61. import emptyPage from '@/components/emptyPage.vue'
  62. import {
  63. getBargainUserList,
  64. getBargainUserCancel
  65. } from "@/api/activity";
  66. import {
  67. getUserInfo
  68. } from '@/api/user.js';
  69. import Loading from "@/components/Loading";
  70. import home from '@/components/home';
  71. import colors from "@/mixins/color";
  72. export default {
  73. name: "BargainRecord",
  74. components: {
  75. CountDown,
  76. Loading,
  77. emptyPage,
  78. home
  79. },
  80. props: {},
  81. mixins: [colors],
  82. data: function() {
  83. return {
  84. bargain: [],
  85. status: false, //砍价列表是否获取完成 false 未完成 true 完成
  86. loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
  87. page: 1, //页码
  88. limit: 20, //数量
  89. userInfo: {}
  90. };
  91. },
  92. onLoad: function() {
  93. this.getBargainUserList();
  94. this.getUserInfo();
  95. },
  96. onShow(){
  97. uni.removeStorageSync('form_type_cart');
  98. },
  99. methods: {
  100. goDetail: function(id) {
  101. uni.navigateTo({
  102. url: `/pages/activity/goods_bargain_details/index?id=${id}&spid=${this.userInfo.uid}`
  103. })
  104. },
  105. getBargainUserList: function() {
  106. var that = this;
  107. if (that.loadingList) return;
  108. if (that.status) return;
  109. getBargainUserList({
  110. page: that.page,
  111. limit: that.limit
  112. })
  113. .then(res => {
  114. that.status = res.data.length < that.limit;
  115. that.bargain.push.apply(that.bargain, res.data);
  116. that.page++;
  117. that.loadingList = false;
  118. })
  119. .catch(res => {
  120. that.$util.Tips({
  121. title: res
  122. })
  123. });
  124. },
  125. getBargainUserCancel: function(bargainId) {
  126. var that = this;
  127. getBargainUserCancel({
  128. bargainId: bargainId
  129. })
  130. .then(res => {
  131. that.status = false;
  132. that.loadingList = false;
  133. that.page = 1;
  134. that.bargain = [];
  135. that.getBargainUserList();
  136. that.$util.Tips({
  137. title: res.msg
  138. })
  139. })
  140. .catch(res => {
  141. that.$util.Tips({
  142. title: res
  143. })
  144. });
  145. },
  146. /**
  147. * 获取个人用户信息
  148. */
  149. getUserInfo: function() {
  150. let that = this;
  151. getUserInfo().then(res => {
  152. that.userInfo = res.data;
  153. });
  154. },
  155. goPage(url){
  156. uni.navigateTo({
  157. url
  158. })
  159. }
  160. },
  161. onReachBottom() {
  162. this.getBargainUserList();
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. .order_card{
  168. margin-top:20rpx;
  169. }
  170. .border_ccc {
  171. border: 1rpx solid #ccc;
  172. }
  173. .bt{
  174. border-top: 1rpx solid #eee;
  175. }
  176. .btn ~ .btn{
  177. margin-left: 16rpx;
  178. }
  179. </style>