center.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="content">
  3. <view class="order-title">
  4. <view class="body-title">
  5. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  6. <view class="header">接单中心</view>
  7. </view>
  8. <view class="roder-content">
  9. <view class="left" :class="{ current: currentIndex === index }" :key="index" v-for="(item, index) in maiList" @click="navGo(index)">{{ item.title }}</view>
  10. </view>
  11. </view>
  12. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  13. <!-- 订单列表 -->
  14. <view class="order-item" v-for="(item, index) in maiList[currentIndex].orderList">
  15. <view class="order-top flex">
  16. <view class="order-top-left">
  17. <image class="order-top-left-image" src="../../static/img/order5.png" mode=""></image>
  18. <view class="order-top-left-font">订单信息</view>
  19. </view>
  20. <view class="order-top-right">待接单</view>
  21. </view>
  22. <view class="order-info flex">
  23. <view class="order-info-left">预约时间:</view>
  24. <view class="order-info-right">{{ item.time }}</view>
  25. </view>
  26. <view class="order-info flex">
  27. <view class="order-info-left">姓名:</view>
  28. <view class="order-info-right">{{ item.name }}</view>
  29. </view>
  30. <view class="order-info flex">
  31. <view class="order-info-left">性别:</view>
  32. <view class="order-info-right">{{ item.sex == 1 ? '男' : '女' }}</view>
  33. </view>
  34. <view class="order-info flex" v-if="currentIndex == 0">
  35. <view class="order-info-left">代办医院:</view>
  36. <view class="order-info-right">{{ item.hospital }}</view>
  37. </view>
  38. <view class="order-info flex" v-if="currentIndex == 0">
  39. <view class="order-info-left">代办类型:</view>
  40. <view class="order-info-right">{{ item.catename }}</view>
  41. </view>
  42. <view class="order-info flex" v-if="currentIndex == 1">
  43. <view class="order-info-left">医院:</view>
  44. <view class="order-info-right">{{ item.hospital }}</view>
  45. </view>
  46. <view class="order-info flex" v-if="currentIndex == 1">
  47. <view class="order-info-left">陪诊类型:</view>
  48. <view class="order-info-right">{{ item.catename }}</view>
  49. </view>
  50. <view class="order-info flex" v-if="currentIndex == 1">
  51. <view class="order-info-left">陪诊服务:</view>
  52. <view class="order-info-right">{{ item.servicename }}</view>
  53. </view>
  54. <view class="order-info flex" v-if="currentIndex == 1 && item.issm == 2">
  55. <view class="order-info-left">接送地址:</view>
  56. <view class="order-info-right">{{ item.transfer_address }}</view>
  57. </view>
  58. <view class="order-info flex">
  59. <view class="order-info-left">备注:</view>
  60. <view class="order-info-right">{{ item.remarks || '无' }}</view>
  61. </view>
  62. <view class="order-info flex">
  63. <view class="order-info-left">佣金:</view>
  64. <view class="order-info-price">{{ item.commission }}</view>
  65. </view>
  66. <view class="order-btn">
  67. <image class="order-btn-icon" src="../../static/img/order5.png" mode=""></image>
  68. <view class="order-btn-font" @click="takeOrder(item)">立即接单</view>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. </view>
  73. </template>
  74. <script>
  75. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  76. import empty from '@/components/empty';
  77. import { order_receiving_hall, order_receiving } from '@/api/jdr.js';
  78. import { getTime } from '@/utils/rocessor.js';
  79. export default {
  80. components: {
  81. uniLoadMore,
  82. empty
  83. },
  84. data() {
  85. return {
  86. currentIndex: 0, //当前选中的第一级0为我要买单,1我要卖单
  87. maiList: [
  88. {
  89. state: 2,
  90. title: '代办订单',
  91. loadingType: 'more',
  92. orderList: [],
  93. page: 1, //当前页数
  94. limit: 10 //每次信息条数
  95. },
  96. {
  97. state: 1,
  98. title: '陪诊订单',
  99. loadingType: 'more',
  100. orderList: [],
  101. page: 1, //当前页数
  102. limit: 10 //每次信息条数
  103. }
  104. ]
  105. };
  106. },
  107. onLoad(options) {
  108. this.loadData();
  109. },
  110. methods: {
  111. navGo(index) {
  112. this.currentIndex = index;
  113. this.loadData('shua');
  114. },
  115. toBack() {
  116. uni.switchTab({
  117. url: '/pages/user/user'
  118. });
  119. },
  120. loadData(source) {
  121. //这里是将订单挂载到tab列表下
  122. let index = this.currentIndex;
  123. let navItem = this.maiList[index];
  124. let state = navItem.state;
  125. if (source === 'shua') {
  126. navItem.loaded = false;
  127. navItem.page = 1;
  128. navItem.limit = 10;
  129. navItem.loadingType = 'more';
  130. navItem.orderList = [];
  131. }
  132. if (source === 'tabChange' && navItem.loaded === true) {
  133. //tab切换只有第一次需要加载数据
  134. return;
  135. }
  136. if (navItem.loadingType === 'loading') {
  137. //防止重复加载
  138. return;
  139. }
  140. if (navItem.loadingType === 'noMore') {
  141. //防止重复加载
  142. return;
  143. }
  144. // 修改当前对象状态为加载中
  145. navItem.loadingType = 'loading';
  146. order_receiving_hall({
  147. type: state,
  148. page: navItem.page,
  149. limit: navItem.limit
  150. })
  151. .then(({ data }) => {
  152. data.forEach(e => {
  153. if (e.remarks == undefined || e.remarks == 'undefined') {
  154. e.remarks = '无';
  155. }
  156. let key = Object.keys(e.cate);
  157. let name = '';
  158. key.forEach(e => {
  159. if (name == '') {
  160. name = name + e;
  161. } else {
  162. name = name + '/' + e;
  163. }
  164. });
  165. e.catename = name;
  166. let key1 = Object.keys(e.service);
  167. let name1 = '';
  168. e.issm = 1;
  169. key1.forEach(es => {
  170. console.log(e);
  171. if (es == '上门接送') {
  172. e.issm = 2;
  173. }
  174. if (name1 == '') {
  175. name1 = name1 + es;
  176. } else {
  177. name1 = name1 + '/' + es;
  178. }
  179. });
  180. e.servicename = name1;
  181. e.time = getTime(e.time);
  182. });
  183. navItem.orderList = navItem.orderList.concat(data);
  184. // console.log(navItem.orderList);
  185. navItem.page++;
  186. if (navItem.limit == data.length) {
  187. //判断是否还有数据, 有改为 more, 没有改为noMore
  188. navItem.loadingType = 'more';
  189. return;
  190. } else {
  191. //判断是否还有数据, 有改为 more, 没有改为noMore
  192. navItem.loadingType = 'noMore';
  193. }
  194. uni.hideLoading();
  195. this.$set(navItem, 'loaded', true);
  196. })
  197. .catch(e => {
  198. console.log(e);
  199. });
  200. },
  201. takeOrder(opt) {
  202. const obj = this;
  203. uni.showModal({
  204. title: '提示',
  205. content: '是否接取该订单,订单佣金:' + opt.commission + '前往医院:' + opt.hospital,
  206. success: function(res) {
  207. if (res.confirm) {
  208. order_receiving({}, opt.id).then(e => {
  209. uni.showToast({
  210. title: '接单成功',
  211. duration: 2000
  212. });
  213. obj.loadData('shua');
  214. });
  215. } else if (res.cancel) {
  216. console.log('用户点击取消');
  217. }
  218. }
  219. });
  220. }
  221. }
  222. };
  223. </script>
  224. <style lang="scss">
  225. page,
  226. .content {
  227. background: $page-color-base;
  228. height: 100%;
  229. }
  230. .order-title {
  231. width: 750rpx;
  232. height: 270rpx;
  233. background: url(../../static/img/jrzxbg.png) repeat-x 0;
  234. display: flex;
  235. flex-direction: column;
  236. text-align: center;
  237. .body-title {
  238. height: 80rpx;
  239. text-align: center;
  240. font-size: 35rpx;
  241. position: relative;
  242. .header {
  243. position: absolute;
  244. left: 0;
  245. top: 30rpx;
  246. width: 100%;
  247. font-size: 36rpx;
  248. font-family: PingFang SC;
  249. font-weight: bold;
  250. color: #fffeff;
  251. height: 80rpx;
  252. font-size: 36rpx;
  253. font-weight: 700;
  254. z-index: 9;
  255. display: flex;
  256. justify-content: center;
  257. align-items: center;
  258. }
  259. .goback-box {
  260. position: absolute;
  261. left: 18rpx;
  262. top: 30rpx;
  263. height: 80rpx;
  264. display: flex;
  265. align-items: center;
  266. }
  267. .goback {
  268. z-index: 100;
  269. width: 34rpx;
  270. height: 34rpx;
  271. }
  272. }
  273. text {
  274. margin: 30px 0;
  275. font-size: 17px;
  276. font-family: PingFang SC;
  277. font-weight: bold;
  278. color: #ffffff;
  279. }
  280. .roder-content {
  281. margin-top: 80rpx;
  282. display: flex;
  283. justify-content: space-around;
  284. .left {
  285. width: 168px;
  286. height: 40px;
  287. line-height: 40px;
  288. border: 1px solid #ffffff;
  289. border-radius: 5px;
  290. text-align: center;
  291. font-size: 15px;
  292. font-family: PingFang SC;
  293. font-weight: bold;
  294. color: #ffffff;
  295. background: #24a17d;
  296. }
  297. .current {
  298. color: #24a17d;
  299. background: #ffffff;
  300. }
  301. }
  302. }
  303. .list-scroll-content {
  304. height: calc(100% - 150px);
  305. }
  306. .order-item {
  307. width: 702rpx;
  308. background: #ffffff;
  309. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  310. border-radius: 20rpx;
  311. margin: 20rpx auto 0;
  312. padding: 24rpx;
  313. .order-top-left {
  314. display: flex;
  315. align-items: center;
  316. .order-top-left-image {
  317. width: 32rpx;
  318. height: 37rpx;
  319. }
  320. .order-top-left-font {
  321. margin-left: 10rpx;
  322. font-size: 30rpx;
  323. font-family: PingFang SC;
  324. font-weight: bold;
  325. color: #333333;
  326. }
  327. }
  328. .order-top-right {
  329. font-size: 26rpx;
  330. font-family: PingFang SC;
  331. font-weight: 500;
  332. color: #ff6f0f;
  333. }
  334. .order-info {
  335. margin-top: 24rpx;
  336. align-items: flex-start;
  337. .order-info-left {
  338. width: 200rpx;
  339. font-size: 28rpx;
  340. font-family: PingFang SC;
  341. font-weight: 500;
  342. color: #666666;
  343. }
  344. .order-info-right {
  345. font-size: 28rpx;
  346. font-family: PingFang SC;
  347. font-weight: bold;
  348. color: #333333;
  349. }
  350. .order-info-price {
  351. font-size: 38rpx;
  352. font-family: PingFang SC;
  353. font-weight: bold;
  354. color: #ff6f0f;
  355. }
  356. }
  357. .order-btn {
  358. margin: 34rpx auto;
  359. align-items: center;
  360. display: flex;
  361. justify-content: center;
  362. width: 566rpx;
  363. height: 74rpx;
  364. background: #24a17d;
  365. border-radius: 15rpx;
  366. .order-btn-icon {
  367. width: 35rpx;
  368. height: 36rpx;
  369. }
  370. .order-btn-font {
  371. margin-left: 7rpx;
  372. font-size: 30rpx;
  373. font-family: PingFang SC;
  374. font-weight: bold;
  375. color: #ffffff;
  376. }
  377. }
  378. }
  379. </style>