siteList.vue 8.3 KB

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