index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. /**
  121. * 取消砍价活动
  122. * @param {number} bargainId - 砍价活动ID
  123. */
  124. getBargainUserCancel: function(bargainId) {
  125. var that = this;
  126. getBargainUserCancel({
  127. bargainId: bargainId
  128. })
  129. .then(res => {
  130. that.status = false;
  131. that.loadingList = false;
  132. that.page = 1;
  133. that.bargain = [];
  134. that.getBargainUserList();
  135. that.$util.Tips({
  136. title: res.msg
  137. })
  138. })
  139. .catch(res => {
  140. that.$util.Tips({
  141. title: res
  142. })
  143. });
  144. },
  145. /**
  146. * 获取个人用户信息
  147. */
  148. getUserInfo: function() {
  149. let that = this;
  150. getUserInfo().then(res => {
  151. that.userInfo = res.data;
  152. });
  153. },
  154. },
  155. onReachBottom() {
  156. this.getBargainUserList();
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. /*砍价记录*/
  162. .bargain-record .item .picTxt .text .time .styleAll {
  163. color: #fc4141;
  164. font-size: 24rpx;
  165. }
  166. .bargain-record .item .picTxt .text .time .red {
  167. color: #999;
  168. font-size: 24rpx;
  169. }
  170. .bargain-record .item {
  171. background-color: #fff;
  172. margin-bottom: 12upx;
  173. }
  174. .bargain-record .item .picTxt {
  175. height: 210upx;
  176. border-bottom: 1px solid #f0f0f0;
  177. padding: 0 30upx;
  178. }
  179. .bargain-record .item .picTxt .pictrue {
  180. width: 150upx;
  181. height: 150upx;
  182. }
  183. .bargain-record .item .picTxt .pictrue image {
  184. width: 100%;
  185. height: 100%;
  186. border-radius: 6upx;
  187. }
  188. .bargain-record .item .picTxt .text {
  189. width: 515upx;
  190. font-size: 30upx;
  191. color: #282828;
  192. height: 150upx;
  193. }
  194. .bargain-record .item .picTxt .text .time {
  195. font-size: 24upx;
  196. color: #868686;
  197. justify-content: left !important;
  198. }
  199. .bargain-record .item .picTxt .text .successTxt {
  200. font-size: 24rpx;
  201. }
  202. .bargain-record .item .picTxt .text .endTxt {
  203. font-size: 24rpx;
  204. color: #999;
  205. }
  206. .bargain-record .item .picTxt .text .money {
  207. font-size: 24upx;
  208. }
  209. .bargain-record .item .picTxt .text .money .num {
  210. font-size: 32upx;
  211. font-weight: bold;
  212. }
  213. .bargain-record .item .picTxt .text .money .symbol {
  214. font-weight: bold;
  215. }
  216. .bargain-record .item .bottom {
  217. height: 100upx;
  218. padding: 0 30upx;
  219. font-size: 27upx;
  220. }
  221. .bargain-record .item .bottom .purple {
  222. color: #f78513;
  223. }
  224. .bargain-record .item .bottom .end {
  225. color: #999;
  226. }
  227. .bargain-record .item .bottom .success {
  228. color: #e93323;
  229. }
  230. .bargain-record .item .bottom .bnt {
  231. font-size: 27upx;
  232. color: #fff;
  233. width: 176upx;
  234. height: 60upx;
  235. border-radius: 32upx;
  236. text-align: center;
  237. line-height: 60upx;
  238. }
  239. .bargain-record .item .bottom .bnt.cancel {
  240. color: #aaa;
  241. border: 1px solid #ddd;
  242. }
  243. .bargain-record .item .bottom .bnt~.bnt {
  244. margin-left: 18upx;
  245. }
  246. </style>