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.

269 lines
5.6 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
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. let queryParams = {
  73. ...this.queryParams,
  74. }
  75. if(this.$store.state.selectArea.id){
  76. queryParams.county = this.$store.state.selectArea.id
  77. }
  78. this.$api('getTechnicianList', queryParams, res => {
  79. if (res.code == 200) {
  80. this.technicianList = res.result.records
  81. if (this.queryParams.pageSize > res.result.total) {
  82. this.finished = true
  83. }
  84. this.calculatedDistance() //计算用户与技师距离
  85. }
  86. this.loading = false
  87. })
  88. },
  89. //清空输入框数据
  90. clearKey() {
  91. this.getTechnicianList();
  92. },
  93. //关闭选择地区
  94. closeAreaPro() {
  95. this.showAeraPro = false;
  96. },
  97. //选择了地区信息
  98. selectArea(area) {
  99. this.area = area;
  100. this.showAeraPro = false;
  101. },
  102. //显示选择地区
  103. showSelectArea() {
  104. this.showAeraPro = true;
  105. },
  106. //获取用户详细地址(省市县)
  107. getLocation() {
  108. Position.getLocationDetail().then(res => {
  109. if(!this.selectArea.name && this.configList.open_address == 0){
  110. this.$store.commit('setArea', {
  111. name : res.addressDetail.district
  112. })
  113. }
  114. })
  115. },
  116. //计算距离
  117. calculatedDistance() {
  118. Position.getLocation(result => {
  119. this.technicianList.forEach(item => {
  120. item.km = Position.calculateDistance(result.latitude, result.longitude, item.latitude, item.longitude)
  121. })
  122. })
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. body {
  129. background-color: #f3f3f3;
  130. }
  131. .technician-top {
  132. background: linear-gradient(38deg, #4899A6, #60BDA2);
  133. }
  134. .technician-bottm {
  135. display: flex;
  136. justify-content: space-around;
  137. font-size: 28rpx;
  138. height: 110rpx;
  139. align-items: center;
  140. color: #fff;
  141. }
  142. .technician-search {
  143. padding-top: 60rpx;
  144. .search {
  145. height: 82rpx;
  146. width: 710rpx;
  147. background: #FFFFFF;
  148. margin: 0px auto;
  149. border-radius: 41rpx;
  150. box-sizing: border-box;
  151. padding: 0 15rpx;
  152. display: flex;
  153. align-items: center;
  154. justify-content: space-between;
  155. .left-area,
  156. .center-area {
  157. display: flex;
  158. align-items: center;
  159. }
  160. .left-area {
  161. max-width: 160rpx;
  162. image {
  163. flex-shrink: 0;
  164. width: 26rpx;
  165. height: 26rpx;
  166. }
  167. .area {
  168. font-size: 24rpx;
  169. display: -webkit-box;
  170. -webkit-line-clamp: 2;
  171. /* 限制显示两行 */
  172. -webkit-box-orient: vertical;
  173. overflow: hidden;
  174. text-overflow: ellipsis;
  175. color: #292929;
  176. }
  177. .parting-line {
  178. flex-shrink: 0;
  179. font-size: 26rpx;
  180. color: #ccc;
  181. margin: 0rpx 5rpx;
  182. // background: transparent;
  183. }
  184. }
  185. .center-area {
  186. display: flex;
  187. flex-wrap: nowrap;
  188. align-items: center;
  189. width: calc(100% - 290rpx);
  190. image {
  191. width: 26rpx;
  192. height: 26rpx;
  193. }
  194. .van-field {
  195. background-color: transparent;
  196. box-sizing: border-box;
  197. height: 82rpx;
  198. line-height: 82rpx;
  199. width: calc(100% - 30rpx);
  200. padding: 0rpx 10rpx 0rpx 0rpx;
  201. input {
  202. height: 82rpx;
  203. font-size: 60rpx;
  204. }
  205. }
  206. }
  207. .right-area {
  208. .search-button {
  209. background: #60BDA2;
  210. height: 60rpx;
  211. width: 130rpx;
  212. font-size: 26rpx;
  213. border-radius: 35rpx;
  214. color: white;
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. }
  219. }
  220. }
  221. }
  222. .technician-search-button {
  223. background-color: #60BDA2;
  224. color: #fff;
  225. font-size: 26rpx;
  226. padding: 2rpx 24rpx;
  227. border-radius: 40rpx;
  228. }
  229. </style>