serveDetail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="home-detail">
  3. <div class="container" v-loading="loading">
  4. <div class="container-box" v-if="detail.id">
  5. <div class="home-detail-content">
  6. <div class="home-detail-swiper">
  7. <div class="swiper-container">
  8. <div class="swiper-wrapper">
  9. <div v-for="item in rotatingImages" :key="item.id" class="swiper-slide"
  10. :style="`background-image:url(${item.url})`" @click.stop="openImage(item)">
  11. </div>
  12. </div>
  13. <div class="swiper-button-prev"></div>
  14. <div class="swiper-button-next"></div>
  15. </div>
  16. </div>
  17. <div class="home-detail-information">
  18. <div class="house-name">{{detail.name}}</div>
  19. <div class="sub-title">{{detail.subtitle}}</div>
  20. <div class="house-price">
  21. <div class="color-danger price">
  22. <span class="average alibaba">{{detail.price}}</span><span class="unit">元/次</span>
  23. </div>
  24. <div class="button-box">
  25. <el-button type="primary" size="small" @click="payItem"
  26. v-permission="`/work/serve/list/${$route.query.sign}/pay`">
  27. 购买
  28. </el-button>
  29. <el-button type="primary" size="small" @click="chatItem">联系客服</el-button>
  30. </div>
  31. </div>
  32. <div class="contract" v-if="detail.contract">
  33. <span class="color-primary" @click="lookContract">查看合同</span>
  34. </div>
  35. <div class="content-detail" v-if="detail.intro">
  36. <div class="detail-item" v-for="(item,index) in JSON.parse(detail.intro)" :key="item.id">
  37. <i class="iconfont huifont-youjiantou"></i>
  38. <div class="detail-item-title">{{item.title}}</div>
  39. <div class="detail-item-content">{{item.content}}</div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="detail-img-box">
  45. <div class="home-detail-img" v-for="(item,index) in detailedImage" :key="item.id">
  46. <img :src="item.url" :alt="item.name">
  47. </div>
  48. </div>
  49. </div>
  50. <div class="skeleton-box" v-else>
  51. <el-empty description="暂无服务"></el-empty>
  52. </div>
  53. </div>
  54. <el-dialog :close-on-click-modal="false" :title="dialogType === 1?'创建订单':'预览合同'" :visible.sync="dialogVisible"
  55. width="900px" :append-to-body="true">
  56. <create-order v-if="dialogVisible && dialogType === 1" :serveId="detail.id"
  57. @callback="dialogVisible = false">
  58. </create-order>
  59. <pdf-viewer v-if="dialogVisible && dialogType === 2"
  60. :list="detail.contract ? JSON.parse(detail.contract) : []" type="preview">
  61. </pdf-viewer>
  62. </el-dialog>
  63. <el-dialog :title="`与<${customerTitle}>的聊天`" :visible.sync="chatVisible" width="600px" :append-to-body="true">
  64. <chat-box v-if="chatVisible" :body="{
  65. conversationId: customerId
  66. }"></chat-box>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import {
  72. getServeListByQuery
  73. } from '@/api/serve'
  74. import {
  75. getCustomerServeDetail
  76. } from '@/api/organization'
  77. import Crypto from '@/uitls/crypto'
  78. const createOrder = () => import('@/components/website/createOrder');
  79. const pdfViewer = () => import('@/components/common/pdfViewer');
  80. const chatBox = () => import('@/layout/components/chat/customer/chatBox.vue');
  81. export default {
  82. data() {
  83. return {
  84. loading: false,
  85. type: '',
  86. detail: {},
  87. list: [],
  88. rotatingImages: [],
  89. detailedImage: [],
  90. dialogVisible: false,
  91. dialogType: '',
  92. chatVisible: false,
  93. customerId: '',
  94. customerTitle: ''
  95. };
  96. },
  97. mounted() {
  98. window.scrollTo(0, 0);
  99. this.init();
  100. },
  101. methods: {
  102. init() {
  103. this.loading = true;
  104. this.type = Crypto.AES.decrypt(decodeURIComponent(this.$route.query.type), 'bosshand');
  105. if (!this.type) return this.loading = false;
  106. this.getDetail();
  107. },
  108. getDetail() {
  109. getServeListByQuery({
  110. productLevelId: this.type,
  111. state: 1
  112. }).then(res => {
  113. if (res.state) {
  114. if (res.data.length === 0) return this.loading = false;
  115. this.list = res.data;
  116. this.initDetail(this.list.length - 1);
  117. } else {
  118. this.loading = false;
  119. }
  120. this.loading = false;
  121. })
  122. },
  123. initDetail(val) {
  124. this.detail = this.list[val];
  125. if (this.detail.rotatingImages) {
  126. this.rotatingImages = JSON.parse(this.detail.rotatingImages);
  127. this.initSwiper();
  128. }
  129. if (this.detail.detailedImage) {
  130. this.detailedImage = JSON.parse(this.detail.detailedImage);
  131. }
  132. },
  133. initSwiper() {
  134. this.$nextTick(() => {
  135. this.swiper = new Swiper(".swiper-container", {
  136. loop: true,
  137. navigation: {
  138. nextEl: '.swiper-button-next',
  139. prevEl: '.swiper-button-prev',
  140. },
  141. })
  142. })
  143. },
  144. payItem() {
  145. if (!this.$store.getters.user.userId) {
  146. let index = this.$store.getters.loginVisible;
  147. index++
  148. this.$store.dispatch('app/changeLoginVisible', index);
  149. return;
  150. }
  151. this.dialogType = 1;
  152. this.dialogVisible = true;
  153. },
  154. chatItem() {
  155. if (!this.$store.getters.user.userId) {
  156. let index = this.$store.getters.loginVisible;
  157. index++
  158. this.$store.dispatch('app/changeLoginVisible', index);
  159. return;
  160. }
  161. if (!this.detail.customerId) return this.$message.warning('该产品暂未设置客服');
  162. getCustomerServeDetail(this.detail.customerId).then(res => {
  163. if (res.state) {
  164. if (!res.data) return this.$message.warning('该产品暂未设置客服');
  165. this.customerId = res.data.customerId;
  166. this.customerTitle = res.data.nickName;
  167. this.chatVisible = true;
  168. }
  169. })
  170. },
  171. lookContract() {
  172. this.dialogType = 2;
  173. this.dialogVisible = true;
  174. }
  175. },
  176. components: {
  177. createOrder,
  178. pdfViewer,
  179. chatBox
  180. }
  181. };
  182. </script>
  183. <style lang="scss">
  184. .home-detail {
  185. padding: 10px 0;
  186. box-sizing: border-box;
  187. .home-detail-img {
  188. width: 100%;
  189. img {
  190. width: 100%;
  191. }
  192. }
  193. .detail-item {
  194. padding-top: 20px;
  195. position: relative;
  196. padding-left: 25px;
  197. .huifont-youjiantou {
  198. color: $--color-primary;
  199. font-size: 22px;
  200. position: absolute;
  201. left: 0;
  202. top: 22px;
  203. }
  204. .detail-item-title {
  205. font-size: 20px;
  206. font-weight: bold;
  207. }
  208. .detail-item-content {
  209. margin-top: 3px;
  210. color: $--color-text-secondary;
  211. }
  212. }
  213. .contract {
  214. text-align: right;
  215. padding-top: 10px;
  216. cursor: pointer;
  217. }
  218. .container {
  219. width: 1200px;
  220. margin: 0 auto;
  221. min-height: calc(100vh - 137px);
  222. position: relative;
  223. }
  224. .skeleton-box {
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. bottom: 0;
  229. right: 0;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. }
  234. .home-detail-content {
  235. display: flex;
  236. padding-top: 30px;
  237. }
  238. .home-detail-swiper {
  239. width: 670px;
  240. height: 480px;
  241. background: $--background-color-base;
  242. .swiper-container,
  243. .swiper-wrapper,
  244. .swiper-slide {
  245. width: 100%;
  246. height: 100%;
  247. }
  248. .swiper-slide {
  249. background-size: cover;
  250. background-position: center;
  251. background-repeat: no-repeat;
  252. cursor: pointer;
  253. position: relative;
  254. }
  255. .swiper-button-next:after,
  256. .swiper-button-prev:after {
  257. color: #eee;
  258. font-size: 16px;
  259. }
  260. .swiper-button-prev,
  261. .swiper-container-rtl .swiper-button-next {
  262. left: 0;
  263. background: rgba(0, 0, 0, 0.1);
  264. height: 70px;
  265. margin-top: -35px;
  266. }
  267. .swiper-button-next,
  268. .swiper-container-rtl .swiper-button-prev {
  269. right: 0;
  270. background: rgba(0, 0, 0, 0.1);
  271. height: 70px;
  272. margin-top: -35px;
  273. }
  274. }
  275. .home-detail-information {
  276. width: 470px;
  277. height: 480px;
  278. margin-left: 60px;
  279. .house-name {
  280. font-size: 26px;
  281. font-weight: 500;
  282. }
  283. .sub-title {
  284. font-size: $--font-size-small;
  285. color: $--color-text-secondary;
  286. text-indent: 24px;
  287. margin-top: 10px;
  288. }
  289. .content-title {
  290. padding: 10px 0;
  291. font-size: 16px;
  292. font-weight: 500;
  293. }
  294. .house-price {
  295. display: flex;
  296. align-items: center;
  297. justify-content: space-between;
  298. border-bottom: 1px solid $--border-color-light;
  299. padding: 10px 0;
  300. .price {
  301. display: flex;
  302. align-items: flex-end;
  303. }
  304. }
  305. .average {
  306. font-size: 30px;
  307. font-weight: 900;
  308. margin-right: 5px;
  309. line-height: 24px;
  310. }
  311. .unit {
  312. font-size: 12px;
  313. }
  314. .desc-text {
  315. margin-top: 10px;
  316. }
  317. }
  318. }
  319. </style>