order-list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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: [],
  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. uni.navigateTo({url: '/plugins/bargain/goods/goods?goods_id=' + v.goods_id});
  127. },
  128. goto(v) {
  129. uni.navigateTo({url: "/plugins/bargain/activity/activity?id=" + v.bargain_order_id});
  130. },
  131. getIntegral: function (list) {
  132. const self = this;
  133. clearInterval(self.integral);
  134. let func = function () {
  135. list.forEach((value, key, array) => {
  136. if (value.status) return;
  137. let time = value.finish_at.replace(/-/g, '/');
  138. let diff_time = parseInt((new Date(time).getTime() - new Date().getTime()) / 1000)
  139. let day = 0, hour = 0, minute = 0, second = 0;
  140. if (diff_time > 0) {
  141. day = Math.floor(diff_time / (60 * 60 * 24));
  142. hour = Math.floor(diff_time / (60 * 60)) - (day * 24);
  143. minute = Math.floor(diff_time / 60) - (day * 24 * 60) - (hour * 60);
  144. second = Math.floor(diff_time) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
  145. value.times = {day, hour, minute, second};
  146. } else {
  147. value.times = second;
  148. }
  149. });
  150. self.list = list;
  151. }
  152. func(list);
  153. self.integral = setInterval(() => {
  154. func(list);
  155. }, 1000);
  156. },
  157. submit: function (bargain) {
  158. const mchList = [{
  159. "mch_id": 0,
  160. "bargain_order_id": bargain.bargain_order_id,
  161. "goods_list": [{
  162. "id": bargain.goods_id,
  163. "attr": [],
  164. "num": 1,
  165. "cart_id": 0,
  166. "goods_attr_id": bargain.goods_attr_id
  167. }]
  168. }];
  169. uni.navigateTo({
  170. url: '/pages/order-submit/order-submit?mch_list=' +
  171. JSON.stringify(mchList) +
  172. '&preview_url=' + encodeURIComponent(this.$api.bargain.order_preview) +
  173. '&submit_url=' + encodeURIComponent(this.$api.bargain.order_submit)
  174. });
  175. },
  176. }
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .no-content {
  181. padding: #{150rpx} 0;
  182. text-align: center;
  183. color: #888;
  184. }
  185. .order-list {
  186. }
  187. .bargain-list {
  188. padding: #{24rpx};
  189. margin-bottom: #{8rpx};
  190. background: #ffffff;
  191. image {
  192. height: #{216rpx};
  193. width: #{215rpx};
  194. display: block;
  195. }
  196. .bargain-right {
  197. margin-left: #{20rpx};
  198. min-height: #{216rpx};
  199. }
  200. .bargain-time {
  201. margin: #{8rpx} 0;
  202. font-size: #{26rpx};
  203. .info {
  204. width: #{45rpx};
  205. height: #{38rpx};
  206. background: #666666;
  207. color: #FFFFFF;
  208. text-align: center;
  209. border-radius: #{4rpx};
  210. line-height: #{38rpx};
  211. }
  212. .mark {
  213. color: #666666;
  214. margin: 0 #{10rpx};
  215. }
  216. }
  217. .self {
  218. }
  219. .min-price {
  220. color: #999999;
  221. font-size: #{24rpx};
  222. }
  223. .price {
  224. margin-top: #{8rpx};
  225. color: #ff4544;
  226. font-size: #{28rpx};
  227. }
  228. .bargain-content {
  229. margin-bottom: #{64rpx};
  230. color: #666666;
  231. font-size: #{24rpx};
  232. }
  233. .bargain-name {
  234. font-size: #{28rpx};
  235. color: #353535;
  236. }
  237. .attr {
  238. color: #999999;
  239. margin: #{12rpx 0 16rpx 0};
  240. font-size: $uni-font-size-weak-one;
  241. }
  242. }
  243. </style>