detail.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="peripheralDetail">
  3. <div class="peripheralFirstBox">
  4. <div class="periTitle">{{detail.businessName}}<span class="periType">{{detail.typeName}}</span></div>
  5. <div class="periTime">更新时间:{{detail.releaseTime}}</div>
  6. <div class="periAddress">
  7. <span>地址:{{detail.businessAddress}}</span>
  8. <img src="../parkActivity/image/dhIcon.png" class="dhIcon" @tap="searchAddress(detail.businessAddress)">
  9. </div>
  10. <div class="contactBox">
  11. <span class="contackLeft">
  12. <span style="color: #666666;font-size: 28rpx">联系电话:</span>
  13. <span style="color: #18172A;font-size: 36rpx;font-weight: 600">{{detail.businessPhone}}</span>
  14. </span>
  15. <img src="https://www.idea-co-sf.com/gardenProduct/image/phoneIcon.png" class="phoneIcon" @tap="phoneCall(detail.businessPhone)">
  16. </div>
  17. </div>
  18. <div class="peripheralFirstBox" style="padding: 32rpx">
  19. <div class="periTitle" style="padding: 0 0 32rpx 0">简介</div>
  20. <!-- <img src="https://www.idea-co-sf.com/gardenProduct/image/img1.png" class="firstImg"/>-->
  21. <div v-for="fit in detail.imageUrl" :key="fit">
  22. <img :src="fit" class="firstImg" />
  23. </div>
  24. <div class="perInfo" v-html="detail.introduction">
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { peripheryGetById,getUserLocalStorageInfo,getByCodes } from "@/js_sdk/http";
  31. export default {
  32. name: "detail",
  33. data(){
  34. return{
  35. getUserLocalStorageInfo: getUserLocalStorageInfo(),
  36. dc_key: ['periphery_type'],
  37. serviceList:[],
  38. detail:{}
  39. }
  40. },
  41. created(){
  42. this.getByCodes()
  43. },
  44. onLoad(item){
  45. console.log(item.id)
  46. this.getDetailById(item.id)
  47. },
  48. methods:{
  49. async getByCodes() {
  50. let data = await getByCodes(JSON.stringify(this.dc_key));
  51. this.dic_SelectList = this.$common.handleDicList(data);
  52. this.serviceList = this.dic_SelectList.periphery_type
  53. },
  54. phoneCall(phone){
  55. uni.makePhoneCall({
  56. phoneNumber: phone, // 需要拨打的电话号码
  57. success: function () {
  58. console.log('拨打电话成功!');
  59. },
  60. fail: function (err) {
  61. console.error('拨打电话失败:', err);
  62. // 可能的失败原因包括:用户拒绝、没有安装电话应用等
  63. uni.showToast({
  64. title: '拨打电话失败',
  65. icon: 'none'
  66. });
  67. }
  68. })
  69. },
  70. searchAddress(address){
  71. console.log(address)
  72. uni.getLocation({
  73. type: 'wgs84',
  74. geocode: true, // 是否解析地址为经纬度
  75. address: address,
  76. success: function (res) {
  77. console.log(res)
  78. const latitude = res.latitude; //待web端传经纬度
  79. const longitude = res.longitude;//待web端传经纬度
  80. uni.openLocation({
  81. latitude: latitude,
  82. longitude: longitude,
  83. address: address,
  84. // ...其他参数
  85. });
  86. },
  87. fail: function (error) {
  88. console.error('获取位置失败', error);
  89. }
  90. });
  91. },
  92. getDetailById(id) {
  93. const _this = this
  94. peripheryGetById({ id }).then((res) => {
  95. console.log(res.data)
  96. if (res.data) {
  97. const det = _this.getItemJson(res.data)
  98. this.detail = det
  99. this.star = Math.ceil((det.score == null ? 0 : det.score) / (det.evaluateNum == null ? 1 : det.evaluateNum))
  100. }
  101. // const item = _this.getItemJson(res)
  102. })
  103. },
  104. getItemJson: function(item) {
  105. item.releaseTime = this.$common.transDate(item.releaseTime)
  106. // item.type = this.dic_SelectList.periphery_type[item.type]
  107. let transformedObject = this.dic_SelectList.periphery_type.reduce((acc, obj) => {
  108. acc[obj.value] = obj.label;
  109. return acc;
  110. }, {'':'全部'});
  111. item.typeName = transformedObject[item.type]
  112. if (item.fileUrl && item.fileUrl.length > 2) {
  113. const files = JSON.parse(item.fileUrl)
  114. item.imageUrl = []
  115. files.forEach(itemm => {
  116. itemm.url = itemm.url.replace('server', 'smartParkH5Server')
  117. item.imageUrl.push(itemm.url)
  118. })
  119. }
  120. return item
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .peripheralDetail{
  127. box-sizing: border-box;
  128. .peripheralFirstBox{
  129. margin: 24rpx 0;
  130. padding: 32rpx 0;
  131. background: white;
  132. box-sizing: border-box;
  133. .periTitle{
  134. color: rgba(34, 34, 34, 1);
  135. font-size: 32rpx;
  136. font-weight: 600;
  137. display: flex;
  138. align-items: center;
  139. padding: 0 32rpx;
  140. box-sizing: border-box;
  141. .periType{
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. width: 92rpx;
  146. height: 48rpx;
  147. background: rgba(3, 101, 249, 0.20);
  148. color: rgba(3, 101, 249, 1);
  149. border-radius: 8rpx;
  150. font-size: 28rpx;
  151. font-weight: 500;
  152. margin-left: 24rpx;
  153. }
  154. }
  155. .periTime{
  156. font-size: 28rpx;
  157. color: rgba(102, 102, 102, 1);
  158. padding: 16rpx 32rpx;
  159. box-sizing: border-box;
  160. }
  161. .periAddress{
  162. display: flex;
  163. justify-content: space-between;
  164. align-items: center;
  165. font-size: 28rpx;
  166. color: rgba(102, 102, 102, 1);
  167. padding: 0 32rpx 32rpx 32rpx;
  168. box-sizing: border-box;
  169. .dhIcon{
  170. width: 36rpx;
  171. height: 36rpx;
  172. padding-left: 20rpx;
  173. border-left: 1px solid #E6E6E6;
  174. }
  175. }
  176. .contactBox{
  177. display: flex;
  178. align-items: center;
  179. justify-content: space-between;
  180. padding:24rpx 32rpx 0 32rpx;
  181. border-top: 1px solid #E6E6E6;
  182. .contackLeft{
  183. display: flex;
  184. align-items: center;
  185. }
  186. .phoneIcon{
  187. width: 64rpx;
  188. height: 64rpx;
  189. }
  190. }
  191. .firstImg{
  192. width: 686rpx;
  193. height: 300rpx;
  194. }
  195. .perInfo{
  196. font-size: 28rpx;
  197. color: rgba(51, 51, 51, 1);
  198. line-height: 50rpx;
  199. margin-top: 24rpx;
  200. }
  201. }
  202. }
  203. </style>