index.vue 6.2 KB

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