center.vue 11 KB

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