index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="container-order">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <view class="top" :style="{'top': sticky + 'px'}">
  5. <view class="iconfont3 left" @click="changeDate(0)">&#xe604;</view>
  6. <view class="time" @click="openDate" v-if="date">
  7. <!-- {{date}} -->
  8. <uni-datetime-picker type="date" v-model="date" :border="false" :clear-icon="false" :end="nowDate"
  9. @change="selectDate" />
  10. </view>
  11. <view class="iconfont3 right" @click="changeDate(1)">&#xe604;</view>
  12. </view>
  13. <view style="height: 138rpx;"></view>
  14. <view class="order-info">
  15. <view class="item">
  16. <view class="num">{{orderInfo.order_num || 0}}</view>
  17. <view class="">订单数</view>
  18. </view>
  19. <view class="item">
  20. <view class="num">{{orderInfo.sale_money_total || 0}}</view>
  21. <view class="">营业额(¥)</view>
  22. </view>
  23. <view class="item">
  24. <view class="num">{{orderInfo.discount_money_total || 0}}</view>
  25. <view class="">打赏金额(¥)</view>
  26. </view>
  27. </view>
  28. <view class="list" v-if="list.length">
  29. <z-order-list :list="list" :isMine="false"></z-order-list>
  30. <u-loadmore :status="status" />
  31. </view>
  32. <noData v-if="list.length<=0"></noData>
  33. <view class="footer">
  34. <view class="btn" @click="orderUp">
  35. <view class="up-icon">
  36. <view class="iconfont3">&#xe8b5;</view>
  37. </view>
  38. <view class="">上报订单</view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import zOrderList from '@/pages/workbench/z-order-list.vue';
  45. import noData from "@/components/noData/nodata.vue"
  46. export default {
  47. components: {
  48. zOrderList,
  49. noData
  50. },
  51. data() {
  52. return {
  53. config: {
  54. back: true,
  55. title: '订单管理',
  56. color: '#1A1A1A',
  57. backgroundColor: [1, "#fff"],
  58. statusBarFontColor: '#1A1A1A',
  59. leftSlot: true
  60. },
  61. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  62. sticky: uni.getSystemInfoSync().statusBarHeight + 44,
  63. date: this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd'),
  64. nowDate: this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd'),
  65. timestamp: 24 * 60 * 60 * 1000,
  66. list: [],
  67. orderInfo: {},
  68. params: {
  69. page: 1,
  70. limit: 10
  71. },
  72. totalPage: 0,
  73. currPage: 1,
  74. refresh: false,
  75. status: 'loadmore',
  76. }
  77. },
  78. onShow() {
  79. this.getOrderInfo()
  80. this.getOrderlist(this.date)
  81. },
  82. onPullDownRefresh() {
  83. this.getOrderInfo()
  84. this.getOrderlist(this.date, true)
  85. setTimeout(() => {
  86. uni.stopPullDownRefresh();
  87. }, 1000);
  88. },
  89. onReachBottom() {
  90. if (this.currPage == this.totalPage) {
  91. return this.status = 'nomore';
  92. } else {
  93. this.params.page++
  94. this.getOrderlist(this.date, false)
  95. }
  96. },
  97. methods: {
  98. // 时间戳
  99. timestampHandle(date, i) {
  100. let timestamp = 24 * 60 * 60 * 1000
  101. let yesterday = new Date(date).getTime() - timestamp
  102. let tomorrow = new Date(date).getTime() + timestamp
  103. let isLook = tomorrow > new Date().getTime() ? true : false
  104. console.log(date, i, isLook)
  105. if (i == 0) {
  106. return {
  107. status: true,
  108. currentDate: this.$u.timeFormat(yesterday, 'yyyy-mm-dd')
  109. }
  110. }
  111. if (isLook) {
  112. return {
  113. status: false,
  114. date: date
  115. }
  116. }
  117. return {
  118. status: true,
  119. currentDate: this.$u.timeFormat(tomorrow, 'yyyy-mm-dd')
  120. }
  121. },
  122. changeDate(i) {
  123. this.$u.throttle(() => {
  124. let res = this.timestampHandle(this.date, i)
  125. if (res.status) {
  126. this.date = res.currentDate
  127. this.getOrderInfo()
  128. this.getOrderlist(this.date, true)
  129. }
  130. }, 500)
  131. },
  132. openDate() {
  133. this.show = true
  134. },
  135. selectDate(e) {
  136. if (e) {
  137. this.date = e
  138. this.getOrderInfo()
  139. this.getOrderlist(e, true)
  140. }
  141. },
  142. // 获取订单全部信息
  143. getOrderInfo() {
  144. this.$http.get('/offlineorder/count').then(res => {
  145. if (res.code == 200) {
  146. this.orderInfo = res.data
  147. }
  148. })
  149. },
  150. getOrderlist(date, refresh) {
  151. uni.showLoading({
  152. title: '加载中'
  153. })
  154. this.params.page = refresh ? 1 : this.params.page
  155. this.$http.get('/offlineorder/page', {
  156. date: date,
  157. ...this.params
  158. }).then(res => {
  159. if (res.code == 200) {
  160. if (this.params.page == 1) this.list = []
  161. this.list = [...this.list, ...res.page.list]
  162. this.totalPage = res.page.totalPage
  163. this.currPage = res.page.currPage
  164. setTimeout(() => {
  165. uni.hideLoading()
  166. }, 300)
  167. if (this.currPage == this.totalPage) return this.status = 'nomore';
  168. }
  169. }).catch(err => {
  170. uni.hideLoading()
  171. })
  172. },
  173. orderUp() {
  174. uni.navigateTo({
  175. url: `/pages/workbench/order/entering`
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .container-order {
  183. .top {
  184. position: fixed;
  185. width: 100%;
  186. height: 138rpx;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. font-size: 36rpx;
  191. font-family: PingFang SC, PingFang SC-Regular;
  192. font-weight: 400;
  193. text-align: center;
  194. color: #1a1a1a;
  195. z-index: 9;
  196. background-color: #fff;
  197. .time {
  198. margin: 0 60rpx;
  199. }
  200. .left,
  201. .right {
  202. color: #808080;
  203. }
  204. .right {
  205. transform: rotate(180deg);
  206. }
  207. }
  208. .order-info {
  209. display: flex;
  210. justify-content: space-around;
  211. align-items: center;
  212. width: 690rpx;
  213. height: 205rpx;
  214. margin: 0 auto 10rpx;
  215. background: #ffffff;
  216. border-radius: 20rpx;
  217. box-shadow: 0 0 20rpx rgba(0, 0, 0, .05);
  218. font-size: 26rpx;
  219. font-family: PingFang SC, PingFang SC-Regular;
  220. font-weight: 400;
  221. color: #1a1a1a;
  222. .item {
  223. max-width: 30%;
  224. text-align: center;
  225. .num {
  226. font-size: 36rpx;
  227. color: #ff6600;
  228. margin-bottom: 18rpx;
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. white-space: nowrap;
  232. }
  233. }
  234. }
  235. .list {
  236. padding: 0 30rpx 200rpx;
  237. }
  238. .footer {
  239. width: 100%;
  240. padding: 30rpx 60rpx;
  241. position: fixed;
  242. bottom: 0;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. background-color: #fff;
  247. z-index: 8;
  248. .btn {
  249. display: flex;
  250. flex-direction: column;
  251. align-items: center;
  252. color: #fff;
  253. text-align: center;
  254. font-size: 28rpx;
  255. font-family: PingFang SC, PingFang SC-Regular;
  256. font-weight: 700;
  257. text-align: center;
  258. color: #FA6138;
  259. .up-icon {
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. width: 67rpx;
  264. height: 67rpx;
  265. margin-bottom: 16rpx;
  266. background: #FA6138;
  267. border-radius: 50%;
  268. color: #fff;
  269. }
  270. }
  271. }
  272. /deep/ .uni-date {
  273. .uni-date__x-input {
  274. padding-left: 0;
  275. color: #1a1a1a;
  276. }
  277. }
  278. }
  279. </style>