clientRepair.vue 6.9 KB

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