siteList.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view :class="['site-item' , index === 0 ? 'first-site-item' : '']" @click.stop="openSite(info)">
  3. <view class="site-name">{{info.locationName}}</view>
  4. <view class="location-text">
  5. <view class="icon-box">
  6. <image class="location-icon" src="/static/images/location-text.png" mode="aspectFit" />
  7. </view>
  8. <text class="location-val">{{`${info.cityName || ''}${info.areaName || ''}${info.address || ''}`}}</text>
  9. </view>
  10. <view class="distance-box">
  11. <view class="distance-num one-row">
  12. 距离{{getDistance(info.centerDistance)}}
  13. <!-- 距离{{getDistance(info.distance)}} -->
  14. </view>
  15. <view class="distance-btns">
  16. <view class="distance-btn" @click.stop="getPhoneCall(info.mapContactList)">
  17. <image class="btn-icon" src="/static/images/btn_02.png" mode="aspectFit" />
  18. <text>电话</text>
  19. </view>
  20. <view class="distance-btn" @click.stop="openLocation(info)">
  21. <image class="btn-icon" src="/static/images/btn_01.png" mode="aspectFit" />
  22. <text>导航</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="division-box" />
  27. <view class="time-box">
  28. <view class="time-label">
  29. <image class="time-icon" src="/static/images/time.png" mode="aspectFit" />
  30. <text class="time-text">办公时间:</text>
  31. </view>
  32. <view :class="['time-content', isShow ? '': 'hide-content' ]" id="contentText">
  33. <template v-for="(item , index) in getVal(info.workTimeRemark)">
  34. <view :class="[index==0 ? 'time-val' :'' ]">
  35. <text>{{ item }} </text>
  36. <view v-if="index === 0 && isExceed" class="exceed-btn" @click.stop="isShow = !isShow">
  37. <text>{{isShow ? '收起':'展开'}} </text>
  38. <image :class="['direction' , isShow ? '' : 'show-direction']"
  39. src="/static/images/direction.png" mode="aspectFit" />
  40. </view>
  41. </view>
  42. </template>
  43. </view>
  44. </view>
  45. <telList ref="telListRef" />
  46. <!-- 选择地图 -->
  47. <SelectMapNavigation ref="SelectMapNavigationRef" />
  48. </view>
  49. </template>
  50. <script>
  51. import { distanceCalculate, getMapLocation } from "@/utils/tool.js";
  52. import { EventBus } from "@/utils/vueBus.js"
  53. import telList from "./telList.vue"
  54. import map from "./../map.js"
  55. import SelectMapNavigation from "./SelectMapNavigation.vue"
  56. export default {
  57. mixins: [map],
  58. props: {
  59. index: {
  60. type: Number,
  61. require: true,
  62. default: 0
  63. },
  64. info: {
  65. type: Object,
  66. require: true,
  67. default: () => {}
  68. }
  69. },
  70. components: { telList , SelectMapNavigation },
  71. data() {
  72. return {
  73. isExceed: false,
  74. isShow: true,
  75. // outerPhone
  76. }
  77. },
  78. mounted() {
  79. this.getContentHeight()
  80. },
  81. watch: {
  82. isShow() {
  83. this.$emit('refresh')
  84. }
  85. },
  86. methods: {
  87. getContentHeight() {
  88. this.$nextTick(() => {
  89. setTimeout(() => {
  90. try {
  91. const query = uni.createSelectorQuery().in(this).select("#contentText");
  92. query.boundingClientRect((data) => {
  93. const defaultHeight = uni.upx2px(33)
  94. // console.log("data.height = ", data.height, uni.upx2px(33))
  95. // const f_s = uni.upx2px(this.contentSize) * this.contentHeight * 5;
  96. // const content_h = data.height;
  97. // // 是否超出
  98. this.isExceed = data.height > uni.upx2px(33) ? true : false;
  99. this.isShow = false
  100. // // 超出就隐藏,否则就不隐藏
  101. // this.showAllContent = this.exceedHeight ? false : true;
  102. // this.showContent = true;
  103. })
  104. .exec();
  105. } catch (e) {
  106. this.exceedHeight = false;
  107. this.showAllContent = true;
  108. this.showContent = true;
  109. }
  110. }, 10)
  111. })
  112. },
  113. getDistance(num) {
  114. return distanceCalculate(num)
  115. },
  116. getPhoneCall(tel) {
  117. this.$refs.telListRef.open({ tel })
  118. },
  119. openLocation(info) {
  120. // const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } = info
  121. // const name = `${provinceName}${cityName}${areaName}${address}`;
  122. // const code = areaCode || cityCode || provinceCode
  123. // openMap({ name, code, type: "gaode", info })
  124. // this.$emit("openMap" ,info )
  125. this.$refs.SelectMapNavigationRef.open(info)
  126. },
  127. openSite(info) {
  128. this.$emit('checkSiteDetails', info)
  129. // EventBus.$emit('TianDiTuSite', info)
  130. },
  131. getHeight() {
  132. return new Promise(resolve => {
  133. let contentH = 0;
  134. try {
  135. const query = uni.createSelectorQuery().in(this);
  136. query
  137. .select(".site-item")
  138. .boundingClientRect((data) => {
  139. if (data) {
  140. contentH = data.height;
  141. }
  142. })
  143. .exec();
  144. } catch (error) {}
  145. resolve(contentH)
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .site-item {
  153. width: 100%;
  154. padding: 30rpx 30rpx 0;
  155. border-bottom: 10rpx solid #F5F5F5;
  156. .site-name {
  157. font-size: 30rpx;
  158. font-weight: 700;
  159. color: #1a1a1a;
  160. line-height: 42rpx;
  161. }
  162. .location-text {
  163. width: 100%;
  164. display: flex;
  165. align-items: start;
  166. padding: 12rpx 0;
  167. .icon-box {
  168. width: 22rpx;
  169. height: 37rpx;
  170. flex-shrink: 0;
  171. .location-icon {
  172. width: 22rpx;
  173. height: 37rpx;
  174. }
  175. }
  176. .location-val {
  177. font-size: 26rpx;
  178. font-weight: 400;
  179. line-height: 37rpx;
  180. color: #666666;
  181. padding-left: 8rpx;
  182. }
  183. }
  184. .distance-box {
  185. width: 100%;
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. .distance-num {
  190. font-size: 26rpx;
  191. font-weight: 400;
  192. color: #808080;
  193. }
  194. .distance-btns {
  195. width: 274rpx;
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-between;
  199. .distance-btn {
  200. width: 130rpx;
  201. height: 50rpx;
  202. border-radius: 10rpx;
  203. background-color: #61A8FF;
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. image {
  208. width: 22rpx;
  209. height: 26rpx;
  210. margin-right: 10rpx;
  211. }
  212. line-height: 30rpx;
  213. font-size: 22rpx;
  214. font-weight: 700;
  215. color: #ffffff;
  216. }
  217. }
  218. }
  219. .division-box {
  220. margin-top: 20rpx;
  221. width: 100%;
  222. height: 1px;
  223. background: #f0f0f0;
  224. }
  225. .time-box {
  226. min-height: 73rpx;
  227. padding: 20rpx 0;
  228. font-size: 26rpx;
  229. font-weight: 400;
  230. color: #808080;
  231. display: flex;
  232. align-items: start;
  233. .time-label {
  234. display: flex;
  235. align-items: center;
  236. .time-icon {
  237. width: 27rpx;
  238. height: 33rpx;
  239. }
  240. .time-text {
  241. padding-left: 8rpx;
  242. line-height: 33rpx;
  243. color: #1a1a1a;
  244. }
  245. }
  246. .time-content {
  247. flex: 1;
  248. .time-val {
  249. width: 100%;
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: start;
  253. line-height: 33rpx;
  254. .exceed-btn {
  255. flex-shrink: 0;
  256. display: flex;
  257. align-items: center;
  258. color: #61A8FF;
  259. .direction {
  260. width: 42rpx;
  261. height: 33rpx;
  262. }
  263. .show-direction {
  264. transform: rotate(180deg);
  265. }
  266. }
  267. }
  268. }
  269. .hide-content {
  270. height: 33rpx;
  271. overflow: hidden;
  272. }
  273. }
  274. // box-shadow: 1px 1px 1px 1px #ccc;
  275. // background-color: #ccc;
  276. // .site-name {
  277. // padding-top: 30rpx;
  278. // font-size: 36rpx;
  279. // padding-bottom: 15rpx;
  280. // background-color: #fff;
  281. // }
  282. // .site-info {
  283. // background-color: #fff;
  284. // display: flex;
  285. // justify-content: space-between;
  286. // align-items: center;
  287. // .site-left {
  288. // width: 1px;
  289. // flex: 1;
  290. // display: flex;
  291. // flex-direction: column;
  292. // font-size: 28rpx;
  293. // padding-bottom: 15rpx;
  294. // .site-distance {
  295. // color: #7D7D7D;
  296. // }
  297. // }
  298. // .site-right {
  299. // flex-shrink: 0;
  300. // display: flex;
  301. // align-items: center;
  302. // .site-btn {
  303. // margin-left: 10rpx;
  304. // display: flex;
  305. // flex-direction: column;
  306. // align-items: center;
  307. // .site-icon {
  308. // width: 50rpx;
  309. // height: 50rpx;
  310. // line-height: 1;
  311. // border-radius: 50%;
  312. // background-color: #3291F8;
  313. // display: flex;
  314. // align-items: center;
  315. // justify-content: center;
  316. // }
  317. // .icon {
  318. // width: 30rpx;
  319. // height: 30rpx;
  320. // path {
  321. // fill: #fff;
  322. // }
  323. // }
  324. // .site-text {
  325. // font-size: 28rpx;
  326. // }
  327. // }
  328. // }
  329. // }
  330. // .site-time {
  331. // background-color: #fff;
  332. // border-top: 1rpx solid #F0F0F0;
  333. // padding: 15rpx 0;
  334. // display: flex;
  335. // justify-content: space-between;
  336. // font-size: 28rpx;
  337. // text {
  338. // flex-shrink: 0;
  339. // }
  340. // .time-lable {
  341. // color: #7D7D7D;
  342. // }
  343. // .site-time-val {
  344. // width: 1rpx;
  345. // flex: 1;
  346. // padding-left: 30rpx;
  347. // // text-align: right;
  348. // }
  349. // }
  350. // &:first-child {
  351. // .site-name {
  352. // padding-top: 0;
  353. // }
  354. // }
  355. }
  356. .first-site-item {
  357. padding-top: 0;
  358. }
  359. </style>