userRepair.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. export default {
  108. data() {
  109. return {
  110. tabCurrentIndex: 0,
  111. navList: [{
  112. state: 0,
  113. text: '维修历史',
  114. loadingType: 'more',
  115. orderList: [],
  116. page: 1, //当前页数
  117. limit: 10 //每次信息条数
  118. }]
  119. };
  120. },
  121. onLoad() {
  122. this.loadData();
  123. },
  124. methods: {
  125. // 跳转详细页面
  126. navDetail(item) {
  127. uni.navigateTo({
  128. url: '/pages/shop/repair/clientReparirDetail?id=' + item.order_id + '&type=2'
  129. })
  130. },
  131. navPj(item){
  132. uni.navigateTo({
  133. url: '/pages/user/reportForRepair/Report?id=' + item.car_number
  134. })
  135. },
  136. // 打开地址
  137. openAddress(res) {
  138. console.log(res, '返回的位置数据');
  139. uni.chooseLocation({
  140. latitude: res.latitude,
  141. longitude: res.longitude,
  142. success(re) {
  143. console.log(re, '当前位置');
  144. },
  145. fail(e) {
  146. console.log(e, 'cw');
  147. }
  148. })
  149. },
  150. // 拨打电话
  151. openPhone(item) {
  152. uni.makePhoneCall({
  153. phoneNumber: item //仅为示例
  154. });
  155. },
  156. //顶部tab点击
  157. tabClick(index) {
  158. this.tabCurrentIndex = index;
  159. this.loadData('tabChange');
  160. },
  161. //swiper 切换
  162. changeTab(e) {
  163. this.tabCurrentIndex = e.target.current;
  164. this.loadData('tabChange');
  165. },
  166. // 加载数据
  167. loadData(source) {
  168. //这里是将订单挂载到tab列表下
  169. let index = this.tabCurrentIndex;
  170. let navItem = this.navList[index];
  171. let state = navItem.state;
  172. if (source === 'tabChange' && navItem.loaded === true) {
  173. //tab切换只有第一次需要加载数据
  174. return;
  175. }
  176. if (navItem.loadingType === 'loading') {
  177. //防止重复加载
  178. return;
  179. }
  180. if (navItem.loadingType === 'noMore') {
  181. //防止重复加载
  182. return;
  183. }
  184. // 修改当前对象状态为加载中
  185. navItem.loadingType = 'loading';
  186. console.log('开始请求');
  187. question({
  188. history: 1,
  189. page: navItem.page,
  190. limit: navItem.limit
  191. })
  192. .then(({
  193. data
  194. }) => {
  195. let arr = data.data.map(e => {
  196. e.status = +e.status;
  197. return e;
  198. });
  199. navItem.orderList = navItem.orderList.concat(arr);
  200. // console.log(navItem.orderList);
  201. navItem.page++;
  202. if (navItem.limit == data.length) {
  203. //判断是否还有数据, 有改为 more, 没有改为noMore
  204. navItem.loadingType = 'more';
  205. return;
  206. } else {
  207. //判断是否还有数据, 有改为 more, 没有改为noMore
  208. navItem.loadingType = 'noMore';
  209. }
  210. uni.hideLoading();
  211. this.$set(navItem, 'loaded', true);
  212. })
  213. .catch(e => {
  214. console.log(e);
  215. });
  216. },
  217. }
  218. };
  219. </script>
  220. <style lang="scss">
  221. page,
  222. .container {
  223. height: 100%;
  224. }
  225. .swiper-box {
  226. height: 100%;
  227. }
  228. .list-scroll-content {
  229. height: 100%;
  230. padding-top: 30rpx;
  231. }
  232. .navbar {
  233. display: flex;
  234. height: 40px;
  235. padding: 0 5px;
  236. background: #fff;
  237. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  238. .nav-item {
  239. flex: 1;
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. height: 100%;
  244. font-size: 15px;
  245. color: $font-color-dark;
  246. position: relative;
  247. &.current {
  248. color: $base-color;
  249. &:after {
  250. content: '';
  251. position: absolute;
  252. left: 50%;
  253. bottom: 0;
  254. transform: translateX(-50%);
  255. width: 44px;
  256. height: 0;
  257. border-bottom: 2px solid $base-color;
  258. }
  259. }
  260. }
  261. }
  262. .itemBox {
  263. margin: 0 $page-row-spacing;
  264. margin-bottom: $page-row-spacing;
  265. background-color: #FFFFFF;
  266. border-radius: 20rpx;
  267. padding: 40rpx 0;
  268. .boxButtom {
  269. justify-content: center;
  270. margin: 0 30rpx;
  271. color: $color-green;
  272. font-size: 24rpx;
  273. height: 70rpx;
  274. border-radius: 100rpx;
  275. line-height: 1;
  276. padding: 0 50rpx;
  277. flex-grow: 1;
  278. &.btn3 {
  279. border: 1px solid $uni-color-warning;
  280. color: $uni-color-warning;
  281. }
  282. &.btn1 {
  283. border: 1px solid $font-color-light;
  284. color: $font-color-light;
  285. }
  286. &.btn2 {
  287. color: #FFFFFF;
  288. background-color: $color-green;
  289. padding: 0 120rpx;
  290. }
  291. }
  292. .item {
  293. justify-content: flex-start;
  294. padding: 30rpx;
  295. padding-top: 0;
  296. font-size: $font-base;
  297. .title {
  298. flex-shrink: 0;
  299. color: $font-color-base;
  300. }
  301. .content {
  302. color: $font-color-light;
  303. .icon {
  304. width: 32rpx;
  305. }
  306. }
  307. }
  308. }
  309. </style>