宜轩到家/服务到家第三版,换个颜色
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.

268 lines
6.0 KiB

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