index.vue 6.1 KB

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