t-shart.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="t-shart">
  3. <template v-if="list.length">
  4. <view class="title">T恤统计截止至5月16日下午6点,逾期不候</view>
  5. <view class="memberr-item" v-for="item in list" :key="item.mobile">
  6. <view class="userinfo">
  7. <text>{{ item.mobile }}</text>
  8. <text>{{ item.nickname }}</text>
  9. <text>总数量:{{ item.total }} / <text class="basecolor">{{ ' ' }}{{ item.type_l + item.type_xl + item.type_3xl }}</text></text>
  10. </view>
  11. <view class="size-item address">
  12. <text class="name">收货地址:</text>
  13. <text>{{ item.province }}{{ item.city }}{{ item.area }}{{ item.address }}</text>
  14. </view>
  15. <view class="size-item">
  16. <text>L:</text>
  17. <NumInput :max="item.total - (item.type_l + item.type_xl + item.type_3xl) + item.type_l" v-model="item.type_l" />
  18. </view>
  19. <view class="size-item">
  20. <text>XL:</text>
  21. <NumInput :max="item.total - (item.type_l + item.type_xl + item.type_3xl) + item.type_xl" v-model="item.type_xl" />
  22. </view>
  23. <view class="size-item">
  24. <text>3XL:</text>
  25. <NumInput :max="item.total - (item.type_l + item.type_xl + item.type_3xl) + item.type_3xl" v-model="item.type_3xl" />
  26. </view>
  27. </view>
  28. <view class="big-btn bg" :class="{ not: !couldSubmit }" @click="submit"><text v-if="couldSubmit" class="countDown">距离截止还剩:{{ countDown }}</text>{{ couldSubmit ? '提交' : '已截止' }}</view>
  29. </template>
  30. <template v-else>
  31. <view style="margin-top: 48vh;">暂无统计</view>
  32. </template>
  33. </view>
  34. </template>
  35. <script>
  36. import { _API_GetTShirtNum, _API_SubmitTShirtNum } from '@/apis/order.js'
  37. import NumInput from '@/components/public/num-input.vue'
  38. export default {
  39. components: {
  40. NumInput
  41. },
  42. data() {
  43. return {
  44. num: 20,
  45. L: 0,
  46. list: [],
  47. couldSubmit: false,
  48. s: 1589536800000,
  49. e: 1589623200000,
  50. n: 0
  51. };
  52. },
  53. computed: {
  54. countDown() {
  55. const add0 = num => num < 10 ? '0' + num : num
  56. const sec = Math.floor((this.e - this.n) / 1000)
  57. const day = Math.floor(sec / 86400)
  58. const hour = Math.floor((sec % 86400) / 3600)
  59. const minite = Math.floor((sec - 86400 * day - hour * 3600) / 60)
  60. const second = Math.floor(sec - 86400 * day - hour * 3600 - minite * 60)
  61. return `${add0(day)}天${add0(hour)}时${add0(minite)}分${add0(second)}秒`
  62. }
  63. },
  64. mounted() {
  65. uni.loading()
  66. _API_GetTShirtNum().then(({ data }) => {
  67. this.list = data
  68. })
  69. this.n = Date.now()
  70. if (this.n >= this.s && this.n <= this.e) {
  71. this.couldSubmit = true
  72. this.timer = setInterval(() => {
  73. if (this.n + 1000 >= this.e) {
  74. this.couldSubmit = false
  75. clearInterval(this.timer)
  76. }
  77. this.n = Date.now()
  78. }, 1000)
  79. }
  80. },
  81. methods: {
  82. submit() {
  83. // const find = this.list.find(item => item.total !== item.type_l + item.type_xl + item.type_3xl)
  84. // if (find) {
  85. // uni.toast(`${find.nickname}的数量没有选够`)
  86. // return
  87. // } else {
  88. if (!this.couldSubmit) {
  89. uni.toast('提交时间已截止')
  90. return
  91. }
  92. uni.loading()
  93. _API_SubmitTShirtNum({
  94. id: this.list.map(e => e.id),
  95. type_l: this.list.map(e => e.type_l),
  96. type_xl: this.list.map(e => e.type_xl),
  97. type_3xl: this.list.map(e => e.type_3xl),
  98. }).then(() => {
  99. uni.showModal({ showCancel: false, title: '提示', content: '提交成功' }).then(() => uni.navigateBack())
  100. })
  101. // }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .t-shart {
  108. height: 100vh;
  109. overflow: auto;
  110. -webkit-overflow-scrolling : touch;
  111. @include flex(column);
  112. padding-top: 66rpx;
  113. padding-bottom: 123rpx;
  114. box-sizing: border-box;
  115. background: $app-base-bg;
  116. justify-content: flex-start;
  117. .title {
  118. @include flex();
  119. background: #FFFFFF;
  120. color: #FF0000;
  121. font-size: 36rpx;
  122. font-weight: bold;
  123. border-bottom: 1rpx solid #C8C7CC;
  124. top: 0;
  125. width: 100%;
  126. height: 66rpx;
  127. position: fixed;
  128. }
  129. .memberr-item {
  130. width: 100%;
  131. margin-bottom: 10rpx;
  132. .userinfo {
  133. @include flex();
  134. padding: 30rpx;
  135. background: #FFFFFF;
  136. box-sizing: border-box;
  137. justify-content: space-between;
  138. font-size: 32rpx;
  139. font-weight: bold;
  140. }
  141. .size-item {
  142. &.address {
  143. font-size: 28rpx;
  144. .name {
  145. width: 280rpx;
  146. font-weight: bold;
  147. }
  148. }
  149. @include flex();
  150. background: #FFFFFF;
  151. margin-bottom: 1rpx;
  152. padding: 30rpx;
  153. box-sizing: border-box;
  154. justify-content: space-between;
  155. }
  156. }
  157. .big-btn {
  158. height: 123rpx;
  159. position: fixed;
  160. bottom: 0;
  161. width: 100vw;
  162. border-radius: 0;
  163. &.not {
  164. background: #C8C7CC;
  165. border-color: #C8C7CC;
  166. }
  167. .countDown {
  168. top: 0;
  169. left: 8rpx;
  170. position: absolute;
  171. font-size: 28rpx;
  172. }
  173. }
  174. }
  175. </style>