details.vue 14 KB

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