index.vue 6.5 KB

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