details.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <template>
  2. <view class="details">
  3. <view class="top"></view>
  4. <view class="head">
  5. <view class="head_left">
  6. <span class="cuIcon-back" @click="back"></span>
  7. </view>
  8. <view class="case">
  9. 商品详情
  10. </view>
  11. </view>
  12. <view class="center">
  13. <view class="box">
  14. <view class="title">
  15. 商品信息
  16. </view>
  17. <view class="data">
  18. <span class="span">商品名称</span>{{ form.productName }}
  19. </view>
  20. <view class="data">
  21. <span class="span">商品分类</span>{{ form.productCategory }}
  22. </view>
  23. <view class="data">
  24. <span class="span">商品分组</span>{{ form.groupingName }}
  25. </view>
  26. <view class="img_box">
  27. <span class="line">商品封面图</span>
  28. <view class="img_list">
  29. <view v-for="(val, index) in fmImageList" :key="index">
  30. <view class="img">
  31. <image :src="val.url" mode=""
  32. style="width: 140rpx;height:140rpx;border-radius: 4px; border: 1px solid #ebecee;margin-right:20rpx;margin-bottom:10rpx">
  33. </image>
  34. </view>
  35. <!-- <image v-for="(val, index) in fmImageList" :key="index" :src="form.productImage" mode=""></image> -->
  36. </view>
  37. </view>
  38. </view>
  39. <view class="img_box">
  40. <span class="line">主图视频</span>
  41. <view class="item upload">
  42. <view class="customize">
  43. <view class="business-img">
  44. <view class="uni-uploader__file">
  45. <view class="uploader_video" v-if="form.video">
  46. <video :src="form.video" class="video-container"></video>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="img_box">
  54. <span class="line">商品详情页</span>
  55. <view class="img_list" v-if="detailImages">
  56. <view class="img" v-for="(item, index) in detailImages" :key="index">
  57. <image :src="item" mode=""></image>
  58. </view>
  59. </view>
  60. <view class="item" v-if="form.richText">
  61. <!-- 使用Editor组件代替rich-text -->
  62. <Editor :readOnly="true" :toolbarConfig="toolbarConfig" @init="onEditorInit" />
  63. </view>
  64. <!-- <view class="item" v-if="form.richText">
  65. <rich-text :nodes="form.richText"></rich-text>
  66. </view> -->
  67. </view>
  68. <view class="data">
  69. <span class="span">搜索关键字</span>{{ form.searchKeywords }}
  70. </view>
  71. <!-- <view class="data" v-if="form.categoryId != '1945013773786701826'">
  72. <span class="span">原价</span>{{ form.price }}
  73. </view>
  74. <view class="data" v-if="form.categoryId != '1945013773786701826'">
  75. <span class="span">实际售价</span>{{ form.soldPrice }}
  76. </view> -->
  77. <!--
  78. <view class="particulars" v-if="form.categoryId != '1945013773786701826'">
  79. 组合套餐
  80. <view class="content">
  81. <view class="item" v-for="(item, index) in form.productGroups" :key="item.groupId">
  82. <view class="item_title">
  83. {{ item.groupName }}
  84. </view>
  85. <view class="item_row" v-for="(row, index) in item.singleProduct" :key="index">
  86. <view class="name">{{ row.productName }} </view>
  87. <view class="price">
  88. {{ row.quantity }}{{ row.unit }}/{{ row.price }}元
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view> -->
  94. </view>
  95. <!-- <view class="box" v-if="form.categoryId == '1945013773786701826'">
  96. <view class="span">
  97. 商品规格
  98. </view>
  99. <view class="spec">
  100. <view class="spec_item" v-for="(item, index) in specItems" :key="item.id">
  101. <view class="name">
  102. {{ item.partName }} {{ item.positionName }} {{ item.craftName }}
  103. </view>
  104. <view class="price">
  105. 原价<span>{{ item.price }}</span>参考售价 <span>{{ item.soldPrice }}</span>
  106. </view>
  107. </view>
  108. </view>
  109. </view> -->
  110. <view class="box rule">
  111. <view class="title">
  112. 销售信息
  113. </view>
  114. <view class="data">
  115. <span class="span">商品售价</span>{{ form.price }}元
  116. </view>
  117. <view class="data">
  118. <span class="span">商品市场价</span>{{ form.soldPrice }}元
  119. </view>
  120. <view class="data">
  121. <span class="span">虚拟销量</span>{{ form.virtualSales }}
  122. </view>
  123. <view>
  124. <view class="data">
  125. <span class="span">售卖时间</span>
  126. <span v-if="form.sellingTimeType == '1'">不限制</span>
  127. <span v-if="form.sellingTimeType == '2'">每天</span>
  128. <span v-if="form.sellingTimeType == '3'">每周</span>
  129. </view>
  130. <!-- 每天售卖时间 -->
  131. <view class="card_data" v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0">
  132. <uni-card :is-shadow="false" is-full style="border:1rpx solid #E5E5E5;">
  133. <view v-for="item, index in form.sellingDay" :key="index" style="display: flex; justify-content: center;">
  134. <view>{{ item[0] }}</view>
  135. </view>
  136. </uni-card>
  137. </view>
  138. <view class="card_data" v-show="form.sellingTimeType == '3'">
  139. <!-- 每周售卖时间 -->
  140. <uni-table v-show="form.sellingTimeType == '3'">
  141. <!-- 表头 -->
  142. <uni-tr class="table-header">
  143. <uni-th width="200rpx" align="left"><u-checkbox disabled></u-checkbox>工作日</uni-th>
  144. <uni-th align="center">时间</uni-th>
  145. </uni-tr>
  146. <!-- 数据行 -->
  147. <uni-tr v-for="(item, index) in form.localProductSellingWeeks" :key="index" class="table-row">
  148. <uni-td width="200rpx" align="left">
  149. <u-checkbox v-model="item.checked" @change="handleItemCheckChange($event, item, index)"
  150. disabled></u-checkbox>{{
  151. item.weekDay }}
  152. </uni-td>
  153. <uni-td align="center">
  154. <view v-for="(date, timeIndex) in item.sellingStartTimeList" :key="timeIndex" class="item_weekTime">
  155. <span>{{ date[0] }}</span>
  156. <!-- <span>{{ date[0] ? date[0] + '-' + date[1] : '' }}</span> -->
  157. </view>
  158. </uni-td>
  159. </uni-tr>
  160. </uni-table>
  161. </view>
  162. </view>
  163. <!-- <view class="data">
  164. <span class="span">库存</span>{{ form.stockQuantity }}
  165. </view> -->
  166. <view class="data">
  167. <span class="span">可用时间</span>
  168. <view v-if="form.useType == '3'">
  169. 长期有效
  170. </view>
  171. <view class="" v-if="form.useType == '1' && form.expirationDays">
  172. 购买后{{ form.expirationDays }}天失效
  173. </view>
  174. <view class="" v-if="form.useType == '2' && form.availableStartDate">
  175. {{ form.availableStartDate.slice(0, 10) }} — {{ form.availableEndDate.slice(0, 10) }}
  176. </view>
  177. </view>
  178. <view class="data">
  179. <span class="span">预约规则</span>{{ form.preBook == 0 ? '不需要预约' : '用户需要提前预约' }}
  180. </view>
  181. <view class="data">
  182. <span class="span">服务说明</span>
  183. <view v-for="(item, index) in form.serviceDescription" :key="index">
  184. <span class="span">{{ index + 1 + '.' + item }}</span>
  185. </view>
  186. </view>
  187. <!-- <view class="data">
  188. <span class="span">退款规则 </span>
  189. <view class="ruler">
  190. <view class="item">
  191. {{ form.refundLabelName }}
  192. </view>
  193. <view class="item">
  194. {{ form.refundConfirmName }}
  195. </view>
  196. </view>
  197. </view> -->
  198. <!-- <view class="img_box">
  199. <span class="line">使用说明</span>
  200. <view class="text_area">
  201. {{ form.instructions }}
  202. </view>
  203. </view> -->
  204. </view>
  205. </view>
  206. </view>
  207. </template>
  208. <script>
  209. import Editor from '@/uni_modules/sp-editor/components/sp-editor/sp-editor.vue';
  210. export default {
  211. components: {
  212. Editor
  213. },
  214. data() {
  215. return {
  216. form: {},
  217. detailImages: [],
  218. oldPrice: 300,
  219. price: 280,
  220. ruleList: [],
  221. productId: '',
  222. imageHttp: 'http://192.168.0.36:8080/jeecg-boot/',
  223. specItems: [],
  224. fmImageList: [],
  225. // 编辑器配置
  226. toolbarConfig: {
  227. keys: [], // 只读模式下不显示工具栏
  228. excludeKeys: []
  229. },
  230. editorCtx: null, // 编辑器上下文
  231. editorId: null, // 编辑器ID
  232. // 为"每周"选项添加单独的时间段数组
  233. localProductSellingWeeks: [
  234. {
  235. weekDay: '周一',
  236. sellingStartTimeList: [],
  237. checked: false
  238. },
  239. {
  240. weekDay: '周二',
  241. sellingStartTimeList: [],
  242. checked: false
  243. },
  244. {
  245. weekDay: '周三',
  246. sellingStartTimeList: [],
  247. checked: false
  248. },
  249. {
  250. weekDay: '周四',
  251. sellingStartTimeList: [],
  252. checked: false
  253. },
  254. {
  255. weekDay: '周五',
  256. sellingStartTimeList: [],
  257. checked: false
  258. },
  259. {
  260. weekDay: '周六',
  261. sellingStartTimeList: [],
  262. checked: false
  263. },
  264. {
  265. weekDay: '周日',
  266. sellingStartTimeList: [],
  267. checked: false
  268. }
  269. ]
  270. }
  271. },
  272. methods: {
  273. //返回
  274. back() {
  275. uni.navigateBack({
  276. delta: 1
  277. });
  278. },
  279. // 编辑器初始化完成时触发
  280. onEditorInit(editorCtx, editorId) {
  281. this.editorCtx = editorCtx // 保存编辑器上下文
  282. this.editorId = editorId // 保存编辑器ID
  283. console.log('编辑器初始化完成')
  284. // 初始化编辑器内容
  285. if (this.form.richText) {
  286. this.editorCtx.setContents({
  287. html: this.form.richText
  288. })
  289. }
  290. }
  291. },
  292. onLoad(options) {
  293. this.productId = options.productId
  294. this.$http.post("/app/product/queryByIdNew", {
  295. id: this.productId,
  296. isApp: '1'
  297. }).then(res => {
  298. if (res.data.code == 200) {
  299. this.form = res.data.result
  300. console.log(this.form)
  301. if (res.data.result.detailImages) {
  302. this.detailImages = res.data.result.detailImages.split(',')
  303. }
  304. this.form.groupingName = res.data.result.groupingName || ''
  305. this.form.serviceDescription = res.data.result.serviceDescription || []
  306. if (!res.data.result.sellingDay) {
  307. this.form.sellingDay = []
  308. }
  309. if (!res.data.result.localProductSellingWeeks) {
  310. this.form.localProductSellingWeeks = this.localProductSellingWeeks
  311. }
  312. // 处理封面图,支持多张图片
  313. if (res.data.result.productImage) {
  314. let productImages = res.data.result.productImage.split(',');
  315. productImages.forEach(imageUrl => {
  316. if (imageUrl.trim()) { // 过滤空字符串
  317. this.fmImageList.push({
  318. url: imageUrl
  319. });
  320. }
  321. });
  322. }
  323. if (this.form.specItems) {
  324. this.form.specItems.forEach(item => {
  325. if (item.replaced) {
  326. this.specItems.push(item)
  327. }
  328. })
  329. }
  330. console.log(this.specItems)
  331. }
  332. })
  333. },
  334. onUnload() {
  335. // 页面销毁前清空Storage中的'smdate'
  336. uni.removeStorage({
  337. key: 'smdate'
  338. });
  339. }
  340. }
  341. </script>
  342. <style lang="scss" scoped>
  343. .details {
  344. width: 100vw;
  345. height: 100vh;
  346. display: flex;
  347. flex-direction: column;
  348. overflow: hidden;
  349. background: #F7F8FC;
  350. /*#ifdef APP-PLUS*/
  351. .top {
  352. width: 100%;
  353. height: var(--status-bar-height);
  354. background-color: #fff;
  355. }
  356. /*#endif*/
  357. .head {
  358. width: 100%;
  359. padding: 20rpx;
  360. background-color: #fff;
  361. display: flex;
  362. justify-content: space-between;
  363. align-items: center;
  364. position: relative;
  365. .head_left {
  366. font-size: 40rpx;
  367. }
  368. .case {
  369. position: absolute;
  370. left: 50%;
  371. top: 50%;
  372. transform: translate(-50%, -50%);
  373. font-size: 36rpx;
  374. font-weight: 600;
  375. }
  376. }
  377. .center {
  378. flex: 1;
  379. overflow-y: auto;
  380. padding: 21rpx 24rpx;
  381. .box {
  382. width: 100%;
  383. padding: 16rpx;
  384. background-color: #fff;
  385. border-radius: 16rpx;
  386. .spec {
  387. background: #FBFCFF;
  388. border-radius: 8rpx;
  389. padding: 16rpx;
  390. margin-top: 16rpx;
  391. .spec_item {
  392. margin-bottom: 32rpx;
  393. .name {
  394. font-size: 28rpx;
  395. margin-bottom: 16rpx;
  396. }
  397. .price {
  398. font-size: 26rpx;
  399. color: #666666;
  400. span {
  401. color: #333333;
  402. margin-left: 20rpx;
  403. margin-right: 30rpx;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. }
  410. .title {
  411. width: 100%;
  412. font-weight: 600;
  413. margin-bottom: 32rpx;
  414. }
  415. .card_data {
  416. border-bottom: 1px solid #EEEEEE;
  417. padding-bottom: 16rpx;
  418. }
  419. .data {
  420. min-height: 58rpx;
  421. display: flex;
  422. align-items: center;
  423. border-bottom: 1px solid #EEEEEE;
  424. padding-bottom: 16rpx;
  425. margin-top: 16rpx;
  426. font-size: 28rpx;
  427. .span {
  428. display: inline-block;
  429. margin-right: 20rpx;
  430. min-width: 112rpx;
  431. font-size: 28rpx;
  432. color: #666666;
  433. }
  434. .ruler {
  435. display: flex;
  436. align-items: center;
  437. .item {
  438. width: auto;
  439. height: 44rpx;
  440. padding: 0rpx 16rpx;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. line-height: 28rpx;
  445. color: #2983EC;
  446. background: rgba(68, 154, 255, 0.1);
  447. border-radius: 4rpx;
  448. border: 1px solid #449AFF;
  449. margin-right: 20rpx;
  450. }
  451. }
  452. }
  453. .img_box {
  454. border-bottom: 1px solid #EEEEEE;
  455. padding-bottom: 16rpx;
  456. .line {
  457. display: block;
  458. font-size: 28rpx;
  459. color: #666666;
  460. margin: 16rpx 0px;
  461. }
  462. .img_list {
  463. display: flex;
  464. flex-wrap: wrap;
  465. justify-content: start;
  466. // gap: 27rpx;
  467. .img {
  468. flex: 0 0 calc(25% - 27rpx);
  469. height: 140rpx;
  470. border-radius: 12rpx;
  471. overflow: hidden;
  472. margin-bottom: 25rpx;
  473. image {
  474. width: 140rpx;
  475. height: 140rpx;
  476. }
  477. }
  478. }
  479. }
  480. .particulars {
  481. width: 100%;
  482. margin-top: 20rpx;
  483. .content {
  484. width: 100%;
  485. padding: 20rpx;
  486. background: #F7F8FC;
  487. border-radius: 8rpx;
  488. margin-top: 16rpx;
  489. padding-top: 0px;
  490. overflow: hidden;
  491. .item {
  492. margin-top: 16rpx;
  493. .item_title {
  494. font-weight: 600;
  495. font-size: 26rpx;
  496. }
  497. .item_row {
  498. width: 100%;
  499. .name {
  500. font-size: 26rpx;
  501. margin-top: 16rpx;
  502. margin-bottom: 4rpx;
  503. color: #333333;
  504. line-height: 30rpx;
  505. }
  506. .price {
  507. font-size: 24rpx;
  508. color: #888888;
  509. line-height: 28rpx;
  510. }
  511. }
  512. }
  513. .hint {
  514. border-bottom: 1px solid #ccc;
  515. }
  516. }
  517. }
  518. .rule {
  519. width: 100%;
  520. background-color: #fff;
  521. padding: 20rpx;
  522. margin-top: 20rpx;
  523. .headline {
  524. font-weight: 600;
  525. }
  526. .rule_item {
  527. display: flex;
  528. margin-top: 20rpx;
  529. .item {
  530. padding: 10rpx 20rpx;
  531. border: 1px solid #ccc;
  532. margin-right: 20rpx;
  533. }
  534. }
  535. }
  536. .banner {
  537. width: 95%;
  538. margin: 20rpx auto;
  539. image {
  540. width: 100%;
  541. }
  542. }
  543. .edit {
  544. width: 100%;
  545. height: 80rpx;
  546. background-color: #fff;
  547. display: flex;
  548. justify-content: center;
  549. align-items: center;
  550. span {
  551. display: block;
  552. width: 200rpx;
  553. height: 60rpx;
  554. border: 1px solid #ccc;
  555. display: flex;
  556. justify-content: center;
  557. align-items: center;
  558. }
  559. }
  560. }
  561. // video_style
  562. .customize {
  563. margin-bottom: 16rpx;
  564. background-color: #ffffff;
  565. border-radius: 16rpx;
  566. .business-img {
  567. height: 210upx;
  568. width: 310upx;
  569. background-size: cover;
  570. image {
  571. width: 100%;
  572. height: 100%;
  573. }
  574. }
  575. .uploader_video {
  576. width: 310upx;
  577. height: 210upx;
  578. }
  579. .video-container {
  580. max-width: 100%;
  581. /* 最大宽度为父容器宽度 */
  582. max-height: 100%;
  583. ::v-deep.uni-video-bar {
  584. height: 62upx;
  585. padding: 0
  586. }
  587. }
  588. }
  589. .uni-uploader__file,
  590. .uploader_video {
  591. position: relative;
  592. z-index: 1;
  593. width: 200upx;
  594. height: 200upx;
  595. }
  596. ::v-deep .editor-container {
  597. height: 260rpx;
  598. }
  599. </style>