myDriving.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="index">
  3. <view class="top">
  4. <text class="t1" :class="{ active: active == 'jd' }" @tap="setActive('jd')">接单</text>
  5. <text class="t2" :class="{ active: active == 'dj' }" @tap="setActive('dj')">代驾须知</text>
  6. <text class="icon" @tap="navigateTo('createOrder')">&#xe60e;</text>
  7. </view>
  8. <view class="center" v-show="active == 'jd'">
  9. <view class="orders" v-if="order.total > 0" v-for="(v, i) in order.data" :key="i">
  10. <view class="left">
  11. <view class="input">
  12. <text class="icon gray">&#xe77c;</text>
  13. <text class="time">{{ v.createtime | date }}</text>
  14. </view>
  15. <view class="input">
  16. <text class="icon green">&#xe608;</text>
  17. <text class="address">{{ v.start }}</text>
  18. </view>
  19. <view class="input">
  20. <text class="icon orange">&#xe608;</text>
  21. <text class="address">{{ v.end }}</text>
  22. </view>
  23. </view>
  24. <view class="right">
  25. <text class="price">¥{{ v.estimated_price }}元</text>
  26. <button type="primary" @tap="taking(v.id)">立即接单</button>
  27. </view>
  28. </view>
  29. <view class="empty" v-if="order.total == 0">暂无订单</view>
  30. </view>
  31. <view class="center1" v-show="active == 'dj'"><rich-text :nodes="setting.notice"></rich-text></view>
  32. <view class="bottom">
  33. <view class="item active" @tap="navigateTo('/pages/myDriving/myDriving')">
  34. <text class="icon">&#xe606;</text>
  35. 首页
  36. </view>
  37. <view class="item " @tap="navigateTo('/pages/myDriving/order')">
  38. <text class="icon">&#xe616;</text>
  39. 订单
  40. </view>
  41. <view class="item " @tap="navigateTo('/pages/myDriving/withdraw')">
  42. <text class="icon">&#xe61c;</text>
  43. 提现
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import helper from '../../common/helper.js';
  50. import api from '../../common/api.js';
  51. let timer = null;
  52. export default {
  53. data() {
  54. return {
  55. active: 'jd',
  56. setting: {},
  57. map: {
  58. page: 1
  59. },
  60. order: {}
  61. };
  62. },
  63. onLoad() {
  64. this.getInfo();
  65. },
  66. onShow() {
  67. this.getList();
  68. timer = setInterval(() => {
  69. this.getList();
  70. }, 3000);
  71. },
  72. onHide() {
  73. clearInterval(timer);
  74. },
  75. filters: {
  76. date: value => {
  77. let date = new Date(value * 1000);
  78. let h = date.getHours();
  79. let m = date.getMinutes();
  80. return (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m);
  81. }
  82. },
  83. methods: {
  84. async taking(orderId) {
  85. uni.showModal({
  86. title: '操作提示',
  87. content: '确定要接单吗?',
  88. success: async e => {
  89. if (e.confirm) {
  90. let res = await api.orderTaking(orderId);
  91. helper.toast(res.msg);
  92. if (res.code == 1) {
  93. uni.navigateTo({
  94. url: '/pages/myDriving/drivingDetails?order_id=' + orderId
  95. });
  96. }
  97. }
  98. }
  99. });
  100. },
  101. async getInfo() {
  102. let res = await api.getSetting();
  103. this.setting = res.data;
  104. },
  105. async getList() {
  106. let res = await api.getOrderTakingList(this.map);
  107. this.order = res.data;
  108. uni.stopPullDownRefresh();
  109. },
  110. onPullDownRefresh() {
  111. this.map.page = 1;
  112. this.getList();
  113. },
  114. onReachBottom() {
  115. if (this.info.last_page > this.info.current_page) {
  116. this.getList();
  117. }
  118. },
  119. setActive(active) {
  120. this.active = active;
  121. },
  122. navigateTo(url) {
  123. uni.navigateTo({
  124. url: url
  125. });
  126. }
  127. }
  128. };
  129. </script>
  130. <style lang="scss" scoped>
  131. .empty {
  132. height: 100upx;
  133. line-height: 100upx;
  134. font-size: 26upx;
  135. text-align: center;
  136. }
  137. page,
  138. .index {
  139. height: 100%;
  140. background-color: #fbfbfb;
  141. }
  142. .center {
  143. padding: 30upx;
  144. }
  145. .center1 {
  146. padding: 30upx;
  147. font-size: 26upx;
  148. line-height: 48upx;
  149. }
  150. .top {
  151. display: flex;
  152. padding: 20upx;
  153. font-size: 28upx;
  154. background-color: #ffffff;
  155. .active {
  156. color: #32c45e;
  157. }
  158. .t1 {
  159. width: 48%;
  160. text-align: center;
  161. }
  162. .t2 {
  163. width: 48%;
  164. text-align: center;
  165. }
  166. .icon {
  167. font-size: 30upx;
  168. }
  169. }
  170. .orders {
  171. margin-bottom: 30upx;
  172. display: flex;
  173. padding: 20upx 10upx;
  174. padding-right: 20upx;
  175. border-radius: 10upx;
  176. box-shadow: 1px 1px 1px 1px #eaeaea;
  177. align-items: center;
  178. flex-wrap: wrap;
  179. align-items: center;
  180. justify-content: center;
  181. background-color: #ffffff;
  182. .icon {
  183. text-align: center;
  184. font-size: 56upx;
  185. }
  186. .left {
  187. width: 80%;
  188. .input {
  189. width: 100%;
  190. padding: 6upx 0;
  191. display: flex;
  192. align-items: center;
  193. text {
  194. width: 20%;
  195. }
  196. .time {
  197. width: 70%;
  198. font-size: 25upx;
  199. color: #979797;
  200. }
  201. .address {
  202. width: 70%;
  203. font-size: 26upx;
  204. }
  205. }
  206. }
  207. .right {
  208. width: 20%;
  209. text-align: right;
  210. font-size: 34upx;
  211. color: #e51c23;
  212. button {
  213. float: right;
  214. width: 140upx;
  215. background-color: #32c45e;
  216. margin-top: 20upx;
  217. border-radius: 50upx;
  218. padding: 0 10upx;
  219. font-size: 22upx;
  220. }
  221. .price {
  222. float: right;
  223. position: relative;
  224. right: 20upx;
  225. font-size: 28rpx;
  226. width: 250upx;
  227. }
  228. }
  229. }
  230. .bottom {
  231. background-color: #ffffff;
  232. position: absolute;
  233. width: 100%;
  234. bottom: 0;
  235. height: 120upx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-around;
  239. .item {
  240. display: flex;
  241. flex-direction: column;
  242. align-items: center;
  243. font-size: 24upx;
  244. width: 33.33%;
  245. .icon {
  246. font-size: 56upx;
  247. color: #999999;
  248. }
  249. }
  250. }
  251. .active {
  252. color: #32c45e !important;
  253. .icon {
  254. color: #32c45e !important;
  255. }
  256. }
  257. </style>