鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

433 lines
10 KiB

  1. <template>
  2. <view class="page__view">
  3. <view class="main">
  4. <navbar title="活动详情" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="transparent" />
  5. <view class="swiper">
  6. <uv-swiper
  7. :list="bannerList"
  8. keyName="image"
  9. indicator
  10. indicatorMode="dot"
  11. indicatorInactiveColor="rgba(255, 255, 255, 0.7)"
  12. height="680rpx"
  13. ></uv-swiper>
  14. </view>
  15. <view class="summary">
  16. <view class="card info">
  17. <view class="card-header">{{ detail.title }}</view>
  18. <view class="card-content">
  19. <view class="desc">{{ detail.brief }}</view>
  20. <view class="flex tags" v-if="tagList.length">
  21. <view class="tag" v-for="(tag, tIdx) in tagList" :key="tIdx">
  22. {{ tag }}
  23. </view>
  24. </view>
  25. <view class="flex data">
  26. <view class="flex price">
  27. <view class="price-val">
  28. <text>¥</text>
  29. <text class="highlight">{{ priceInt }}</text>
  30. <text>{{ `${priceFrac}` }}</text>
  31. </view>
  32. <view class="price-bef" v-if="detail.priceOrigin">¥<text>{{ detail.priceOrigin }}</text></view>
  33. </view>
  34. <view class="registered" v-if="detail.applyNum">
  35. {{ `${detail.applyNum}人已报名` }}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="card">
  41. <view class="card-header">选择团期</view>
  42. <view class="card-content">
  43. <timeOptionsSelect v-model="selectTime" :options="detail.dateList"></timeOptionsSelect>
  44. </view>
  45. </view>
  46. <view class="card comment">
  47. <view class="flex card-header">
  48. <view>评论</view>
  49. <button class="flex btn" @click="jumpToCommentRecords">
  50. <view>查看全部</view>
  51. <image class="img" src="@/static/image/icon-arrow-right.png" mode="widthFix"></image>
  52. </button>
  53. </view>
  54. <view class="card-content">
  55. <commentList :list="commentList"></commentList>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- <uv-sticky bgColor="#F3F3F3"> -->
  60. <view class="tabs">
  61. <uv-tabs
  62. :list="tabs"
  63. :scrollable="false"
  64. lineColor="#00A9FF"
  65. lineWidth="48rpx"
  66. lineHeight="4rpx"
  67. :activeStyle="{
  68. 'font-family': 'PingFang SC',
  69. 'font-weight': 500,
  70. 'font-size': '32rpx',
  71. 'line-height': 1.4,
  72. 'color': '#00A9FF',
  73. }"
  74. :inactiveStyle="{
  75. 'font-family': 'PingFang SC',
  76. 'font-weight': 400,
  77. 'font-size': '32rpx',
  78. 'line-height': 1.4,
  79. 'color': '#191919',
  80. }"
  81. @click="clickTabs"
  82. ></uv-tabs>
  83. </view>
  84. <!-- </uv-sticky> -->
  85. <view class="detail" v-if="displayContent">
  86. <uv-parse :content="displayContent"></uv-parse>
  87. </view>
  88. </view>
  89. <view class="flex bottom">
  90. <button plain class="flex flex-column btn btn-simple" open-type="contact">
  91. <image class="icon" src="@/pages_order/static/product/icon-service.png" mode="widthFix"></image>
  92. <view>客服</view>
  93. </button>
  94. <view class="flex operate">
  95. <button class="flex btn btn-palin" @click="onCollect">{{ isCollected ? '移除收藏' : '收藏' }}</button>
  96. <button class="flex btn btn-primary" @click="onBuy">立即购买</button>
  97. </view>
  98. </view>
  99. <orderInfoPopup ref="orderInfoPopup" :data="detail" @timeChange="selectTime = $event"></orderInfoPopup>
  100. </view>
  101. </template>
  102. <script>
  103. import timeOptionsSelect from '@/pages_order/order/orderConfirm/timeOptionsSelect.vue'
  104. import commentList from './commentList.vue'
  105. import orderInfoPopup from '@/pages_order/order/orderConfirm/infoPopup.vue'
  106. export default {
  107. components: {
  108. timeOptionsSelect,
  109. commentList,
  110. orderInfoPopup,
  111. },
  112. data() {
  113. return {
  114. id: null,
  115. detail: {},
  116. next: 'createOrder', // createOrder | addCart
  117. commentList: [],
  118. tabs: [
  119. { name: '行程亮点' },
  120. { name: '课程目标' },
  121. { name: '详细行程' },
  122. ],
  123. current: 0,
  124. selectTime: null,
  125. }
  126. },
  127. computed: {
  128. bannerList() {
  129. const { image } = this.detail
  130. if (!image) {
  131. return []
  132. }
  133. return Array.isArray(image) ? image : image.split(',')
  134. },
  135. tagList() {
  136. // todo: check key
  137. const { tagDetails } = this.detail || {}
  138. return tagDetails?.length ? tagDetails.split('、') : []
  139. },
  140. priceInt() {
  141. return Math.floor(this.detail.priceDiscount)
  142. },
  143. priceFrac() {
  144. let frac = this.detail.priceDiscount % this.priceInt
  145. return frac > 0 ? frac.toFixed(2).slice(1) : ''
  146. },
  147. displayContent() {
  148. const {
  149. special,
  150. target,
  151. process,
  152. } = this.detail
  153. if (this.current == 0) {
  154. return special
  155. } else if (this.current == 1) {
  156. return target
  157. } else if (this.current == 2) {
  158. return process
  159. }
  160. return ''
  161. },
  162. isCollected() {
  163. return this.detail.isCollection == '1'
  164. },
  165. },
  166. onLoad(arg) {
  167. const { id } = arg
  168. this.id = id
  169. this.fetchDetail(id)
  170. this.fetchComment(id)
  171. },
  172. methods: {
  173. async fetchDetail(activityId) {
  174. try {
  175. const result = await this.$fetch('queryActivityById', { activityId })
  176. this.detail = result
  177. } catch (err) {
  178. }
  179. },
  180. async fetchComment(activityId) {
  181. try {
  182. const queryParams = {
  183. pageNo: 1,
  184. pageSize: 2,
  185. activityId,
  186. }
  187. this.commentList = (await this.$fetch('queryCommentList', queryParams))?.records
  188. } catch (err) {
  189. console.log('fetchComment', err)
  190. }
  191. },
  192. async onCollect() {
  193. let succ = await this.$store.dispatch('collect', this.id)
  194. succ && this.fetchDetail(this.id)
  195. },
  196. onBuy() {
  197. this.$refs.orderInfoPopup.open({ selectTime: this.selectTime })
  198. },
  199. jumpToCommentRecords() {
  200. this.$utils.navigateTo(`/pages_order/comment/commentRecordsOfProduct?id=${this.id}`)
  201. },
  202. //点击tab栏
  203. clickTabs({ index }) {
  204. this.current = index
  205. },
  206. },
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. .page__view {
  211. width: 100vw;
  212. min-height: 100vh;
  213. background: linear-gradient(#DAF3FF, #F3F3F3 500rpx, #F3F3F3);
  214. position: relative;
  215. }
  216. .main {
  217. width: 100vw;
  218. // padding: calc(var(--status-bar-height) + 120rpx) 0 198rpx 0;
  219. padding-bottom: 198rpx;
  220. box-sizing: border-box;
  221. }
  222. .swiper {
  223. /deep/ .uv-swiper-indicator__wrapper__dot,
  224. /deep/ .uv-swiper-indicator__wrapper__dot--active {
  225. width: 30rpx;
  226. }
  227. /deep/ .uv-swiper-indicator__wrapper__dot--active {
  228. background: linear-gradient(to right, #21FEEC, #019AF9);
  229. }
  230. }
  231. .summary {
  232. width: 100%;
  233. padding: 40rpx 32rpx;
  234. box-sizing: border-box;
  235. }
  236. .card {
  237. width: 100%;
  238. padding: 32rpx;
  239. box-sizing: border-box;
  240. background: #FFFFFF;
  241. border-radius: 24rpx;
  242. & + & {
  243. margin-top: 40rpx;
  244. }
  245. &-header {
  246. font-family: PingFang SC;
  247. font-weight: 500;
  248. font-size: 32rpx;
  249. line-height: 1.4;
  250. color: #181818;
  251. }
  252. &-content {
  253. margin-top: 16rpx;
  254. }
  255. &.info {
  256. .desc {
  257. font-size: 26rpx;
  258. white-space: pre-wrap;
  259. color: #8B8B8B;
  260. }
  261. .tags {
  262. margin-top: 16rpx;
  263. justify-content: flex-start;
  264. flex-wrap: wrap;
  265. gap: 16rpx;
  266. .tag {
  267. padding: 2rpx 14rpx;
  268. font-family: PingFang SC;
  269. font-weight: 400;
  270. font-size: 24rpx;
  271. line-height: 1.4;
  272. color: #00A9FF;
  273. background: #E9F8FF;
  274. border: 2rpx solid #00A9FF;
  275. border-radius: 8rpx;
  276. }
  277. }
  278. .data {
  279. margin-top: 16rpx;
  280. justify-content: space-between;
  281. }
  282. .price {
  283. justify-content: flex-start;
  284. align-items: baseline;
  285. column-gap: 6rpx;
  286. &-val {
  287. font-size: 24rpx;
  288. font-weight: 500;
  289. color: #FF4800;
  290. .highlight {
  291. font-size: 48rpx;
  292. }
  293. }
  294. &-bef {
  295. text-decoration: line-through;
  296. font-size: 24rpx;
  297. color: #8B8B8B;
  298. }
  299. }
  300. .registered {
  301. padding: 2rpx 10rpx;
  302. font-weight: 500;
  303. font-size: 30rpx;
  304. color: #FF4800;
  305. border: 2rpx solid #FF4800;
  306. border-radius: 4rpx;
  307. }
  308. }
  309. &.comment {
  310. .card-header {
  311. justify-content: space-between;
  312. }
  313. .btn {
  314. column-gap: 4rpx;
  315. font-size: 24rpx;
  316. color: #8B8B8B;
  317. .img {
  318. width: 32rpx;
  319. height: auto;
  320. }
  321. }
  322. }
  323. }
  324. .detail {
  325. // font-size: 0;
  326. }
  327. .bottom {
  328. position: fixed;
  329. left: 0;
  330. bottom: 0;
  331. z-index: 999;
  332. justify-content: space-between;
  333. column-gap: 16rpx;
  334. width: 100vw;
  335. // height: 198rpx;
  336. padding: 24rpx 40rpx 0 40rpx;
  337. padding-bottom: calc(env(safe-area-inset-bottom) + 24rpx);
  338. background: #FFFFFF;
  339. box-sizing: border-box;
  340. .btn-simple {
  341. border: none;
  342. font-family: PingFang SC;
  343. font-weight: 400;
  344. font-size: 22rpx;
  345. line-height: 1.1;
  346. color: #999999;
  347. .icon {
  348. width: 52rpx;
  349. height: auto;
  350. margin-bottom: 4rpx;
  351. }
  352. }
  353. .operate {
  354. justify-content: flex-end;
  355. column-gap: 16rpx;
  356. .btn {
  357. font-size: 36rpx;
  358. font-weight: 500;
  359. border-radius: 41rpx;
  360. line-height: 1.4;
  361. &-palin {
  362. padding: 14rpx 46rpx;
  363. color: #252545;
  364. border: 2rpx solid #252545;
  365. }
  366. &-primary {
  367. padding: 14rpx 62rpx;
  368. color: #FFFFFF;
  369. background: linear-gradient(to right, #21FEEC, #019AF9);
  370. border: 2rpx solid #00A9FF;
  371. }
  372. }
  373. }
  374. }
  375. </style>