index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view :style="colorStyle">
  3. <block v-if="bargain.length>0">
  4. <div class="bargain-record" ref="container">
  5. <div class="item" v-for="(item, index) in bargain" :key="index">
  6. <div class="picTxt acea-row row-between-wrapper">
  7. <div class="pictrue">
  8. <image :src="item.image" />
  9. </div>
  10. <div class="text acea-row row-column-around">
  11. <div class="line1" style="width: 100%;">{{ item.title }}</div>
  12. <count-down :justify-left="'justify-content:left'" :is-day="true" :tip-text="$t(`倒计时`) "
  13. :day-text=" $t(`天`) " :hour-text=" $t(`时`) " :minute-text=" $t(`分`) " :second-text=" $t(`秒`)"
  14. :datatime="item.datatime" v-if="item.status === 1"></count-down>
  15. <div class="successTxt font-num" v-else-if="item.status === 3">{{$t(`砍价成功`)}}</div>
  16. <div class="endTxt" v-else>{{$t(`活动已结束`)}}</div>
  17. <div class="money font-num">
  18. {{$t(`已砍至`)}}<span class="symbol">{{$t(`¥`)}}</span><span class="num">{{ item.residue_price }}</span>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="bottom acea-row row-between-wrapper">
  23. <div class="purple" v-if="item.status === 1">{{$t(`活动进行中`)}}</div>
  24. <div class="success" v-if="item.status === 3">{{$t(`砍价成功`)}}</div>
  25. <div class="end" v-if="item.status === 2">{{$t(`活动已结束`)}}</div>
  26. <div class="acea-row row-middle row-right">
  27. <div class="bnt cancel" v-if="item.status === 1"
  28. @click="getBargainUserCancel(item.bargain_id)">
  29. {{$t(`取消活动`)}}
  30. </div>
  31. <div class="bnt bg-color-red" v-if="item.status === 1" @click="goDetail(item.bargain_id)">
  32. {{$t(`继续砍价`)}}
  33. </div>
  34. </div>
  35. <div class="acea-row row-middle row-right success" v-if="item.status === 3">
  36. {{item.success_time}}
  37. </div>
  38. </div>
  39. </div>
  40. <Loading :loaded="status" :loading="loadingList"></Loading>
  41. </div>
  42. </block>
  43. <block v-if="bargain.length == 0">
  44. <emptyPage :title="$t(`暂无砍价记录`)"></emptyPage>
  45. </block>
  46. <!-- #ifndef MP -->
  47. <home></home>
  48. <!-- #endif -->
  49. </view>
  50. </template>
  51. <script>
  52. import CountDown from "@/components/countDown";
  53. import emptyPage from '@/components/emptyPage.vue'
  54. import {
  55. getBargainUserList,
  56. getBargainUserCancel
  57. } from "@/api/activity";
  58. import {
  59. getUserInfo
  60. } from '@/api/user.js';
  61. import Loading from "@/components/Loading";
  62. import home from '@/components/home';
  63. import colors from "@/mixins/color";
  64. export default {
  65. name: "BargainRecord",
  66. components: {
  67. CountDown,
  68. Loading,
  69. emptyPage,
  70. home
  71. },
  72. props: {},
  73. mixins: [colors],
  74. data: function() {
  75. return {
  76. bargain: [],
  77. status: false, //砍价列表是否获取完成 false 未完成 true 完成
  78. loadingList: false, //当前接口是否请求完成 false 完成 true 未完成
  79. page: 1, //页码
  80. limit: 20, //数量
  81. userInfo: {}
  82. };
  83. },
  84. onLoad: function() {
  85. this.getBargainUserList();
  86. this.getUserInfo();
  87. },
  88. methods: {
  89. goDetail: function(id) {
  90. uni.navigateTo({
  91. url: `/pages/activity/goods_bargain_details/index?id=${id}&bargain=${this.userInfo.uid}`
  92. })
  93. },
  94. // 砍价列表
  95. goList: function() {
  96. uni.navigateTo({
  97. url: '/pages/activity/goods_bargain/index'
  98. })
  99. },
  100. getBargainUserList: function() {
  101. var that = this;
  102. if (that.loadingList) return;
  103. if (that.status) return;
  104. getBargainUserList({
  105. page: that.page,
  106. limit: that.limit
  107. })
  108. .then(res => {
  109. that.status = res.data.length < that.limit;
  110. that.bargain.push.apply(that.bargain, res.data);
  111. that.page++;
  112. that.loadingList = false;
  113. })
  114. .catch(res => {
  115. that.$util.Tips({
  116. title: res
  117. })
  118. });
  119. },
  120. getBargainUserCancel: function(bargainId) {
  121. var that = this;
  122. getBargainUserCancel({
  123. bargainId: bargainId
  124. })
  125. .then(res => {
  126. that.status = false;
  127. that.loadingList = false;
  128. that.page = 1;
  129. that.bargain = [];
  130. that.getBargainUserList();
  131. that.$util.Tips({
  132. title: res.msg
  133. })
  134. })
  135. .catch(res => {
  136. that.$util.Tips({
  137. title: res
  138. })
  139. });
  140. },
  141. /**
  142. * 获取个人用户信息
  143. */
  144. getUserInfo: function() {
  145. let that = this;
  146. getUserInfo().then(res => {
  147. that.userInfo = res.data;
  148. });
  149. },
  150. },
  151. onReachBottom() {
  152. this.getBargainUserList();
  153. }
  154. };
  155. </script>
  156. <style lang="scss">
  157. /*砍价记录*/
  158. .bargain-record .item .picTxt .text .time .styleAll {
  159. color: #fc4141;
  160. font-size: 24rpx;
  161. }
  162. .bargain-record .item .picTxt .text .time .red {
  163. color: #999;
  164. font-size: 24rpx;
  165. }
  166. .bargain-record .item {
  167. background-color: #fff;
  168. margin-bottom: 12upx;
  169. }
  170. .bargain-record .item .picTxt {
  171. height: 210upx;
  172. border-bottom: 1px solid #f0f0f0;
  173. padding: 0 30upx;
  174. }
  175. .bargain-record .item .picTxt .pictrue {
  176. width: 150upx;
  177. height: 150upx;
  178. }
  179. .bargain-record .item .picTxt .pictrue image {
  180. width: 100%;
  181. height: 100%;
  182. border-radius: 6upx;
  183. }
  184. .bargain-record .item .picTxt .text {
  185. width: 515upx;
  186. font-size: 30upx;
  187. color: #282828;
  188. height: 150upx;
  189. }
  190. .bargain-record .item .picTxt .text .time {
  191. font-size: 24upx;
  192. color: #868686;
  193. justify-content: left !important;
  194. }
  195. .bargain-record .item .picTxt .text .successTxt {
  196. font-size: 24rpx;
  197. }
  198. .bargain-record .item .picTxt .text .endTxt {
  199. font-size: 24rpx;
  200. color: #999;
  201. }
  202. .bargain-record .item .picTxt .text .money {
  203. font-size: 24upx;
  204. }
  205. .bargain-record .item .picTxt .text .money .num {
  206. font-size: 32upx;
  207. font-weight: bold;
  208. }
  209. .bargain-record .item .picTxt .text .money .symbol {
  210. font-weight: bold;
  211. }
  212. .bargain-record .item .bottom {
  213. height: 100upx;
  214. padding: 0 30upx;
  215. font-size: 27upx;
  216. }
  217. .bargain-record .item .bottom .purple {
  218. color: #f78513;
  219. }
  220. .bargain-record .item .bottom .end {
  221. color: #999;
  222. }
  223. .bargain-record .item .bottom .success {
  224. color: #e93323;
  225. }
  226. .bargain-record .item .bottom .bnt {
  227. font-size: 27upx;
  228. color: #fff;
  229. width: 176upx;
  230. height: 60upx;
  231. border-radius: 32upx;
  232. text-align: center;
  233. line-height: 60upx;
  234. }
  235. .bargain-record .item .bottom .bnt.cancel {
  236. color: #aaa;
  237. border: 1px solid #ddd;
  238. }
  239. .bargain-record .item .bottom .bnt~.bnt {
  240. margin-left: 18upx;
  241. }
  242. </style>