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.

281 lines
6.3 KiB

1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year 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">{{ area }}</view>
  9. <image src="../../static/home/arrow-icon.png"></image>
  10. <view class="parting-line">|</view>
  11. </view>
  12. <view class="center-area">
  13. <image src="@/static/home/search-icon.png"></image>
  14. <van-field v-model="queryParams.title" :clearable="true" @clear="clearKey" center placeholder="请输入技师" />
  15. </view>
  16. <view class="right-area">
  17. <view @click="getTechnicianList" class="search-button">搜索</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="technician-bottm">
  22. <view class="a"><van-icon name="chat-o" />24小时在线接单</view>
  23. <view class="a"><uni-icons type="staff" color="#fff" size="13" />随时随地</view>
  24. <view class="a"><uni-icons type="staff" color="#fff" size="13" />绿色安全</view>
  25. </view>
  26. </view>
  27. <!-- tab栏 -->
  28. <view class="tab">
  29. <van-tabs v-model:active="active" color="#EF8C94" background="transparent">
  30. <van-tab title="男士套餐"></van-tab>
  31. <van-tab title="女士套餐"></van-tab>
  32. <!-- 后面这两个个用于解决页面显示bug -->
  33. <van-tab title="免通行费"></van-tab>
  34. <van-tab disabled></van-tab>
  35. <van-tab disabled></van-tab>
  36. </van-tabs>
  37. </view>
  38. <van-list v-model:loading="loading" :finished="finished" @load="onLoad">
  39. <technician-list :technicianList="technicianList"></technician-list>
  40. </van-list>
  41. <selectArea :show="showAeraPro" @close="closeAreaPro" @select="selectArea"></selectArea>
  42. </view>
  43. </template>
  44. <script>
  45. import technicianList from "../../components/technicianList.vue"
  46. import selectArea from '../../components/selectArea.vue';
  47. import Position from '@/utils/position.js'
  48. export default {
  49. components: { technicianList , selectArea },
  50. data() {
  51. return {
  52. list: [],
  53. queryParams: {
  54. pageNo: 1,
  55. pageSize: 10,
  56. title: ''
  57. },
  58. technicianList: [],
  59. loading: false,
  60. finished: false,
  61. showAeraPro: false,
  62. area: '',
  63. active : 0
  64. }
  65. },
  66. onShow() {
  67. this.getTechnicianList()
  68. this.initUserArea()
  69. },
  70. methods: {
  71. //list列表滑动到底部自动新增数据列表
  72. onLoad() {
  73. this.queryParams.pageSize += 10
  74. this.getTechnicianList()
  75. },
  76. //获取技师列表
  77. getTechnicianList() {
  78. this.$api('getTechnicianList', this.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. this.updateSessionPositon(area)
  103. },
  104. //显示选择地区
  105. showSelectArea() {
  106. this.showAeraPro = true;
  107. },
  108. //获取用户详细地址(省市县)
  109. getLocation() {
  110. Position.getLocationDetail().then(res => {
  111. sessionStorage.setItem("position", JSON.stringify(res))
  112. this.area = res.addressDetail.district
  113. })
  114. },
  115. //初始化用户所在地区
  116. initUserArea(){
  117. if(!sessionStorage.getItem('position')) return this.getLocation() //获取(详细地址,包括省市区)
  118. let positionInfo = JSON.parse(sessionStorage.getItem('position'))
  119. this.area = positionInfo.addressDetail.district
  120. },
  121. //计算距离
  122. calculatedDistance() {
  123. Position.getLocation(result => {
  124. this.technicianList.forEach(item => {
  125. item.km = Position.calculateDistance(result.latitude, result.longitude, item.latitude, item.longitude)
  126. })
  127. })
  128. },
  129. //更新用户所在区域(更新区县信息)
  130. updateSessionPositon(area){
  131. if(sessionStorage.getItem('position')){
  132. let position = JSON.parse(sessionStorage.getItem('position'))
  133. position.addressDetail.district = area
  134. sessionStorage.setItem('position',JSON.stringify(position))
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. body {
  142. background-color: #f3f3f3;
  143. }
  144. .technician-top {
  145. background: #F6BEC3;
  146. }
  147. .technician-bottm {
  148. display: flex;
  149. justify-content: space-around;
  150. font-size: 28rpx;
  151. height: 110rpx;
  152. align-items: center;
  153. color: #fff;
  154. }
  155. .technician-search {
  156. padding-top: 60rpx;
  157. .search {
  158. height: 82rpx;
  159. width: 710rpx;
  160. background: #FFFFFF;
  161. margin: 0px auto;
  162. border-radius: 41rpx;
  163. box-sizing: border-box;
  164. padding: 0 15rpx;
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. .left-area,
  169. .center-area {
  170. display: flex;
  171. align-items: center;
  172. }
  173. .left-area {
  174. max-width: 160rpx;
  175. image {
  176. flex-shrink: 0;
  177. width: 26rpx;
  178. height: 26rpx;
  179. }
  180. .area {
  181. font-size: 24rpx;
  182. display: -webkit-box;
  183. -webkit-line-clamp: 2;
  184. /* 限制显示两行 */
  185. -webkit-box-orient: vertical;
  186. overflow: hidden;
  187. text-overflow: ellipsis;
  188. color: #292929;
  189. }
  190. .parting-line {
  191. flex-shrink: 0;
  192. font-size: 26rpx;
  193. color: #ccc;
  194. margin: 0rpx 5rpx;
  195. }
  196. }
  197. .center-area {
  198. display: flex;
  199. flex-wrap: nowrap;
  200. align-items: center;
  201. width: calc(100% - 290rpx);
  202. image {
  203. width: 26rpx;
  204. height: 26rpx;
  205. }
  206. .van-field {
  207. background-color: transparent;
  208. box-sizing: border-box;
  209. height: 82rpx;
  210. line-height: 82rpx;
  211. width: calc(100% - 30rpx);
  212. padding: 0rpx 10rpx 0rpx 0rpx;
  213. input {
  214. height: 82rpx;
  215. font-size: 60rpx;
  216. }
  217. }
  218. }
  219. .right-area {
  220. .search-button {
  221. background: #F6BEC3;
  222. height: 60rpx;
  223. width: 130rpx;
  224. font-size: 26rpx;
  225. border-radius: 35rpx;
  226. color: white;
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. }
  231. }
  232. }
  233. }
  234. .technician-search-button {
  235. background-color: #F6BEC3;
  236. color: #fff;
  237. font-size: 26rpx;
  238. padding: 2rpx 24rpx;
  239. border-radius: 40rpx;
  240. }
  241. </style>