混凝土运输管理微信小程序、替班
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

284 lines
6.1 KiB

2 weeks ago
  1. <template>
  2. <view class="content">
  3. <navbar title="抢单大厅" :leftClick="true" @leftClick="$utils.navigateBack" />
  4. <!-- 顶部搜索和状态切换 -->
  5. <view class="head flex-sb sticky box-shadow-light">
  6. <view class="flex" @click="showFilter">
  7. <view class="mr5">
  8. <uv-icon v-if="showFilterIcon" name="funnel" size="24" color="#666"></uv-icon>
  9. </view>
  10. <view v-if="showFilterText" style="font-size:28rpx">筛选</view>
  11. <input
  12. :class="['search-input', searchActive && 'active']"
  13. maxlength="10"
  14. type="text"
  15. confirm-type="search"
  16. @confirm="onSearch"
  17. v-model="searchValue"
  18. @input="onInput"
  19. placeholder="搜索订单"
  20. />
  21. </view>
  22. <!-- 在线状态切换 -->
  23. <view v-if="showOnlineStatus" class="flex" @click="switchToOffline">
  24. <view style="font-size:28rpx;color:#F40000;font-weight:bolder"> · 在线 </view>
  25. <uv-icon v-if="showOnlineIcon" name="arrow-down" size="16" color="#F40000"></uv-icon>
  26. </view>
  27. <view v-if="showOfflineStatus" class="flex" @click="switchToOnline">
  28. <view style="font-size:28rpx;color:#555555;font-weight:bolder"> · 离线 </view>
  29. <uv-icon v-if="showOfflineIcon" name="arrow-down" size="16" color="#555"></uv-icon>
  30. </view>
  31. </view>
  32. <!-- 订单列表 -->
  33. <view class="m20">
  34. <view v-if="isEmpty" class="re-empty">
  35. <view>暂无数据</view>
  36. </view>
  37. <view v-for="(item, index) in orderList" :key="index" class="b-relative item-card mb20">
  38. <view class="m10 flex-sb">
  39. <view class="ellipsis">{{ item.title }}</view>
  40. <view class="item-time">{{ item.time }}</view>
  41. </view>
  42. <view>到场时间{{ item.arrivalTime }}</view>
  43. <view>计划数量{{ item.quantity }}m³/</view>
  44. <view class="item-button" @click="grabOrder(item)">去接单</view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import navbar from '@/components/base/navbar.vue'
  51. export default {
  52. name: 'UserHall',
  53. components: {
  54. navbar
  55. },
  56. data() {
  57. return {
  58. showFilterIcon: true,
  59. showFilterText: true,
  60. searchActive: false,
  61. searchValue: '',
  62. showOnlineStatus: true,
  63. showOfflineStatus: false,
  64. showOnlineIcon: true,
  65. showOfflineIcon: true,
  66. isEmpty: false,
  67. orderList: [
  68. {
  69. id: 1,
  70. title: '长沙市雨花区建设项目',
  71. time: '2024-01-15 08:00',
  72. arrivalTime: '2024-01-15 09:00',
  73. quantity: '50'
  74. },
  75. {
  76. id: 2,
  77. title: '长沙市岳麓区商业中心',
  78. time: '2024-01-15 10:00',
  79. arrivalTime: '2024-01-15 11:00',
  80. quantity: '30'
  81. },
  82. {
  83. id: 3,
  84. title: '长沙市开福区住宅项目',
  85. time: '2024-01-15 14:00',
  86. arrivalTime: '2024-01-15 15:00',
  87. quantity: '40'
  88. }
  89. ]
  90. }
  91. },
  92. onLoad() {
  93. uni.setNavigationBarTitle({
  94. title: '抢单大厅'
  95. });
  96. },
  97. methods: {
  98. showFilter() {
  99. console.log('显示筛选');
  100. uni.showActionSheet({
  101. itemList: ['全部订单', '泵车订单', '搅拌车订单', '车载泵订单'],
  102. success: (res) => {
  103. const filters = ['全部订单', '泵车订单', '搅拌车订单', '车载泵订单'];
  104. uni.showToast({
  105. title: `已选择:${filters[res.tapIndex]}`,
  106. icon: 'none'
  107. });
  108. }
  109. });
  110. },
  111. onSearch() {
  112. console.log('搜索:', this.searchValue);
  113. uni.showToast({
  114. title: `搜索:${this.searchValue}`,
  115. icon: 'none'
  116. });
  117. },
  118. onInput() {
  119. this.searchActive = this.searchValue.length > 0;
  120. },
  121. switchToOffline() {
  122. this.showOnlineStatus = false;
  123. this.showOfflineStatus = true;
  124. uni.showToast({
  125. title: '已切换到离线状态',
  126. icon: 'none'
  127. });
  128. },
  129. switchToOnline() {
  130. this.showOnlineStatus = true;
  131. this.showOfflineStatus = false;
  132. uni.showToast({
  133. title: '已切换到在线状态',
  134. icon: 'success'
  135. });
  136. },
  137. grabOrder(item) {
  138. uni.showModal({
  139. title: '确认接单',
  140. content: `确定要接取订单:${item.title} 吗?`,
  141. success: (res) => {
  142. if (res.confirm) {
  143. uni.showToast({
  144. title: '接单成功',
  145. icon: 'success'
  146. });
  147. // 跳转到订单详情页
  148. setTimeout(() => {
  149. uni.navigateTo({
  150. url: `/pages_order/order/orderDetail?id=${item.id}`
  151. });
  152. }, 1000);
  153. }
  154. }
  155. });
  156. },
  157. // 供外部调用的方法
  158. loadPage() {
  159. console.log('用户抢单大厅页面刷新');
  160. // 重新加载订单数据
  161. this.loadOrderData();
  162. },
  163. loadOrderData() {
  164. // 模拟加载订单数据
  165. console.log('加载订单数据');
  166. }
  167. }
  168. }
  169. </script>
  170. <style scoped lang="scss">
  171. .content {
  172. padding: 20rpx;
  173. min-height: 100vh;
  174. background-color: #f5f5f5;
  175. }
  176. .head {
  177. background-color: #fff;
  178. padding: 20rpx;
  179. border-radius: 10rpx;
  180. margin-bottom: 20rpx;
  181. }
  182. .sticky {
  183. position: sticky;
  184. top: 0;
  185. z-index: 999;
  186. }
  187. .box-shadow-light {
  188. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  189. }
  190. .flex {
  191. display: flex;
  192. align-items: center;
  193. }
  194. .flex-sb {
  195. display: flex;
  196. justify-content: space-between;
  197. align-items: center;
  198. }
  199. .mr5 {
  200. margin-right: 5rpx;
  201. }
  202. .search-input {
  203. flex: 1;
  204. height: 60rpx;
  205. padding: 0 20rpx;
  206. border: 1rpx solid #e0e0e0;
  207. border-radius: 30rpx;
  208. margin-left: 20rpx;
  209. font-size: 28rpx;
  210. &.active {
  211. border-color: #007AFF;
  212. }
  213. }
  214. .m20 {
  215. margin: 20rpx 0;
  216. }
  217. .m10 {
  218. margin: 10rpx 0;
  219. }
  220. .mb20 {
  221. margin-bottom: 20rpx;
  222. }
  223. .b-relative {
  224. position: relative;
  225. }
  226. .item-card {
  227. background-color: #fff;
  228. border-radius: 10rpx;
  229. padding: 30rpx;
  230. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  231. font-size: 28rpx;
  232. line-height: 1.6;
  233. }
  234. .ellipsis {
  235. overflow: hidden;
  236. white-space: nowrap;
  237. text-overflow: ellipsis;
  238. flex: 1;
  239. font-weight: bold;
  240. color: #333;
  241. }
  242. .item-time {
  243. font-size: 24rpx;
  244. color: #999;
  245. }
  246. .item-button {
  247. position: absolute;
  248. right: 30rpx;
  249. bottom: 30rpx;
  250. background-color: #ff6b35;
  251. color: #fff;
  252. padding: 15rpx 25rpx;
  253. border-radius: 25rpx;
  254. font-size: 26rpx;
  255. font-weight: bold;
  256. }
  257. .re-empty {
  258. text-align: center;
  259. padding: 100rpx 0;
  260. color: #999;
  261. font-size: 28rpx;
  262. }
  263. </style>