siteList.vue 8.4 KB

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