index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="order-page">
  3. <view class="tabs-wrap">
  4. <view class="tabs">
  5. <view class="tab" :class="{ curr: active == 1 }" @click="handTimeTabhange">近两日</view>
  6. <view class="tab" :class="{ curr: active == 2 }" @click="handChangeDate">
  7. <view class="name" style="margin-right: 10rpx;">{{ params.searchDate || '选择日期' }}</view>
  8. <u-icon name="arrow-down" color="#fff" size="14" v-if="active == 2"></u-icon>
  9. <u-icon name="arrow-down" color="#0F40F5" size="14" v-if="active == 1"></u-icon>
  10. </view>
  11. </view>
  12. <view class="search" @click="goToSearchPage">
  13. <u-icon name="search" size="30" color="#6c6c6c"></u-icon>
  14. </view>
  15. </view>
  16. <view class="tabs-switch-wrap">
  17. <u-tabs
  18. class="tabs"
  19. :list="tabs"
  20. :itemStyle="itemStyle"
  21. :is-scroll="false"
  22. :current="params.active"
  23. @click="handTabhange"
  24. @change="handTabhange">
  25. </u-tabs>
  26. </view>
  27. <view class="scroll-list-wrap">
  28. <view class="item" v-for="order in orderList" :key="order.date">
  29. <view class="item-date">
  30. <view class="label">{{ order.date }}</view>
  31. <view class="collect" @click="handItemMoreCollect(order)">
  32. <view class="name">当日汇总</view>
  33. <u-icon name="arrow-right" size="14" color="#6c6c6c"></u-icon>
  34. </view>
  35. </view>
  36. <view class="scroll-list-content">
  37. <item v-for="item in order.list" :item="item" @loadOrder="loadOrder" :key="item.id" />
  38. </view>
  39. </view>
  40. </view>
  41. <uni-calendar
  42. ref="calendar"
  43. :insert="pickVisible"
  44. @confirm="orderDateConfirm"
  45. @change="orderDateConfirm"
  46. />
  47. </view>
  48. </template>
  49. <script>
  50. import item from '@/pages/components/order.vue'
  51. import {mapState} from 'vuex';
  52. export default {
  53. components: {
  54. item
  55. },
  56. data () {
  57. return {
  58. listUrl: '/storeOrderApi/getOrderListForStoreSearch',
  59. active: 1,
  60. pickVisible: false,
  61. params: {
  62. active: 0,
  63. searchDate: ''
  64. },
  65. itemStyle: {
  66. width: '25vw',
  67. height: '80rpx'
  68. },
  69. tabs: [
  70. {
  71. name: '全部'
  72. },
  73. {
  74. name: '进行中'
  75. },
  76. {
  77. name: '已完成'
  78. },
  79. {
  80. name: '退款'
  81. }
  82. ],
  83. orderList: []
  84. }
  85. },
  86. computed: {
  87. ...mapState(['storeInfo'])
  88. },
  89. methods: {
  90. handChangeDate () {
  91. this.$refs.calendar.open();
  92. },
  93. handTabhange (e) {
  94. this.params.active = e.index
  95. this.loadData();
  96. },
  97. loadOrder () {
  98. this.loadData()
  99. },
  100. handTimeTabhange () {
  101. this.active = 1;
  102. this.params.searchDate = "";
  103. this.loadData();
  104. },
  105. // 跳转至搜索页
  106. goToSearchPage () {
  107. uni.navigateTo({
  108. url: '/pages/search/index'
  109. })
  110. },
  111. // 当日汇总
  112. handItemMoreCollect (item) {
  113. uni.navigateTo({
  114. url: '/pages/search/collect?day=' + item.requireDateStr
  115. })
  116. },
  117. orderDateConfirm (e) {
  118. this.params.searchDate = e.fulldate
  119. this.pickVisible = false
  120. this.active = 2
  121. this.loadData()
  122. },
  123. loadData() {
  124. uni.showLoading({
  125. title: '加载中'
  126. });
  127. var dateStr = (new Date()).getTime();
  128. var sign = this.getSign(dateStr);
  129. let date1 = "";
  130. if (this.active == 1) {
  131. // 获取近两天
  132. const date = new Date();
  133. let month = ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : (date.getMonth() + 1));
  134. const startDate = date.getFullYear() + "-" + month + "-" + ((date.getDate() - 1) < 10 ? ("0" + (date.getDate() - 1)) : (date.getDate() - 1));
  135. const endDate = date.getFullYear() + "-" + month + "-" + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
  136. date1 = startDate + "/" + endDate;
  137. } else {
  138. date1 = this.params.searchDate;
  139. }
  140. let that = this;
  141. this.requst({
  142. url: this.listUrl,
  143. data: {
  144. timestamp: dateStr,
  145. sign: sign,
  146. storeId: this.storeInfo.storeId,
  147. status2: this.params.active,
  148. dateStr: date1
  149. },
  150. success: res => {
  151. if (res.data.rtnBean.rtnCode == 0) {
  152. uni.hideLoading();
  153. this.orderList = this.splitOrderList(res.data.list);
  154. } else {
  155. uni.hideLoading();
  156. if (res.data.rtnBean.rtnMsg != '') {
  157. this.$api.msg(res.data.rtnBean.rtnMsg);
  158. }
  159. }
  160. },
  161. fail: (e) => {
  162. console.log("接口调用失败:" + JSON.stringify(e));
  163. uni.hideLoading();
  164. },
  165. })
  166. },
  167. splitOrderList(list) {
  168. if (!list || list.length == 0) {
  169. return [];
  170. }
  171. let orderList = [];
  172. list.map(item => {
  173. const date = item.requireDateStr.slice(5,10);
  174. if (orderList.length == 0) {
  175. let arr = [];
  176. arr.push(item)
  177. const obj = {
  178. date: date,
  179. requireDate: item.requireDate,
  180. requireDateStr: item.requireDateStr,
  181. list: arr
  182. }
  183. orderList.push(obj)
  184. } else {
  185. let obj = orderList.find(w => w.date == date);
  186. if (obj) {
  187. obj.list.push(item)
  188. } else {
  189. let arr = [];
  190. arr.push(item)
  191. const obj = {
  192. date: date,
  193. requireDate: item.requireDate,
  194. requireDateStr: item.requireDateStr,
  195. list: arr
  196. }
  197. orderList.push(obj)
  198. }
  199. }
  200. })
  201. if (orderList.length > 0) {
  202. orderList.sort((a, b) => {
  203. return new Date(a.requireDate).getTime() - new Date(b.requireDate).getTime()
  204. })
  205. orderList.reverse()
  206. }
  207. return orderList;
  208. }
  209. },
  210. onLoad () {
  211. },
  212. onShow () {
  213. this.loadData();
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .order-page {
  219. background-color: #f5f5f5;
  220. }
  221. .tabs-wrap {
  222. position: relative;
  223. height: 100rpx;
  224. @include flexCenter;
  225. .tabs {
  226. width: 456rpx;
  227. height: 60rpx;
  228. @include flexCenter;
  229. border-radius: 30rpx;
  230. border: 2rpx solid $theme-color;
  231. color: $theme-color;
  232. overflow: hidden;
  233. .tab {
  234. flex: 1;
  235. height: 60rpx;
  236. @include flexCenter;
  237. font-size: $font-base;
  238. }
  239. .tab.curr {
  240. background-color: $theme-color;
  241. color: #fff;
  242. }
  243. }
  244. .search {
  245. position: absolute;
  246. right: 20rpx;
  247. top: 0;
  248. height: 100rpx;
  249. @include flexCenter;
  250. }
  251. }
  252. .tabs-switch-wrap {
  253. width: 100vw;
  254. height: 80rpx;
  255. @include flexCenter;
  256. background-color: #fff;
  257. }
  258. .scroll-list-wrap {
  259. .item-date {
  260. padding: 0 20rpx;
  261. box-sizing: border-box;
  262. }
  263. .item-date, .collect {
  264. @include between;
  265. height: 80rpx;
  266. font-size: $font-base;
  267. }
  268. }
  269. .scroll-list-content {
  270. width: calc(100vw - 40rpx);
  271. margin-left: 20rpx;
  272. padding-bottom: 2rpx;
  273. }
  274. </style>