repairHistory.vue 7.4 KB

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