solution.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template lang="pug">
  2. .view.solution-page
  3. link(href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet")
  4. Topnav(
  5. :fixed="true"
  6. :show-publish="false"
  7. :show-search="topnavFunctional"
  8. @publish-click="connectPopupVisible = true"
  9. )
  10. .summary(
  11. v-if="data"
  12. ref="summary"
  13. )
  14. .container.is-content.is-wide
  15. .columns
  16. .column.left
  17. .cover
  18. img(:src="data.images")
  19. .column
  20. .info
  21. h1.title {{data.title}}
  22. .extends
  23. .tag.is-choice(v-if="data.is_choice == 1") 优选
  24. .tag.is-link.is-light(v-if="data.type === 'gateway'") API
  25. .tag.is-success.is-light(v-if="data.type === 'gateway'") HTTPS
  26. span
  27. a.link(:href="`${siteUrl}/company/${data.uid}`") 服务商: {{data.company_info && data.company_info.name}}
  28. //- desc
  29. .desc(v-if="data.type === 'gateway' && data.is_signing == 1 && data.source == 5" v-html="data.description")
  30. .desc(v-else) {{data.description}}
  31. //- skus
  32. .skus(v-if="skus")
  33. .item(
  34. v-for="item in skus"
  35. :class="{cur: curSkuId === item.id, disabled: item.overlimit}"
  36. @click="changeSku(item)"
  37. ) {{item.label}}
  38. .price(v-if="skus && curSkuId && skuMap[curSkuId]")
  39. span.symbol ¥
  40. span.value {{formatPrice(skuMap[curSkuId].price)}}
  41. span.explain(v-show="!!skuMap[curSkuId].quota") / {{Number(skuMap[curSkuId].quota).toLocaleString()}} {{skuMap[curSkuId].unit}}
  42. .action
  43. .button.is-primary.is-rounded(
  44. v-if="skus"
  45. @click="purchase") {{curSkuId && skuMap[curSkuId] && skuMap[curSkuId].price == 0 ? '免费开通' : '立即购买'}}
  46. .button.is-primary.is-rounded(
  47. v-else
  48. @click="connectPopupVisible = true") 了解咨询
  49. .page-nav
  50. .container.is-content.is-wide
  51. .tabs
  52. ul
  53. li(
  54. v-for="(item, i) in navItems"
  55. :class="{'is-active': curNavIndex === i}"
  56. )
  57. a(@click="changeNavTab(item.id, i)") {{item.label}}
  58. .main
  59. .container.is-content.is-wide(v-if="data")
  60. .paper.columns
  61. .column.is-9
  62. .main-cont
  63. //- api doc
  64. ApiDoc#apidoc(
  65. v-if="apiDoc"
  66. :data="apiDoc"
  67. v-observe-visibility="visibilityChanged"
  68. )
  69. //- details: aliyun
  70. .details#details(
  71. v-if="data.source == 2"
  72. :class="detailsClass"
  73. v-observe-visibility="visibilityChanged"
  74. )
  75. .d-item.rich-text(v-html="data.detail")
  76. .details#details(
  77. v-else
  78. :class="detailsClass"
  79. v-html="data.detail"
  80. v-observe-visibility="visibilityChanged"
  81. )
  82. .case-list#case(v-if="data.successful_case")
  83. .caption.bordered 成功案例
  84. CaseCell(
  85. :solution-title="data.title"
  86. :data="data.successful_case"
  87. )
  88. .column.is-3
  89. .side-cont
  90. .rcmd-list(v-if="providerSolutionList && providerSolutionList.length")
  91. .caption 同服务商产品
  92. SideSolutionCell.item(
  93. v-for="item in providerSolutionList"
  94. :key="item.hash_id"
  95. :data="item"
  96. )
  97. .rcmd-list(v-if="relatedSolutionList && relatedSolutionList.length")
  98. .caption 相似方案推荐
  99. SideSolutionCell.item(
  100. v-for="item in relatedSolutionList"
  101. :key="item.hash_id"
  102. :data="item"
  103. )
  104. KaifainFooter(:data="footer")
  105. ConnectUs(
  106. source="开发屋详情"
  107. :isShowToast="connectPopupVisible"
  108. @close="connectPopupVisible = false"
  109. :sourceId="this.data && this.data.id"
  110. )
  111. </template>
  112. <script lang="ts">
  113. import 'quill/dist/quill.core.css'
  114. import 'quill/dist/quill.snow.css'
  115. import Vue from 'vue'
  116. import Topnav from '../components/Topnav.vue'
  117. import { getSolution, listProviderSolution, listRelatedSolution } from '../apis/solution'
  118. import { genDocumentFooterData } from '../helpers/seoHelper'
  119. import SideSolutionCell from '../components/SideSolutionCell.vue'
  120. import CaseCell from '../components/CaseCell.vue'
  121. import ApiDoc from '../components/ApiDoc.vue'
  122. import ConnectUs from '@/components/common/connectUsKaifain.vue'
  123. import KaifainFooter from '@/components/SeoFooter.vue'
  124. import { formatPrice } from '../utils/misc'
  125. import { parseApiDocFile } from '../helpers/apiDocHelper'
  126. import { ObserveVisibility } from 'vue-observe-visibility'
  127. import { MAIN_ENDPOINT, DASHBOARD_SCENE_CODE } from '../constant'
  128. Vue.directive('observe-visibility', ObserveVisibility)
  129. export default Vue.extend({
  130. name: 'Solution',
  131. components: {
  132. Topnav,
  133. SideSolutionCell,
  134. CaseCell,
  135. ApiDoc,
  136. ConnectUs,
  137. KaifainFooter
  138. },
  139. layout: 'kaifain_v2',
  140. head() {
  141. // @ts-ignore
  142. const { title = '' } = this.data || {}
  143. return {
  144. title: title ? `${title}介绍,功能,开发解决方案-开发屋` : '开发屋-开发解决方案',
  145. meta: [
  146. {
  147. name: 'keywords',
  148. content: title,
  149. },
  150. {
  151. name: 'description',
  152. content: `${title}详细介绍,包括不限于功能、接口、企业开发着对接和布局${title}的方法和详细的开发文档说明。`,
  153. },
  154. {
  155. name: 'h1',
  156. content: `${title}`,
  157. }
  158. ]
  159. }
  160. },
  161. data() {
  162. return {
  163. topnavFunctional: false,
  164. connectPopupVisible: false,
  165. data: {},
  166. curSkuId: null,
  167. curNavIndex: 0,
  168. primaryBtnOffsetY: 300,
  169. cacheNavElMap: {}
  170. }
  171. },
  172. computed: {
  173. siteUrl(): string {
  174. return this.$store.state.domainConfig.siteUrl
  175. },
  176. skus(): any[] | null {
  177. // @ts-ignore
  178. return this.data && this.data.is_signing == 1 && this.data.skus && this.data.skus.length ? this.data.skus.filter(item => !item.label.startsWith('test')).sort((a, b) => a.price - b.price) : null
  179. },
  180. skuMap() {
  181. // @ts-ignore
  182. return this.skus && this.skus.reduce((map, item) => {
  183. map[item.id] = item
  184. return map
  185. }, {}) || {}
  186. },
  187. detailsClass() {
  188. // @ts-ignore
  189. const source = Number(this.data && this.data.source) || 0
  190. switch (source) {
  191. // aliyun
  192. case 2:
  193. return 'r-product-detail'
  194. // tencent
  195. case 3:
  196. return 'mp__productguide-bd'
  197. // huawei
  198. case 4:
  199. return 'detail-description-content product-description'
  200. default:
  201. return 'ql-editor'
  202. }
  203. }
  204. },
  205. async asyncData(ctx: any) {
  206. const headers = ctx.req && {
  207. cookie: ctx.req.headers.cookie
  208. }
  209. const data = await getSolution(ctx.params.id, { headers })
  210. if (!data) {
  211. return
  212. }
  213. let relatedSolutionList!: any[]
  214. let apiDoc!: any
  215. if (data.tags_ids && data.tags_ids !== '[]') {
  216. relatedSolutionList = await listRelatedSolution({
  217. tags_ids: data.tags_ids,
  218. hash_id: data.hash_id,
  219. size: 5
  220. }, { headers })
  221. }
  222. const providerSolutionList = await listProviderSolution({
  223. uid: data.uid,
  224. hash_id: data.hash_id,
  225. page: 1,
  226. size: relatedSolutionList && relatedSolutionList.length ? 3 : 5
  227. }, { headers })
  228. // parse api doc
  229. if (data.doc_path) {
  230. apiDoc = await parseApiDocFile(data.doc_path)
  231. }
  232. if (!ctx.store.state.kaifain.inited) {
  233. await ctx.store.dispatch('parameters:load')
  234. }
  235. const { classes } = ctx.store.state.kaifain
  236. const footer = genDocumentFooterData({
  237. ctx,
  238. classes
  239. })
  240. const navItems = [{
  241. id: 'details',
  242. label: '产品介绍'
  243. }]
  244. if (apiDoc) {
  245. navItems.unshift({
  246. id: 'apidoc',
  247. label: 'API文档'
  248. })
  249. }
  250. if (data.successful_case) {
  251. navItems.push({
  252. id: 'case',
  253. label: '成功案例'
  254. })
  255. }
  256. return {
  257. data,
  258. providerSolutionList,
  259. relatedSolutionList,
  260. apiDoc,
  261. footer,
  262. navItems
  263. }
  264. },
  265. methods: {
  266. formatPrice,
  267. changeNavTab(id, idx) {
  268. // @ts-ignore
  269. this.curNavIndex = idx
  270. // @ts-ignore
  271. let el = this.cacheNavElMap[id]
  272. if (!el) {
  273. el = document.querySelector(`#${id}`)
  274. // @ts-ignore
  275. this.cacheNavElMap[id] = el
  276. }
  277. if (el) {
  278. el.scrollIntoView({
  279. behavior: 'smooth'
  280. })
  281. }
  282. },
  283. changeSku(sku) {
  284. if (sku.overlimit) {
  285. return
  286. }
  287. // @ts-ignore
  288. this.curSkuId = sku.id
  289. },
  290. getIndexByNavId(id: string, previous: boolean) {
  291. // @ts-ignore
  292. for (let i = 0, len = this.navItems.length; i < len; i++) {
  293. // @ts-ignore
  294. if (this.navItems[i].id === id) {
  295. return previous ? Math.min(i - 1, 0) : i
  296. }
  297. }
  298. return null
  299. },
  300. visibilityChanged(isVisible: boolean, { target }) {
  301. // @ts-ignore
  302. const idx = this.getIndexByNavId(target.id, !isVisible)
  303. if (idx != null) {
  304. // @ts-ignore
  305. this.curNavIndex = idx
  306. }
  307. },
  308. purchase() {
  309. // @ts-ignore
  310. window.location.href = `${MAIN_ENDPOINT}/pay?product_type=14&product_id=${this.curSkuId}&number=1&next=${encodeURIComponent('/kaifain/dashboard?scene=' + DASHBOARD_SCENE_CODE.PAID)}`
  311. },
  312. onScroll() {
  313. // @ts-ignore
  314. this.topnavFunctional = window.scrollY > (this.primaryBtnOffsetY || 300)
  315. }
  316. },
  317. mounted() {
  318. // @ts-ignore
  319. window.addEventListener('scroll', this.onScroll)
  320. this.$nextTick(() => {
  321. const el = this.$refs['summary']
  322. if (el) {
  323. // @ts-ignore
  324. const rect = el.getBoundingClientRect()
  325. // @ts-ignore
  326. this.primaryBtnOffsetY = rect.height - 80
  327. }
  328. // @ts-ignore
  329. this.onScroll()
  330. })
  331. },
  332. destroyed() {
  333. // @ts-ignore
  334. window.removeEventListener('scroll', this.onScroll)
  335. },
  336. created() {
  337. // @ts-ignore
  338. if (this.skus) {
  339. // @ts-ignore
  340. const availableSku = this.skus.find((item) => !item.overlimit)
  341. if (availableSku) {
  342. // @ts-ignore
  343. this.curSkuId = availableSku.id
  344. }
  345. }
  346. }
  347. })
  348. </script>
  349. <style lang="scss">
  350. @import '../assets/styles/vars';
  351. @import '../assets/styles/ext_aliyun_market';
  352. @import '../assets/styles/ext_tencent_market';
  353. @import '../assets/styles/ext_huawei_market';
  354. .solution-page {
  355. .summary {
  356. color: $ink;
  357. padding: 128px 0 80px;
  358. .column.left {
  359. flex: none;
  360. }
  361. .cover {
  362. width: 152px;
  363. height: 152px;
  364. border-radius: 32px;
  365. margin-right: 40px;
  366. overflow: hidden;
  367. position: relative;
  368. img {
  369. width: 100%;
  370. height: 100%;
  371. object-fit: cover;
  372. }
  373. &::after {
  374. content: '';
  375. width: 100%;
  376. height: 100%;
  377. border: 1px solid rgba(0, 0, 0, 0.1);
  378. border-radius: 32px;
  379. position: absolute;
  380. top: 0;
  381. left: 0;
  382. }
  383. }
  384. .title {
  385. margin-bottom: 1rem;
  386. line-height: 1.4;
  387. margin-top: -3px;
  388. overflow: hidden;
  389. text-overflow: ellipsis;
  390. -webkit-box-orient: vertical;
  391. display: -webkit-box;
  392. -webkit-line-clamp: 2;
  393. }
  394. .extends {
  395. font-size: 0.875rem;
  396. margin-bottom: 1rem;
  397. line-height: 1.4;
  398. .tag {
  399. margin-right: 0.5rem;
  400. + span {
  401. margin-left: 1.25rem;
  402. }
  403. }
  404. a.link {
  405. color: #888;
  406. }
  407. }
  408. .desc {
  409. font-size: 0.875rem;
  410. margin-bottom: 1.5rem;
  411. line-height: 1.4;
  412. }
  413. .price {
  414. font-weight: 600;
  415. margin-bottom: 1.75rem;
  416. .symbol {
  417. font-size: 1.25rem;
  418. margin-right: 3px;
  419. }
  420. .value {
  421. font-size: 1.625rem;
  422. }
  423. .explain {
  424. font-weight: 400;
  425. font-size: 0.875rem;
  426. margin: 0 0 1px 2px;
  427. opacity: 0.54;
  428. }
  429. }
  430. .action {
  431. .button {
  432. font-size: 0.875rem;
  433. font-weight: 500;
  434. min-width: 106px;
  435. height: 2.75em;
  436. letter-spacing: 0.01em;
  437. }
  438. }
  439. }
  440. .skus {
  441. margin: 0 -0.5rem 1rem 0;
  442. .item {
  443. color: #666;
  444. font-size: 0.8125rem;
  445. padding: 8px 12px;
  446. border: 1px solid #dfdfdf;
  447. border-radius: 2px;
  448. display: inline-block;
  449. margin: 0 1em 0.75em 0;
  450. min-width: 64px;
  451. text-align: center;
  452. cursor: pointer;
  453. &.cur {
  454. color: $primary;
  455. border-color: $primary;
  456. }
  457. &.disabled {
  458. opacity: 0.6;
  459. cursor: not-allowed;
  460. }
  461. }
  462. }
  463. .page-nav {
  464. background: #fff;
  465. height: 54px;
  466. border: 1px solid #eaeaea;
  467. border-left: 0;
  468. border-right: 0;
  469. position: sticky;
  470. top: 52px;
  471. z-index: 9;
  472. .tabs {
  473. font-weight: 500;
  474. ul, a {
  475. border: 0;
  476. }
  477. a {
  478. color: $ink !important;
  479. height: 54px;
  480. }
  481. li.is-active {
  482. position: relative;
  483. &::after {
  484. content: '';
  485. position: absolute;
  486. bottom: 0;
  487. left: 24%;
  488. width: 52%;
  489. height: 3px;
  490. background: $primary;
  491. border-radius: 4px;
  492. }
  493. }
  494. }
  495. }
  496. .paper {
  497. padding: 1.5rem 0 3rem;
  498. }
  499. .details {
  500. padding-left: 0.5rem;
  501. padding-right: 0.5rem;
  502. }
  503. .main-cont {
  504. .caption {
  505. font-size: 1.25rem;
  506. font-weight: 500;
  507. margin: 2rem 0.5rem 1rem;
  508. &.bordered {
  509. border-top: 1px solid #eaeaea;
  510. padding-top: 2rem;
  511. }
  512. }
  513. }
  514. .side-cont {
  515. color: $ink;
  516. .caption {
  517. font-weight: 500;
  518. line-height: 1;
  519. padding: 0.75rem 0;
  520. &::before {
  521. content: '';
  522. background: $primary;
  523. width: 3px;
  524. height: 16px;
  525. border-radius: 4px;
  526. display: inline-block;
  527. margin-right: 10px;
  528. vertical-align: bottom;
  529. }
  530. }
  531. .rcmd-list {
  532. margin-bottom: 3rem;
  533. }
  534. }
  535. @media screen and (min-width: 768px) {
  536. .tabs li {
  537. margin-right: 2em;
  538. }
  539. .main-cont {
  540. padding-right: 1.5rem;
  541. }
  542. .side-cont {
  543. padding-left: 1rem;
  544. }
  545. .summary {
  546. .cover {
  547. margin-left: 1rem;
  548. }
  549. .title {
  550. margin-right: 2rem;
  551. }
  552. .info {
  553. margin-right: 4rem;
  554. }
  555. }
  556. }
  557. @media screen and (max-width: 768px) {
  558. .summary {
  559. padding: 88px 0 64px;
  560. .cover {
  561. width: 112px;
  562. height: 112px;
  563. border-radius: 28px;
  564. }
  565. }
  566. }
  567. }
  568. </style>