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

273 lines
6.1 KiB

7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 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.initUserArea()
  56. this.getTechnicianList()
  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. this.queryParams.county = area
  90. //更新所在地区
  91. this.updateSessionPositon(area)
  92. this.getTechnicianList()
  93. },
  94. //显示选择地区
  95. showSelectArea() {
  96. this.showAeraPro = true;
  97. },
  98. //获取用户详细地址(省市县)
  99. getLocation() {
  100. Position.getLocationDetail().then(res => {
  101. sessionStorage.setItem("position", JSON.stringify(res))
  102. this.area = res.addressDetail.district
  103. })
  104. },
  105. //初始化用户所在地区
  106. initUserArea(){
  107. if(!sessionStorage.getItem('position')) return this.getLocation() //获取(详细地址,包括省市区)
  108. let positionInfo = JSON.parse(sessionStorage.getItem('position'))
  109. this.area = positionInfo.addressDetail.district
  110. this.queryParams.county = this.area
  111. },
  112. //计算距离
  113. calculatedDistance() {
  114. Position.getLocation(result => {
  115. this.technicianList.forEach(item => {
  116. item.km = Position.calculateDistance(result.latitude, result.longitude, item.latitude, item.longitude)
  117. })
  118. })
  119. },
  120. //更新用户所在区域(更新区县信息)
  121. updateSessionPositon(area){
  122. if(sessionStorage.getItem('position')){
  123. let position = JSON.parse(sessionStorage.getItem('position'))
  124. position.addressDetail.district = area
  125. sessionStorage.setItem('position',JSON.stringify(position))
  126. }
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. body {
  133. background-color: #f3f3f3;
  134. }
  135. .technician-top {
  136. background: #ecb978;
  137. color: #6e3009;
  138. }
  139. .technician-bottm {
  140. display: flex;
  141. justify-content: space-around;
  142. font-size: 28rpx;
  143. height: 110rpx;
  144. align-items: center;
  145. color: #6e3009;
  146. }
  147. .technician-search {
  148. padding-top: 60rpx;
  149. .search {
  150. height: 82rpx;
  151. width: 710rpx;
  152. background: #FFFFFF;
  153. margin: 0px auto;
  154. border-radius: 41rpx;
  155. box-sizing: border-box;
  156. padding: 0 15rpx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. .left-area,
  161. .center-area {
  162. display: flex;
  163. align-items: center;
  164. }
  165. .left-area {
  166. max-width: 160rpx;
  167. image {
  168. flex-shrink: 0;
  169. width: 26rpx;
  170. height: 26rpx;
  171. }
  172. .area {
  173. font-size: 24rpx;
  174. display: -webkit-box;
  175. -webkit-line-clamp: 2;
  176. /* 限制显示两行 */
  177. -webkit-box-orient: vertical;
  178. overflow: hidden;
  179. text-overflow: ellipsis;
  180. color: #292929;
  181. }
  182. .parting-line {
  183. flex-shrink: 0;
  184. font-size: 26rpx;
  185. color: #ccc;
  186. margin: 0rpx 5rpx;
  187. }
  188. }
  189. .center-area {
  190. display: flex;
  191. flex-wrap: nowrap;
  192. align-items: center;
  193. width: calc(100% - 290rpx);
  194. image {
  195. width: 26rpx;
  196. height: 26rpx;
  197. }
  198. .van-field {
  199. background-color: transparent;
  200. box-sizing: border-box;
  201. height: 82rpx;
  202. line-height: 82rpx;
  203. width: calc(100% - 30rpx);
  204. padding: 0rpx 10rpx 0rpx 0rpx;
  205. input {
  206. height: 82rpx;
  207. font-size: 60rpx;
  208. }
  209. }
  210. }
  211. .right-area {
  212. .search-button {
  213. height: 60rpx;
  214. width: 130rpx;
  215. font-size: 26rpx;
  216. border-radius: 35rpx;
  217. background: linear-gradient(178deg, #ffe6ed, #ecb978);
  218. color: #6e3009;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. }
  223. }
  224. }
  225. }
  226. .technician-search-button {
  227. background: linear-gradient(178deg, #ffe6ed, #ecb978);
  228. color: #6e3009;
  229. font-size: 26rpx;
  230. padding: 2rpx 24rpx;
  231. border-radius: 40rpx;
  232. }
  233. </style>