_id.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div :class="mobile ? 'mobileMain' : ''">
  3. <div class="consult-detail-wrapper" v-if="!mobile">
  4. 咨询服务详情 web
  5. </div>
  6. <div class="consult-detail-wrapper-mobile" v-else>
  7. <div class="consult-title">{{ consultDetail.title }}</div>
  8. <div class="consult-content">{{ consultDetail.content }}</div>
  9. <div class="consult-image" v-if="consultDetail.coverImage">
  10. <img :src="consultDetail.coverImage" alt="consult image">
  11. </div>
  12. <div class="pay-wrapper">
  13. <div class="price-info">
  14. <div class="price-text">¥{{ consultDetail.price }}</div>
  15. <span>支付金额</span>
  16. </div>
  17. <!-- <el-button
  18. v-if="Number(skillDetail.is_buy) > 0"
  19. class="pay-btn"
  20. disabled>已购买</el-button> -->
  21. <el-button
  22. class="pay-btn"
  23. @click="handleClickPay">一键约聊</el-button>
  24. </div>
  25. </div>
  26. <!-- 约聊时间选择 modal -->
  27. <el-drawer
  28. :visible.sync="isShowSelectTimeDialog"
  29. direction="btt"
  30. size="380px">
  31. <div class="time-dialog-title" slot="title">选择预约时间</div>
  32. <div class="time-dialog-content">
  33. <div class="date-wrapper">
  34. <div class="title">日期</div>
  35. <div class="date-list-wrapper">
  36. <div
  37. class="date-item"
  38. :class="currentDateIndex === index ? 'active' : ''"
  39. v-for="(item, index) in orderTime"
  40. :key="index"
  41. @click="handleClickDialogDate(index)">
  42. {{ item.date }}
  43. </div>
  44. </div>
  45. </div>
  46. <div class="time-wrapper">
  47. <div class="title">时间</div>
  48. <div class="time-list-wrapper">
  49. <div
  50. class="time-list-item"
  51. v-show="currentDateIndex === index"
  52. v-for="(item, index) in orderTime"
  53. :key="`time-${index}`">
  54. <!-- empty info -->
  55. <div class="time-empty" v-if="item.time.length === 1 && item.time[0].date === '00:00'">
  56. 当前日期无服务
  57. </div>
  58. <template v-else>
  59. <div
  60. class="time-item"
  61. :class="selectedOrderTime === timeItem.value ? 'active' : ''"
  62. v-for="timeItem in item.time"
  63. :key="timeItem.value"
  64. @click="handleClickDialogTime(timeItem.value)">
  65. {{ timeItem.date }}
  66. </div>
  67. </template>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="action-wrapper">
  72. <el-button
  73. class="confirm-btn"
  74. @click="handleClickDialogConfirm">确认</el-button>
  75. </div>
  76. </div>
  77. </el-drawer>
  78. <!-- <el-dialog
  79. :visible.sync="isShowSelectTimeDialog"
  80. width="90vw"
  81. @close="handleSelectTimeDialogClose">
  82. </el-dialog> -->
  83. </div>
  84. </template>
  85. <script>
  86. import {mapState} from "vuex"
  87. import qs from "qs"
  88. export default {
  89. name: 'SeoConsultDetail',
  90. data () {
  91. return {
  92. baseUrl: '',
  93. isWeixinApp: true,
  94. // 是否展示约聊时间 dialog
  95. isShowSelectTimeDialog: false,
  96. // 约聊可选时间
  97. orderTime: [],
  98. // 约聊选择的时间
  99. selectedOrderTime: '',
  100. // dialog 当前选中的日期索引
  101. currentDateIndex: 0
  102. }
  103. },
  104. head () {
  105. const {
  106. title = "",
  107. keyword = "",
  108. description = "",
  109. h1 = "",
  110. canonical = "",
  111. metaLocation
  112. } = this.head || {}
  113. let obj = {
  114. title: title,
  115. meta: [{
  116. name: "keywords",
  117. content: keyword
  118. }, {
  119. name: "description",
  120. content: description
  121. }, {
  122. name: "h1",
  123. content: h1
  124. }, {
  125. name: "viewport",
  126. content: "width=device-width, initial-scale=1.0, viewport-fit=cover"
  127. }],
  128. link: [{rel: "canonical", href: canonical}]
  129. }
  130. if (metaLocation) {
  131. obj.meta.push({name: "location", content: metaLocation})
  132. }
  133. return obj
  134. },
  135. computed: {
  136. ...mapState(["deviceType"])
  137. },
  138. async asyncData ({ $axios, params, req, app }) {
  139. const saleId = params.id || ''
  140. let consultDetail = {}
  141. let res = await $axios.$post('/api/sale/saleInfo', { sale_id: saleId })
  142. if (Number(res.status) === 1) {
  143. consultDetail = res.data
  144. }
  145. let imageList = consultDetail.image.split(',')
  146. consultDetail.coverImage = imageList[0] || ''
  147. const head = {
  148. title: '咨询服务详情'
  149. }
  150. return {
  151. saleId,
  152. consultDetail,
  153. mobile: app.$deviceType.isMobile(),
  154. head
  155. }
  156. },
  157. mounted () {
  158. this.baseUrl = this.$store.state.domainConfig.siteUrl
  159. this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
  160. },
  161. methods: {
  162. /**
  163. * 获取约聊可选时间
  164. */
  165. _getConsultTime () {
  166. const self = this
  167. const data = {
  168. sale_id: this.saleId
  169. }
  170. this.$axios.$post('/api/sale/time', data).then(res => {
  171. if (Number(res.status) === 1) {
  172. // 可约聊时间
  173. let orderTime = res.data.list || []
  174. // 为约聊的时间增加下单所需 value
  175. orderTime.forEach((item) => {
  176. item.time.forEach(dateItem => {
  177. dateItem.value = `${item.ymd} ${dateItem.date}`
  178. })
  179. })
  180. if (orderTime[0].time &&
  181. orderTime[0].time.length > 1 &&
  182. orderTime[0].time[0].date !== '00:00') {
  183. self.selectedOrderTime = orderTime[0].time[0].value
  184. }
  185. self.orderTime = orderTime
  186. self.isShowSelectTimeDialog = true
  187. }
  188. })
  189. },
  190. /**
  191. * 点击一键约聊
  192. */
  193. handleClickPay () {
  194. if (!this.userinfo || !this.userinfo.nickname) {
  195. location.href = "proginn://login?backToPage=true";
  196. return
  197. }
  198. if (this.orderTime && this.orderTime.length) {
  199. this.isShowSelectTimeDialog = true
  200. } else {
  201. this._getConsultTime()
  202. }
  203. },
  204. /**
  205. * 点击约聊 modal 的日期
  206. * @param {Number} index - 日期索引
  207. */
  208. handleClickDialogDate (index) {
  209. if (this.currentDateIndex !== index) {
  210. this.currentDateIndex = index
  211. }
  212. },
  213. /**
  214. * 点击约聊 modal 的时间
  215. * @param {String} value - 选择的值
  216. */
  217. handleClickDialogTime (value) {
  218. this.selectedOrderTime = value
  219. },
  220. /**
  221. * 点击约聊 modal 的确定
  222. */
  223. handleClickDialogConfirm () {
  224. // this.$message.info('稍微校验数据,然后直接跳转支付')
  225. if (!this.selectedOrderTime) {
  226. this.$message.error('请选择预约时间')
  227. return
  228. }
  229. const query = {
  230. product_type: 503,
  231. product_id: this.saleId,
  232. obj: this.selectedOrderTime,
  233. next: location.href
  234. }
  235. if (!this.userinfo || !this.userinfo.nickname) {
  236. location.href = "proginn://login?backToPage=true";
  237. } else {
  238. location.href = "proginn://pay?" + qs.stringify(query)
  239. }
  240. this.isShowSelectTimeDialog = false
  241. },
  242. /**
  243. * 点击约聊 modal 的取消
  244. */
  245. // handleClickDialogCancel () {
  246. // this.isShowSelectTimeDialog = false
  247. // },
  248. /**
  249. * 约聊时间选择 modal 关闭时
  250. */
  251. // handleSelectTimeDialogClose () {
  252. // }
  253. }
  254. }
  255. </script>
  256. <style lang="scss" scoped>
  257. @import "@/assets/css/consult/detail/_id.scss";
  258. </style>
  259. <style lang="scss">
  260. .wx-header-custom-detail {
  261. position: relative !important;
  262. }
  263. </style>