order-list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <app-layout>
  3. <view class="no-content" v-if="!list.length">
  4. <view>你还没有进行中的砍价</view>
  5. <view>去会场逛逛!</view>
  6. </view>
  7. <view class="order-list">
  8. <block v-for="(v,k) in list" :key="k">
  9. <view @click="navGoods(v)" class="bargain-list dir-left-nowrap">
  10. <view class="box-grow-0">
  11. <image :src="v.cover_pic"></image>
  12. </view>
  13. <view class="box-grow-1 dir-top-nowrap bargain-right">
  14. <view class="box-grow-0 bargain-name t-omit-two">{{v.goods_name}}</view>
  15. <view class="attr t-omit">{{v.select_attr_group_text}}</view>
  16. <block v-if="v.reset_time">
  17. <view class="box-grow-1 bargain-time dir-left-nowrap cross-center">
  18. <block v-if="v.times.day > 0">
  19. <view class='info'>{{v.times.day}}</view>
  20. <view class="mark">天</view>
  21. </block>
  22. <view class="info">{{v.times.hour}}</view>
  23. <view class="mark">:</view>
  24. <view class="info">{{v.times.minute}}</view>
  25. <view class="mark">:</view>
  26. <view class="info">{{v.times.second}}</view>
  27. <view class="mark">后结束</view>
  28. </view>
  29. <view class="box-grow-0 dir-left-nowrap cross-center">
  30. <view class="box-grow-1 dir-top-nowrap">
  31. <view class='min-price'>
  32. <block v-if="v.now_price == v.min_price">已砍至最低</block>
  33. <block v-else>离最低¥{{v.min_price}}</block>
  34. </view>
  35. <view class='price'>
  36. <block v-if="v.now_price == v.min_price">¥{{v.min_price}}</block>
  37. <block v-else>还差¥{{v.reset_price}}</block>
  38. </view>
  39. </view>
  40. <view class="box-grow-0">
  41. <app-button v-if="v.now_price == v.min_price" @click.native.stop="submit(v)" height="64"
  42. width="176" color="#FFFFFF" background="#ff6700" font-size="28"
  43. round>立即购买
  44. </app-button>
  45. <app-button v-else @click.native.stop="goto(v)" height="64" width="176" color="#FFFFFF"
  46. :theme="getTheme" font-size="28" round>继续砍价
  47. </app-button>
  48. </view>
  49. </view>
  50. </block>
  51. <block v-else>
  52. <view class="box-grow-1"></view>
  53. <view class="box-grow-0">
  54. <view class="box-grow-1 bargain-content">{{v.content}}</view>
  55. <view class="box-grow-0 price">{{v.status_content}}</view>
  56. </view>
  57. </block>
  58. </view>
  59. </view>
  60. </block>
  61. </view>
  62. <common-buttom :theme="getTheme" status="prize"></common-buttom>
  63. </app-layout>
  64. </template>
  65. <script>
  66. import commonButtom from "../common-buttom.vue";
  67. import {mapGetters} from "vuex";
  68. export default {
  69. name: "order-list",
  70. components: {commonButtom},
  71. data() {
  72. let integral;
  73. return {
  74. integral,
  75. list: null,
  76. args: false,
  77. page: 1,
  78. load: false,
  79. }
  80. },
  81. computed: {
  82. ...mapGetters('mallConfig',{
  83. getTheme: 'getTheme',
  84. }),
  85. },
  86. onReachBottom: function () {
  87. const self = this;
  88. if (self.args || self.load)
  89. return;
  90. self.load = true;
  91. let page = self.page + 1;
  92. self.$request({
  93. url: self.$api.bargain.list,
  94. data: {
  95. page: page,
  96. }
  97. }).then(info => {
  98. if (info.code === 0) {
  99. [self.page, self.args] = [page, info.data.list.length === 0];
  100. self.getIntegral(self.list.concat(info.data.list));
  101. }
  102. self.load = false;
  103. });
  104. },
  105. onShow: function () {
  106. const self = this;
  107. self.$showLoading();
  108. self.$request({
  109. url: self.$api.bargain.list,
  110. }).then(info => {
  111. self.$hideLoading();
  112. if (info.code === 0) {
  113. self.getIntegral(info.data.list);
  114. }
  115. self.args = false;
  116. self.page = 1;
  117. }).catch(e => {
  118. self.$hideLoading();
  119. })
  120. },
  121. onUnload() {
  122. clearInterval(this.integral);
  123. },
  124. methods: {
  125. navGoods(v) {
  126. console.log(v.goods_id)
  127. uni.navigateTo({url: '/plugins/bargain/goods/goods?goods_id=' + v.goods_id});
  128. },
  129. goto(v) {
  130. uni.navigateTo({url: "/plugins/bargain/activity/activity?id=" + v.bargain_order_id});
  131. },
  132. getIntegral: function (list) {
  133. const self = this;
  134. clearInterval(self.integral);
  135. let func = function () {
  136. list.forEach((value, key, array) => {
  137. if (value.status) return;
  138. let time = value.finish_at.replace(/-/g, '/');
  139. let diff_time = parseInt((new Date(time).getTime() - new Date().getTime()) / 1000)
  140. let day = 0, hour = 0, minute = 0, second = 0;
  141. if (diff_time > 0) {
  142. day = Math.floor(diff_time / (60 * 60 * 24));
  143. hour = Math.floor(diff_time / (60 * 60)) - (day * 24);
  144. minute = Math.floor(diff_time / 60) - (day * 24 * 60) - (hour * 60);
  145. second = Math.floor(diff_time) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
  146. value.times = {day, hour, minute, second};
  147. } else {
  148. value.times = second;
  149. }
  150. });
  151. self.list = list;
  152. }
  153. func(list);
  154. self.integral = setInterval(() => {
  155. func(list);
  156. }, 1000);
  157. },
  158. submit: function (bargain) {
  159. const mchList = [{
  160. "mch_id": 0,
  161. "bargain_order_id": bargain.bargain_order_id,
  162. "goods_list": [{
  163. "id": bargain.goods_id,
  164. "attr": [],
  165. "num": 1,
  166. "cart_id": 0,
  167. "goods_attr_id": bargain.goods_attr_id
  168. }]
  169. }];
  170. uni.navigateTo({
  171. url: '/pages/order-submit/order-submit?mch_list=' +
  172. JSON.stringify(mchList) +
  173. '&preview_url=' + encodeURIComponent(this.$api.bargain.order_preview) +
  174. '&submit_url=' + encodeURIComponent(this.$api.bargain.order_submit)
  175. });
  176. },
  177. }
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. .no-content {
  182. padding: #{150rpx} 0;
  183. text-align: center;
  184. color: #888;
  185. }
  186. .order-list {
  187. }
  188. .bargain-list {
  189. padding: #{24rpx};
  190. margin-bottom: #{8rpx};
  191. background: #ffffff;
  192. image {
  193. height: #{216rpx};
  194. width: #{215rpx};
  195. display: block;
  196. }
  197. .bargain-right {
  198. margin-left: #{20rpx};
  199. min-height: #{216rpx};
  200. }
  201. .bargain-time {
  202. margin: #{8rpx} 0;
  203. font-size: #{26rpx};
  204. .info {
  205. width: #{45rpx};
  206. height: #{38rpx};
  207. background: #666666;
  208. color: #FFFFFF;
  209. text-align: center;
  210. border-radius: #{4rpx};
  211. line-height: #{38rpx};
  212. }
  213. .mark {
  214. color: #666666;
  215. margin: 0 #{10rpx};
  216. }
  217. }
  218. .self {
  219. }
  220. .min-price {
  221. color: #999999;
  222. font-size: #{24rpx};
  223. }
  224. .price {
  225. margin-top: #{8rpx};
  226. color: #ff4544;
  227. font-size: #{28rpx};
  228. }
  229. .bargain-content {
  230. margin-bottom: #{64rpx};
  231. color: #666666;
  232. font-size: #{24rpx};
  233. }
  234. .bargain-name {
  235. font-size: #{28rpx};
  236. color: #353535;
  237. }
  238. .attr {
  239. color: #999999;
  240. margin: #{12rpx 0 16rpx 0};
  241. font-size: $uni-font-size-weak-one;
  242. }
  243. }
  244. </style>