record.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!-- 历史记录 -->
  2. <template>
  3. <s-layout
  4. title="历史记录"
  5. navbar="inner"
  6. :bgStyle="state.page"
  7. :navbarStyle="state.navigationBar"
  8. opacityBgUi=""
  9. showBackButton
  10. >
  11. <su-tabs
  12. :list="tabMaps"
  13. :scrollable="true"
  14. @change="onTabsChange"
  15. :current="state.currentTab"
  16. :itemStyle="{
  17. height:'56rpx',
  18. width: '140rpx',
  19. borderRadius: '20rpx',
  20. lineHeight: '56rpx'
  21. }"
  22. :inactiveStyle="{
  23. background: '#E6E6E6',
  24. color: '#222222',
  25. opacity: 0.5,
  26. }"
  27. :activeStyle="{
  28. background: '#35E89A',
  29. color: '#257652'
  30. }"
  31. />
  32. <view class="task_cont">
  33. <scroll-view class="task_scroll" :scroll-y="true" @scrolltolower="scrolltolower">
  34. <s-empty v-if="state.pagination.total === 0&&state.loadStatus!=='loading'" icon="/static/order-empty.png" text="暂无记录" />
  35. <view v-else class="task_list">
  36. <view class="task_item" v-for="item in state.pagination.list" @tap="onTaskDetail(item.id)" :key="item.id">
  37. <view class="left">
  38. <view class="title">
  39. <view v-if="item.status!==10" class="status" :class="{'status0':item.status===0,'status1':item.status===1||item.status===2}">{{item.status===2?'已执行':(item.status===1?'执行中':(item.status===0?'待执行':'已失效'))}}</view>
  40. <view class="name">{{item.name}} </view>
  41. </view>
  42. <view class="verbal">{{item.type.name}}</view>
  43. <view class="time">{{formatDate(item.planTime,'YYYY-MM-DD HH:mm')}}</view>
  44. </view>
  45. <view class="right">详情 ></view>
  46. </view>
  47. </view>
  48. <!-- 加载更多 -->
  49. <uni-load-more
  50. v-if="state.pagination.total > 0"
  51. :status="state.loadStatus"
  52. :content-text="{
  53. contentdown: '上拉加载更多',
  54. }"
  55. @tap="loadMore"
  56. />
  57. </scroll-view>
  58. </view>
  59. </s-layout>
  60. </template>
  61. <script setup>
  62. import _ from 'lodash-es'
  63. import $helper from '@/common/helper'
  64. import { formatDate } from '@/common/helper/utils'
  65. import { computed, reactive } from 'vue'
  66. import { onLoad, onPageScroll, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
  67. import taskApi from '@/common/api/member/task'
  68. import { resetPagination } from '@/common/helper/utils'
  69. import sheep from '@/common'
  70. const state = reactive({
  71. navigationBar: {},
  72. page: {
  73. backgroundColor: '#FAFAFA',
  74. backgroundImage: '/static/homeTopBg.png'
  75. },
  76. currentTab: 0, // 选中的 tabMaps 下标
  77. pagination: {
  78. list: [],
  79. total: 0,
  80. page: 1,
  81. pageCount: 10,
  82. },
  83. })
  84. const tabMaps = [
  85. {
  86. name: '全部',
  87. },
  88. {
  89. name: '已完成',
  90. value: 10,
  91. },
  92. ]
  93. onLoad(async (options) => {
  94. if (options.type) {
  95. state.currentTab = options.type
  96. }
  97. await getTaskList()
  98. })
  99. // 切换选项卡
  100. function onTabsChange(e) {
  101. if (state.currentTab === e.index) {
  102. return
  103. }
  104. // 重新加载
  105. resetPagination(state.pagination);
  106. state.currentTab = e.index;
  107. getTaskList()
  108. }
  109. // 订单详情
  110. function onTaskDetail(id) {
  111. sheep.$router.go('/pages/task/details', {
  112. id,
  113. })
  114. }
  115. // 获取订单列表
  116. async function getTaskList() {
  117. state.loadStatus = 'loading';
  118. let { code, data } = await taskApi.taskList({
  119. page: state.pagination.page,
  120. pageCount: state.pagination.pageCount,
  121. status: tabMaps[state.currentTab].value,
  122. })
  123. if (code !== 1) {
  124. return
  125. }
  126. state.pagination.list = _.concat(state.pagination.list, data.records);
  127. state.pagination.total = data.total;
  128. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  129. }
  130. // 加载更多
  131. function loadMore() {
  132. if (state.loadStatus === 'noMore') {
  133. return
  134. }
  135. state.pagination.page++
  136. getTaskList()
  137. }
  138. // 上拉加载更多
  139. onReachBottom(() => {
  140. loadMore()
  141. })
  142. function scrolltolower(){
  143. loadMore()
  144. }
  145. // 下拉刷新
  146. onPullDownRefresh(() => {
  147. resetPagination(state.pagination)
  148. getTaskList()
  149. setTimeout(function () {
  150. uni.stopPullDownRefresh()
  151. }, 800);
  152. })
  153. onPageScroll(() => {})
  154. </script>
  155. <style lang="scss" scoped>
  156. .task_cont{
  157. flex: 1;
  158. overflow: hidden;
  159. .task_scroll{
  160. height: 100%;
  161. }
  162. }
  163. .task_list{
  164. padding-top: 10rpx;
  165. .task_item{
  166. padding: 30rpx 30rpx 20rpx;
  167. width: 690rpx;
  168. height: 192rpx;
  169. background: #FFFFFF;
  170. border-radius: 30rpx;
  171. box-sizing: border-box;
  172. margin: 0 auto 30rpx;
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: center;
  176. .left{
  177. .title{
  178. display: flex;
  179. align-items: center;
  180. margin-bottom: 10rpx;
  181. .status{
  182. height: 40rpx;
  183. line-height: 40rpx;
  184. padding: 0 10rpx;
  185. border-radius: 10rpx;
  186. font-weight: 400;
  187. font-size: 20rpx;
  188. margin-right: 10rpx;
  189. white-space: nowrap;
  190. background: #E6E6E6;
  191. color: #999999;
  192. }
  193. .status0{
  194. background: #FFEFBA;
  195. color: #E28F48;
  196. }
  197. .status1{
  198. background: #A3FFD7;
  199. color: #26B978;
  200. }
  201. .status2{
  202. background: #E6E6E6;
  203. color: #999999;
  204. }
  205. .name{
  206. font-weight: bold;
  207. font-size: 32rpx;
  208. color: #222222;
  209. line-height: 48rpx;
  210. text-overflow: ellipsis;
  211. overflow: hidden;
  212. white-space: nowrap;
  213. width: 420rpx;
  214. }
  215. }
  216. .verbal{
  217. font-weight: 400;
  218. font-size: 28rpx;
  219. color: #666666;
  220. line-height: 40rpx;
  221. margin-bottom: 10rpx;
  222. text-overflow: ellipsis;
  223. overflow: hidden;
  224. white-space: nowrap;
  225. width: 526rpx;
  226. }
  227. .time{
  228. font-weight: 400;
  229. font-size: 24rpx;
  230. color: #CCCCCC;
  231. line-height: 34rpx;
  232. }
  233. }
  234. .right{
  235. font-weight: 400;
  236. font-size: 28rpx;
  237. color: #35E89A;
  238. line-height: 80rpx;
  239. white-space: nowrap;
  240. }
  241. }
  242. }
  243. </style>