userRepair.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="container ">
  3. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  4. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  5. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  6. <!-- 空白页 -->
  7. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  8. <!-- 订单列表 -->
  9. <view class="itemBox" v-for="(item,index) in tabItem.orderList">
  10. <view class="flex item">
  11. <view class="title">
  12. 订单状态:
  13. </view>
  14. <view class="content">
  15. <text v-if='item.status==3' class="font-color-greed">
  16. 已完成
  17. </text>
  18. <text v-if='item.status==-1' class="font-color-gray">
  19. 已取消
  20. </text>
  21. <text v-if='item.status==2' class="font-color-yellow">
  22. 待评价
  23. </text>
  24. </view>
  25. </view>
  26. <view class="flex item">
  27. <view class="title">
  28. 报修车辆:
  29. </view>
  30. <view class="content">
  31. {{item.car.car_name}}
  32. </view>
  33. </view>
  34. <view class="flex item">
  35. <view class="title">
  36. 维修单号:
  37. </view>
  38. <view class="content">
  39. {{item.order_id}}
  40. </view>
  41. </view>
  42. <view class="flex item" @click="openAddress(item)">
  43. <view class="title">
  44. 维修地点:
  45. </view>
  46. <view class="content flex">
  47. <image class="icon" src="../../../static/icon/shopAddress.png" mode="widthFix"></image>
  48. <text class="margin-l-10">{{item.address}}</text>
  49. </view>
  50. </view>
  51. <view class="flex item">
  52. <view class="title">
  53. 维修师傅:
  54. </view>
  55. <view class="content flex">
  56. <text class="margin-l-10">
  57. {{item.processor_user.staff_name}}
  58. </text>
  59. </view>
  60. </view>
  61. <view class="flex item" @click="openPhone(item.processor_user.phone)">
  62. <view class="title">
  63. 师傅电话:
  64. </view>
  65. <view class="content flex">
  66. <image class="icon" src="../../../static/icon/shopPhone.png" mode="widthFix"></image>
  67. <text class="margin-l-10">
  68. {{item.processor_user.phone}}
  69. </text>
  70. </view>
  71. </view>
  72. <view class="flex item">
  73. <view class="title">
  74. 申报时间:
  75. </view>
  76. <view class="content">
  77. {{item.add_time}}
  78. </view>
  79. </view>
  80. <view class="flex item">
  81. <view class="title">
  82. 结束时间:
  83. </view>
  84. <view class="content">
  85. {{item.processor_time}}
  86. </view>
  87. </view>
  88. <view class="flex padding-t-20" v-if="navList[tabCurrentIndex].state==0">
  89. <view @click="navDetail(item)" class="boxButtom flex btn1">
  90. 查看详情
  91. </view>
  92. <view v-if='item.status==2' @click="navPj(item)" class="boxButtom flex btn2">
  93. 去评价
  94. </view>
  95. </view>
  96. </view>
  97. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  98. </scroll-view>
  99. </swiper-item>
  100. </swiper>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. question
  106. } from '@/api/user.js';
  107. import empty from '@/components/empty';
  108. export default {
  109. components: {
  110. empty
  111. },
  112. data() {
  113. return {
  114. tabCurrentIndex: 0,
  115. navList: [{
  116. state: 0,
  117. text: '维修历史',
  118. loadingType: 'more',
  119. orderList: [],
  120. page: 1, //当前页数
  121. limit: 10 //每次信息条数
  122. }]
  123. };
  124. },
  125. onLoad() {
  126. this.loadData();
  127. },
  128. methods: {
  129. // 跳转详细页面
  130. navDetail(item) {
  131. uni.navigateTo({
  132. url: '/pages/shop/repair/clientReparirDetail?id=' + item.order_id + '&type=2'
  133. })
  134. },
  135. navPj(item){
  136. uni.navigateTo({
  137. url: '/pages/user/reportForRepair/Report?id=' + item.car_number
  138. })
  139. },
  140. // 打开地址
  141. openAddress(res) {
  142. console.log(res, '返回的位置数据');
  143. uni.chooseLocation({
  144. latitude: res.latitude,
  145. longitude: res.longitude,
  146. success(re) {
  147. console.log(re, '当前位置');
  148. },
  149. fail(e) {
  150. console.log(e, 'cw');
  151. }
  152. })
  153. },
  154. // 拨打电话
  155. openPhone(item) {
  156. uni.makePhoneCall({
  157. phoneNumber: item //仅为示例
  158. });
  159. },
  160. //顶部tab点击
  161. tabClick(index) {
  162. this.tabCurrentIndex = index;
  163. this.loadData('tabChange');
  164. },
  165. //swiper 切换
  166. changeTab(e) {
  167. this.tabCurrentIndex = e.target.current;
  168. this.loadData('tabChange');
  169. },
  170. // 加载数据
  171. loadData(source) {
  172. //这里是将订单挂载到tab列表下
  173. let index = this.tabCurrentIndex;
  174. let navItem = this.navList[index];
  175. let state = navItem.state;
  176. if (source === 'tabChange' && navItem.loaded === true) {
  177. //tab切换只有第一次需要加载数据
  178. return;
  179. }
  180. if (navItem.loadingType === 'loading') {
  181. //防止重复加载
  182. return;
  183. }
  184. if (navItem.loadingType === 'noMore') {
  185. //防止重复加载
  186. return;
  187. }
  188. // 修改当前对象状态为加载中
  189. navItem.loadingType = 'loading';
  190. console.log('开始请求');
  191. question({
  192. history: 1,
  193. page: navItem.page,
  194. limit: navItem.limit
  195. })
  196. .then(({
  197. data
  198. }) => {
  199. let arr = data.data.map(e => {
  200. e.status = +e.status;
  201. return e;
  202. });
  203. navItem.orderList = navItem.orderList.concat(arr);
  204. // console.log(navItem.orderList);
  205. navItem.page++;
  206. if (navItem.limit == data.length) {
  207. //判断是否还有数据, 有改为 more, 没有改为noMore
  208. navItem.loadingType = 'more';
  209. return;
  210. } else {
  211. //判断是否还有数据, 有改为 more, 没有改为noMore
  212. navItem.loadingType = 'noMore';
  213. }
  214. uni.hideLoading();
  215. this.$set(navItem, 'loaded', true);
  216. })
  217. .catch(e => {
  218. console.log(e);
  219. });
  220. },
  221. }
  222. };
  223. </script>
  224. <style lang="scss">
  225. page,
  226. .container {
  227. height: 100%;
  228. }
  229. .swiper-box {
  230. height: 100%;
  231. }
  232. .list-scroll-content {
  233. height: 100%;
  234. padding-top: 30rpx;
  235. }
  236. .navbar {
  237. display: flex;
  238. height: 40px;
  239. padding: 0 5px;
  240. background: #fff;
  241. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  242. .nav-item {
  243. flex: 1;
  244. display: flex;
  245. justify-content: center;
  246. align-items: center;
  247. height: 100%;
  248. font-size: 15px;
  249. color: $font-color-dark;
  250. position: relative;
  251. &.current {
  252. color: $base-color;
  253. &:after {
  254. content: '';
  255. position: absolute;
  256. left: 50%;
  257. bottom: 0;
  258. transform: translateX(-50%);
  259. width: 44px;
  260. height: 0;
  261. border-bottom: 2px solid $base-color;
  262. }
  263. }
  264. }
  265. }
  266. .itemBox {
  267. margin: 0 $page-row-spacing;
  268. margin-bottom: $page-row-spacing;
  269. background-color: #FFFFFF;
  270. border-radius: 20rpx;
  271. padding: 40rpx 0;
  272. .boxButtom {
  273. justify-content: center;
  274. margin: 0 30rpx;
  275. color: $color-green;
  276. font-size: 24rpx;
  277. height: 70rpx;
  278. border-radius: 100rpx;
  279. line-height: 1;
  280. padding: 0 50rpx;
  281. flex-grow: 1;
  282. &.btn3 {
  283. border: 1px solid $uni-color-warning;
  284. color: $uni-color-warning;
  285. }
  286. &.btn1 {
  287. border: 1px solid $font-color-light;
  288. color: $font-color-light;
  289. }
  290. &.btn2 {
  291. color: #FFFFFF;
  292. background-color: $color-green;
  293. padding: 0 120rpx;
  294. }
  295. }
  296. .item {
  297. justify-content: flex-start;
  298. padding: 30rpx;
  299. padding-top: 0;
  300. font-size: $font-base;
  301. .title {
  302. flex-shrink: 0;
  303. color: $font-color-base;
  304. }
  305. .content {
  306. color: $font-color-light;
  307. .icon {
  308. width: 32rpx;
  309. }
  310. }
  311. }
  312. }
  313. </style>