混凝土运输管理微信小程序、替班
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.

304 lines
6.4 KiB

2 weeks ago
  1. <template>
  2. <view class="content">
  3. <navbar title="我的订单" :leftClick="true" @leftClick="$utils.navigateBack" />
  4. <view class="head flex-sb">
  5. <view class="items">
  6. <view class="item-tab flex">
  7. <view @click="clickTabOne">施工前</view>
  8. <view @click="clickTabTwo">施工中</view>
  9. <view @click="clickTabThr">施工后</view>
  10. </view>
  11. <view class="item-active" :style="'--step:' + step + 'rpx'"></view>
  12. </view>
  13. </view>
  14. <view class="m20">
  15. <view v-if="item.length < 1" class="re-empty">
  16. <view>暂无数据</view>
  17. </view>
  18. <view v-for="(orderItem, index) in item" :key="index" class="b-relative item-card mb20">
  19. <view class="m10 flex-sb">
  20. <view class="item-tip">请于施工前30分钟内到达现场</view>
  21. <view style="color:#aaa" @click="clickDetail(orderItem.id)">
  22. <label v-if="orderItem.step === 0">待开工</label>
  23. <label v-if="orderItem.step === 1">施工中</label>
  24. <label v-if="orderItem.step === 2">已完成</label>
  25. <uv-icon name="arrow-right" color="#aaa" size="12"></uv-icon>
  26. </view>
  27. </view>
  28. <view class="mt20">
  29. <view>
  30. <view class="item-icon"></view>
  31. <label>到场时间{{ formatTime(orderItem.in_time) }}</label>
  32. </view>
  33. <view @click="openMap(orderItem)">
  34. <view class="item-icon"></view>
  35. <label>施工地点{{ orderItem.address }}</label>
  36. <uv-icon name="map" color="#333" size="12"></uv-icon>
  37. </view>
  38. <view>
  39. <view class="item-icon" style="border-color:#e5b746"></view>
  40. <label>施工已开始</label>
  41. </view>
  42. </view>
  43. <view class="mt20 flex-reverse">
  44. <button class="item-button" @click="clickStep(orderItem.id)">拍摄照片</button>
  45. <button v-if="orderItem.step === 0" class="item-button jr">我要拒单</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import navbar from '@/components/base/navbar.vue'
  53. export default {
  54. name: 'UserOrders',
  55. components: {
  56. navbar
  57. },
  58. data() {
  59. return {
  60. step: 8,
  61. item: [],
  62. status: 0
  63. };
  64. },
  65. onLoad() {
  66. uni.setNavigationBarTitle({
  67. title: '我的订单'
  68. });
  69. },
  70. onShow() {
  71. this.clickTabOne();
  72. },
  73. methods: {
  74. clickDetail(id) {
  75. uni.navigateTo({ url: `/pages_order/user/orderd?id=${id}` });
  76. },
  77. clickTabOne() {
  78. this.step = 8;
  79. this.status = 0;
  80. this.loadList();
  81. },
  82. clickTabTwo() {
  83. this.step = 221;
  84. this.status = 1;
  85. this.loadList();
  86. },
  87. clickTabThr() {
  88. this.step = 432;
  89. this.status = 2;
  90. this.loadList();
  91. },
  92. loadList() {
  93. // 模拟数据,实际项目中应该调用API
  94. this.item = this.getMockData();
  95. },
  96. getMockData() {
  97. const mockOrders = [
  98. {
  99. id: '1',
  100. step: this.status,
  101. in_time: '2024-01-15 09:30:00',
  102. address: '北京市朝阳区建国门外大街1号',
  103. latitude: 39.9042,
  104. longitude: 116.4074
  105. },
  106. {
  107. id: '2',
  108. step: this.status,
  109. in_time: '2024-01-15 14:00:00',
  110. address: '北京市海淀区中关村大街27号',
  111. latitude: 39.9889,
  112. longitude: 116.3058
  113. }
  114. ];
  115. return this.status === 0 ? mockOrders : this.status === 1 ? mockOrders.slice(0, 1) : [];
  116. },
  117. clickStep(id) {
  118. let stepUri = '/pages_order/user/step';
  119. if (this.status === 0) {
  120. stepUri = stepUri + '0';
  121. } else if (this.status === 1) {
  122. stepUri = stepUri + '1';
  123. } else if (this.status === 2) {
  124. stepUri = stepUri + '2';
  125. }
  126. uni.navigateTo({
  127. url: `${stepUri}?id=${id}`
  128. });
  129. },
  130. openMap(row) {
  131. uni.openLocation({
  132. latitude: parseFloat(row.latitude),
  133. longitude: parseFloat(row.longitude),
  134. scale: 18,
  135. name: row.address || '未命名地址'
  136. });
  137. },
  138. formatTime(timeStr) {
  139. if (!timeStr) return '';
  140. const date = new Date(timeStr);
  141. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  142. const day = date.getDate().toString().padStart(2, '0');
  143. const hours = date.getHours().toString().padStart(2, '0');
  144. const minutes = date.getMinutes().toString().padStart(2, '0');
  145. return `${month}-${day} ${hours}:${minutes}`;
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. page {
  152. background-color: #f5f5f5;
  153. --step: 1;
  154. --color: #F40000;
  155. }
  156. .content {
  157. min-height: 100vh;
  158. background-color: #f5f5f5;
  159. }
  160. .flex {
  161. display: flex;
  162. }
  163. .flex-sb {
  164. display: flex;
  165. justify-content: space-between;
  166. align-items: center;
  167. }
  168. .flex-reverse {
  169. display: flex;
  170. justify-content: flex-end;
  171. align-items: center;
  172. }
  173. .b-relative {
  174. position: relative;
  175. }
  176. .m10 {
  177. margin: 10rpx;
  178. }
  179. .m20 {
  180. margin: 20rpx;
  181. }
  182. .mt20 {
  183. margin-top: 20rpx;
  184. }
  185. .mb20 {
  186. margin-bottom: 20rpx;
  187. }
  188. .head {
  189. height: 68rpx;
  190. padding: 10rpx 40rpx;
  191. background-color: #fff;
  192. }
  193. .items {
  194. width: 687rpx;
  195. height: 52rpx;
  196. padding: 8rpx 8rpx;
  197. border-radius: 34rpx;
  198. background-color: #f2f4f9;
  199. position: relative;
  200. }
  201. .item-tab {
  202. line-height: 52rpx;
  203. background-color: transparent;
  204. view {
  205. width: 33%;
  206. text-align: center;
  207. font-size: 26rpx;
  208. font-weight: normal;
  209. letter-spacing: -0.16px;
  210. color: #152748;
  211. background-color: transparent;
  212. z-index: 1;
  213. }
  214. }
  215. .item-active {
  216. width: 229rpx;
  217. height: 52rpx;
  218. border-radius: 26rpx;
  219. background-color: #ffffff;
  220. position: absolute;
  221. left: var(--step);
  222. top: 8rpx;
  223. transition: .3s ease-in;
  224. z-index: 0;
  225. }
  226. .re-empty {
  227. text-align: center;
  228. padding: 100rpx;
  229. color: #999;
  230. font-size: 28rpx;
  231. }
  232. .item-card {
  233. width: calc(100vw - 120rpx);
  234. height: calc(414rpx - 60rpx);
  235. background: #ffffff;
  236. padding: 30rpx;
  237. margin: 30rpx;
  238. border-radius: 24rpx;
  239. font-size: 24rpx;
  240. line-height: 52rpx;
  241. color: #333333;
  242. }
  243. .item-tip {
  244. padding: 0 10rpx;
  245. background-color: #F2F5F9;
  246. border-radius: 8rpx;
  247. font-size: 20rpx;
  248. font-weight: normal;
  249. letter-spacing: 0px;
  250. color: #152748;
  251. }
  252. .item-icon {
  253. width: 24rpx;
  254. height: 24rpx;
  255. box-sizing: border-box;
  256. border: 6rpx solid #68B04F;
  257. border-radius: 50%;
  258. display: inline-block;
  259. margin: 10rpx 15rpx -2rpx 0;
  260. }
  261. .item-button {
  262. width: 160rpx;
  263. height: 64rpx;
  264. line-height: 64rpx;
  265. border-radius: 32rpx;
  266. box-sizing: border-box;
  267. font-size: 28rpx;
  268. font-weight: normal;
  269. text-align: center;
  270. letter-spacing: 0px;
  271. color: #F40000;
  272. padding: 0 !important;
  273. margin: 0 !important;
  274. background-color: transparent !important;
  275. margin-left: 10rpx !important;
  276. border: 2rpx solid #F40000;
  277. }
  278. .jr {
  279. border-color: #aaa;
  280. color: #aaa;
  281. }
  282. </style>