index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout :isScroll="true" :refresherTriggered="refresherTriggered" @refresherrefresh="refresherrefresh">
  4. <template slot="header">
  5. <view class="search-container" v-if="isWorkerUser">
  6. <u-search
  7. shape="round"
  8. :showAction="false"
  9. placeholder="输入工单单号进行搜索"
  10. v-model="keyword"
  11. @search="searchData"
  12. >
  13. </u-search>
  14. </view>
  15. </template>
  16. <view class="all-container">
  17. <!-- <view class="order-container card">
  18. <view class="home-title">
  19. <view class="left">我的订单</view>
  20. <view class="right" @tap="navToPage('/packageMine/pages/order/list?tab=', 1)">
  21. <text class="text">全部订单</text>
  22. <text class="iconfont icon-jinru"></text>
  23. </view>
  24. </view>
  25. <view class="list">
  26. <view class="item" v-for="(item, index) in orderList" :key="index"
  27. @tap="navToPage(`/packageMine/pages/order/list?tab=${item.key}`, 1)">
  28. <view class="icon">
  29. <text class="iconfont" :class="item.icon"></text>
  30. <u-badge max="99" :value="item.num" :absolute="true" :offset="[-4, -4]"></u-badge>
  31. </view>
  32. <view class="title">{{ item.title }}</view>
  33. </view>
  34. </view>
  35. </view> -->
  36. <view class="order-container card">
  37. <view class="home-title">
  38. <view class="left">我的服务单</view>
  39. <view class="right" @tap="navToPage('/packageWorkorder/pages/userWorkorderList?tab=', 1)">
  40. <text class="text">全部服务单</text>
  41. <text class="iconfont icon-jinru"></text>
  42. </view>
  43. </view>
  44. <view class="list">
  45. <view
  46. class="item"
  47. v-for="(item, index) in workorderList"
  48. :key="index"
  49. @tap="navToPage(`/packageWorkorder/pages/userWorkorderList?tab=${item.key}`, 1)"
  50. >
  51. <view class="icon">
  52. <text class="iconfont" :class="item.icon"></text>
  53. <u-badge max="99" :value="item.num" :absolute="true" :offset="[-4, -4]"></u-badge>
  54. </view>
  55. <view class="title">{{ item.title }}</view>
  56. </view>
  57. </view>
  58. </view>
  59. <block v-if="isWorkerUser">
  60. <view class="data-container">
  61. <view class="common-title">我的工单</view>
  62. <view class="list">
  63. <view class="item" v-for="(item, index) in statsList" :key="index" @tap="clickItem(item)">
  64. <view class="num">{{ item.num }}</view>
  65. <view class="bottom">
  66. <text class="iconfont" :class="item.icon" :style="{ color: item.color }"></text>
  67. <text class="text">{{ item.name }}</text>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="schedule-container">
  73. <view class="common-title">我的日程</view>
  74. <view class="schedule-card">
  75. <view class="label">
  76. <view>星期</view>
  77. <view>日期</view>
  78. <view>待接单</view>
  79. <view>服务中</view>
  80. </view>
  81. <view class="days">
  82. <view class="item" v-for="(item, index) in scheduleList" :key="index">
  83. <view>{{ item.week }}</view>
  84. <view :class="index === 0 ? 'today' : ''">{{ index === 0 ? '今天' : item.day }}</view>
  85. <view>{{ item.djd || '' }}</view>
  86. <view>{{ item.fwz || '' }}</view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </block>
  92. </view>
  93. </zj-page-layout>
  94. <!-- #endif -->
  95. <!-- #ifndef H5 -->
  96. <web-view :src="webViewHref(`/pages/workorder/index`, pam, crossPagePam)" @message="crossPage.$listener"></web-view>
  97. <!-- #endif -->
  98. </template>
  99. <script>
  100. // #ifdef H5
  101. import { selectionChange } from '@/common/utils/util.js';
  102. export default {
  103. data() {
  104. return {
  105. userInfo: {},
  106. refresherTriggered: false,
  107. keyword: '',
  108. statsList: [
  109. { name: '待接单', num: 0, icon: 'icon-daiyuyue', color: '#D8F6D8', url: '/packageWorkorder/pages/orderList?tab=DJD' },
  110. { name: '服务中', num: 0, icon: 'icon-daishangmen', color: '#FFEBDF', url: '/packageWorkorder/pages/orderList?tab=FWZ' },
  111. { name: '异常单', num: 0, icon: 'icon-daiwangong', color: '#D7F1FF', url: '/packageWorkorder/pages/orderList?tab=YCD' },
  112. { name: '待抢单', num: 0, icon: 'icon-daijiesuan', color: '#FFEED1', url: '/packageWorkorder/pages/orderList?tab=DQD' },
  113. { name: '今日完工', num: 0, icon: 'icon-tuojigongdan', color: '#D7F1FF', url: '/packageWorkorder/pages/orderList?tab=YWG' },
  114. { name: '近半年完工', num: 0, icon: 'icon-bannianwangong', color: '#D8F6D8', url: '/packageWorkorder/pages/orderList?tab=YWG' },
  115. { name: '配件申请中', num: 0, icon: 'icon-bannianwangong', color: '#D8F6D8', url: '/packageMaterial/pages/partsApply/list?tab=ING' },
  116. { name: '配件已到货', num: 0, icon: 'icon-bannianwangong', color: '#D8F6D8', url: '/packageMaterial/pages/partsApply/list?tab=END' },
  117. ],
  118. scheduleList: [],
  119. orderList: [
  120. { title: '待付款', icon: 'icon-daifukuan', key: 'NOPAY', num: 0 },
  121. { title: '进行中', icon: 'icon-daifuwu', key: 'YFH', num: 0 },
  122. { title: '待评价', icon: 'icon-daipingjia1', key: 'OVER', num: 0 },
  123. { title: '售后/退款', icon: 'icon-shouhou', key: 'REFUND', num: 0 }
  124. ],
  125. workorderList: [
  126. { title: '待预约', icon: 'icon-daifukuan', key: 1, num: 0 },
  127. { title: '服务中', icon: 'icon-daifuwu', key: 2, num: 0 },
  128. { title: '待评价', icon: 'icon-daipingjia1', key: 3, num: 0 },
  129. { title: '已完成', icon: 'icon-shouhou', key: 4, num: 0 }
  130. ],
  131. }
  132. },
  133. computed:{
  134. isWorkerUser() { // 是否师傅
  135. return this.userInfo && this.userInfo.type === 'WORKER';
  136. },
  137. },
  138. onLoad() {
  139. this.crossPage.$on('refreshUserWorkorderList', data => {
  140. if(this.isWorkerUser) {
  141. this.getOrderStats();
  142. this.getPartsStats();
  143. this.getSchedule();
  144. }
  145. })
  146. },
  147. async onShow() {
  148. selectionChange();
  149. this.userInfo = await this.$getUserInfo();
  150. if(this.isWorkerUser) {
  151. this.getOrderStats();
  152. this.getPartsStats();
  153. this.getSchedule();
  154. }
  155. },
  156. onUnload() {
  157. this.crossPage.$off('refreshUserWorkorderList');
  158. },
  159. methods: {
  160. // 获取工单统计
  161. async getOrderStats() {
  162. return new Promise((resolve, reject) => {
  163. this.$api.post('/pg/order/base/status/count')
  164. .then(res => {
  165. this.statsList[0].num = res.data.djd;
  166. this.statsList[1].num = res.data.fwz;
  167. this.statsList[2].num = res.data.ycd;
  168. this.statsList[3].num = res.data.dqd;
  169. this.statsList[4].num = res.data.jrwg;
  170. this.statsList[5].num = res.data.jbnwg;
  171. }).finally(res => {
  172. resolve(1);
  173. })
  174. })
  175. },
  176. // 获取配件申请统计
  177. async getPartsStats() {
  178. return new Promise((resolve, reject) => {
  179. this.$api.post('/material/parts/apply/count')
  180. .then(res => {
  181. this.statsList[6].num = res.data.partsIngCount;
  182. this.statsList[7].num = res.data.partsEndCount;
  183. }).finally(res => {
  184. resolve(1);
  185. })
  186. })
  187. },
  188. // 获取日程
  189. async getSchedule() {
  190. return new Promise((resolve, reject) => {
  191. this.$api.post('/pg/order/base/my/schedule')
  192. .then(res => {
  193. let list = [];
  194. for (var i = 0; i < res.data.dayList.length; i++) {
  195. list.push({
  196. week: res.data.weekList[i],
  197. day: res.data.dayList[i],
  198. djd: res.data.djdList[i],
  199. fwz: res.data.fwzList[i]
  200. });
  201. }
  202. this.scheduleList = list;
  203. }).finally(res => {
  204. resolve(1);
  205. })
  206. })
  207. },
  208. // 下拉刷新
  209. async refresherrefresh() {
  210. this.refresherTriggered = true;
  211. if(this.isWorkerUser && this.type != 2) {
  212. await this.getOrderStats();
  213. await this.getPartsStats();
  214. await this.getSchedule();
  215. }
  216. this.refresherTriggered = false;
  217. },
  218. clickItem(item) {
  219. if(!item.url) return false;
  220. this.navToPage(item.url);
  221. },
  222. searchData() {
  223. this.navToPage(`/packageWorkorder/pages/search?keyword=${this.keyword}`)
  224. },
  225. navToPage(url) {
  226. this.$navToPage({
  227. url
  228. })
  229. },
  230. },
  231. }
  232. // #endif
  233. // #ifndef H5
  234. import { getNoticeNum, getOrderNum } from '@/common/utils/util.js';
  235. export default {
  236. data() {
  237. return {
  238. pam: {},
  239. }
  240. },
  241. onLoad(pam) {
  242. this.pam = pam;
  243. getNoticeNum()
  244. getOrderNum()
  245. }
  246. }
  247. // #endif
  248. </script>
  249. <style lang="scss" scoped>
  250. .search-container {
  251. background: #ffffff;
  252. padding: 20rpx;
  253. ::v-deep .u-search {
  254. height: 60rpx;
  255. input {
  256. background: #f7f8ff !important;
  257. }
  258. .u-search__content {
  259. background: #f7f8ff !important;
  260. height: 60rpx;
  261. }
  262. }
  263. }
  264. .all-container {
  265. padding: 1rpx 20rpx 20rpx;
  266. }
  267. .data-container {
  268. .list {
  269. display: flex;
  270. flex-wrap: wrap;
  271. justify-content: flex-start;
  272. .item {
  273. background: #ffffff;
  274. width: calc((100% - 40rpx) / 3);
  275. margin: 20rpx 20rpx 0 0;
  276. height: 220rpx;
  277. border-radius: 8rpx;
  278. display: flex;
  279. flex-direction: column;
  280. justify-content: space-between;
  281. box-sizing: border-box;
  282. padding: 20rpx 16rpx;
  283. &:nth-child(3n) {
  284. margin-right: 0;
  285. }
  286. .num {
  287. font-size: 52rpx;
  288. font-weight: 500;
  289. }
  290. .bottom {
  291. display: flex;
  292. align-items: center;
  293. .iconfont {
  294. font-size: 36rpx;
  295. }
  296. .text {
  297. color: $sec-font;
  298. margin-left: 6rpx;
  299. font-size: 28rpx;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. .card {
  306. @include zj-card;
  307. padding: 30rpx;
  308. box-shadow: none;
  309. margin-top: 20rpx;
  310. }
  311. .common-title {
  312. margin-top: 30rpx;
  313. font-size: 34rpx;
  314. font-weight: bold;
  315. }
  316. .home-title {
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. .left {
  321. font-size: 34rpx;
  322. color: $main-font;
  323. font-weight: bold;
  324. }
  325. .right {
  326. display: flex;
  327. align-items: center;
  328. .text {
  329. font-size: 28rpx;
  330. color: $sec-font;
  331. }
  332. .iconfont {
  333. font-size: 24rpx;
  334. color: $sec-font;
  335. margin-left: 8rpx;
  336. }
  337. }
  338. }
  339. .schedule-container {
  340. .schedule-card {
  341. border-radius: 12rpx;
  342. display: flex;
  343. overflow: hidden;
  344. background: #ffffff;
  345. margin-top: 20rpx;
  346. .label {
  347. background: $theme-color;
  348. width: 44rpx;
  349. view {
  350. height: 90rpx;
  351. font-size: 24rpx;
  352. color: #ffffff;
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. padding: 0 10rpx;
  357. box-sizing: border-box;
  358. }
  359. }
  360. .days {
  361. flex: 1;
  362. display: flex;
  363. overflow-x: scroll;
  364. .item {
  365. flex-shrink: 0;
  366. width: 90rpx;
  367. view {
  368. width: 100%;
  369. text-align: center;
  370. height: 90rpx;
  371. line-height: 90rpx;
  372. box-sizing: border-box;
  373. &.today {
  374. color: $theme-color;
  375. font-size: 28rpx !important;
  376. }
  377. &.active {
  378. color: #19be6b !important;
  379. }
  380. &:nth-child(1) {
  381. color: $sec-font;
  382. }
  383. &:nth-child(2) {
  384. font-size: 32rpx;
  385. font-weight: 500;
  386. }
  387. &:nth-child(3) {
  388. font-size: 32rpx;
  389. font-weight: 500;
  390. color: $assist-color;
  391. border-right: 1rpx solid #f4f5f7;
  392. border-top: 1rpx solid #f4f5f7;
  393. }
  394. &:nth-child(4) {
  395. font-size: 32rpx;
  396. font-weight: 500;
  397. color: $theme-color;
  398. border-right: 1rpx solid #f4f5f7;
  399. border-top: 1rpx solid #f4f5f7;
  400. }
  401. &:nth-child(5) {
  402. color: $sec-font;
  403. border-right: 1rpx solid #f4f5f7;
  404. border-top: 1rpx solid #f4f5f7;
  405. }
  406. }
  407. }
  408. }
  409. }
  410. }
  411. .order-container {
  412. .list {
  413. display: flex;
  414. margin-top: 30rpx;
  415. .item {
  416. flex: 1;
  417. display: flex;
  418. flex-direction: column;
  419. align-items: center;
  420. .icon {
  421. position: relative;
  422. .iconfont {
  423. font-size: 52rpx;
  424. }
  425. }
  426. .title {
  427. font-size: 26rpx;
  428. margin-top: 10rpx;
  429. }
  430. }
  431. }
  432. }
  433. </style>