You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
5.4 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. <template>
  2. <view class="technician">
  3. <view class="technician-top">
  4. <view class="technician-search">
  5. <view class="search">
  6. <view @click="showSelectArea" class="left-area">
  7. <image src="@/static/home/address-icon.png"></image>
  8. <view class="area">{{ selectArea.name }}</view>
  9. <image src="../../static/home/arrow-icon.png"></image>
  10. <view class="parting-line">|</view>
  11. </view>
  12. <view class="center-area">
  13. <van-search
  14. v-model="queryParams.title"
  15. :clearable="true"
  16. background="transparent"
  17. @clear="getTechnicianList"
  18. @search="getTechnicianList"
  19. center
  20. placeholder="请输入技师" />
  21. </view>
  22. <view class="right-area">
  23. <view @click="getTechnicianList" class="search-button">搜索</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="technician-bottm">
  28. <view class="a"><van-icon name="chat-o" />24小时在线接单</view>
  29. <view class="a"><uni-icons type="staff" color="#fff" size="13" />随时随地</view>
  30. <view class="a"><uni-icons type="staff" color="#fff" size="13" />绿色安全</view>
  31. </view>
  32. </view>
  33. <van-list v-model:loading="loading" :finished="finished" @load="onLoad">
  34. <technician-list :technicianList="technicianList"></technician-list>
  35. </van-list>
  36. <selectArea :show="showAeraPro" @close="closeAreaPro" @select="selectArea"></selectArea>
  37. </view>
  38. </template>
  39. <script>
  40. import technicianList from "../../components/technicianList.vue"
  41. import selectArea from '../../components/selectArea.vue';
  42. import Position from '@/utils/position.js'
  43. export default {
  44. components: { technicianList , selectArea },
  45. data() {
  46. return {
  47. list: [],
  48. queryParams: {
  49. pageNo: 1,
  50. pageSize: 10,
  51. title: ''
  52. },
  53. technicianList: [],
  54. loading: false,
  55. finished: false,
  56. showAeraPro: false,
  57. area: ''
  58. }
  59. },
  60. onShow() {
  61. this.getTechnicianList()
  62. this.getLocation()
  63. },
  64. methods: {
  65. //list列表滑动到底部自动新增数据列表
  66. onLoad() {
  67. this.queryParams.pageSize += 10
  68. this.getTechnicianList()
  69. },
  70. //获取技师列表
  71. getTechnicianList() {
  72. this.$api('getTechnicianList', this.queryParams, res => {
  73. if (res.code == 200) {
  74. this.technicianList = res.result.records
  75. if (this.queryParams.pageSize > res.result.total) {
  76. this.finished = true
  77. }
  78. this.calculatedDistance() //计算用户与技师距离
  79. }
  80. this.loading = false
  81. })
  82. },
  83. //清空输入框数据
  84. clearKey() {
  85. this.getTechnicianList();
  86. },
  87. //关闭选择地区
  88. closeAreaPro() {
  89. this.showAeraPro = false;
  90. },
  91. //选择了地区信息
  92. selectArea(area) {
  93. this.area = area;
  94. this.showAeraPro = false;
  95. },
  96. //显示选择地区
  97. showSelectArea() {
  98. this.showAeraPro = true;
  99. },
  100. //获取用户详细地址(省市县)
  101. getLocation() {
  102. Position.getLocationDetail().then(res => {
  103. if(!this.selectArea.name && this.configList.open_address == 0){
  104. this.$store.commit('setArea', {
  105. name : res.addressDetail.district
  106. })
  107. }
  108. })
  109. },
  110. //计算距离
  111. calculatedDistance() {
  112. Position.getLocation(result => {
  113. this.technicianList.forEach(item => {
  114. item.km = Position.calculateDistance(result.latitude, result.longitude, item.latitude, item.longitude)
  115. })
  116. })
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. body {
  123. background-color: #f3f3f3;
  124. }
  125. .technician-top {
  126. background: linear-gradient(38deg, #4899A6, #60BDA2);
  127. }
  128. .technician-bottm {
  129. display: flex;
  130. justify-content: space-around;
  131. font-size: 28rpx;
  132. height: 110rpx;
  133. align-items: center;
  134. color: #fff;
  135. }
  136. .technician-search {
  137. padding-top: 60rpx;
  138. .search {
  139. height: 82rpx;
  140. width: 710rpx;
  141. background: #FFFFFF;
  142. margin: 0px auto;
  143. border-radius: 41rpx;
  144. box-sizing: border-box;
  145. padding: 0 15rpx;
  146. display: flex;
  147. align-items: center;
  148. justify-content: space-between;
  149. .left-area,
  150. .center-area {
  151. display: flex;
  152. align-items: center;
  153. }
  154. .left-area {
  155. max-width: 160rpx;
  156. image {
  157. flex-shrink: 0;
  158. width: 26rpx;
  159. height: 26rpx;
  160. }
  161. .area {
  162. font-size: 24rpx;
  163. display: -webkit-box;
  164. -webkit-line-clamp: 2;
  165. /* 限制显示两行 */
  166. -webkit-box-orient: vertical;
  167. overflow: hidden;
  168. text-overflow: ellipsis;
  169. color: #292929;
  170. }
  171. .parting-line {
  172. flex-shrink: 0;
  173. font-size: 26rpx;
  174. color: #ccc;
  175. margin: 0rpx 5rpx;
  176. // background: transparent;
  177. }
  178. }
  179. .center-area {
  180. display: flex;
  181. flex-wrap: nowrap;
  182. align-items: center;
  183. width: calc(100% - 290rpx);
  184. image {
  185. width: 26rpx;
  186. height: 26rpx;
  187. }
  188. .van-field {
  189. background-color: transparent;
  190. box-sizing: border-box;
  191. height: 82rpx;
  192. line-height: 82rpx;
  193. width: calc(100% - 30rpx);
  194. padding: 0rpx 10rpx 0rpx 0rpx;
  195. input {
  196. height: 82rpx;
  197. font-size: 60rpx;
  198. }
  199. }
  200. }
  201. .right-area {
  202. .search-button {
  203. background: #60BDA2;
  204. height: 60rpx;
  205. width: 130rpx;
  206. font-size: 26rpx;
  207. border-radius: 35rpx;
  208. color: white;
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. }
  213. }
  214. }
  215. }
  216. .technician-search-button {
  217. background-color: #60BDA2;
  218. color: #fff;
  219. font-size: 26rpx;
  220. padding: 2rpx 24rpx;
  221. border-radius: 40rpx;
  222. }
  223. </style>