taskClientRepair.vue 6.2 KB

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