123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <view class="main">
- <view class="one" v-if="info.file.length>0">
- <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
- indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
- <swiper-item class="list" v-for="(item,index) in info.file" :key="index">
- <image class="image" :src="item.url" mode="">
- </image>
- </swiper-item>
- </swiper>
- </view>
- <view class="bottom">
- <view class="two">
- <view class="name">{{info.name||'暂无'}}</view>
- </view>
- <view class="thr">
- <view class="thr_1">
- <view class="left">价格:</view>
- <view class="right"><text class="text_1" :user-select='true'>¥{{info.money||'暂无'}}</text></view>
- </view>
- <view class="thr_1">
- <view class="left">数量:</view>
- <view class="right">
- <text v-if="info.num==0">售罄</text>
- <text v-else>{{info.num||'暂无'}} 间</text>
- </view>
- </view>
- </view>
- <view class="four">
- <view class="four_1">简介</view>
- <rich-text :nodes="formatRichText(info.brief)"></rich-text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id: '',
- user: {},
- info: {
- file: []
- },
- // 字典表
- typeList: []
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- await that.searchOther();
- await that.search();
- },
- onShow: async function(e) {
- const that = this;
- that.searchToken();
- },
- methods: {
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) that.$set(that, `user`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- async search() {
- const that = this;
- if (that.id) {
- const res = await that.$api(`/room/${that.id}`, 'GET', {})
- if (res.errcode == '0') {
- const type = that.typeList.find(i => i.value == res.data.type)
- if (type) res.data.zhType = type.label
- that.$set(that, `info`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- }
- },
- // 处理富文本
- formatRichText(html) {
- if (html) {
- // 富文本内容格式化
- return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
- // 查找所有的 img 元素
- return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
- '')
- // 删除找到的所有 img 元素中的 style 属性
- }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
- }
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- // 查询类型
- res = await that.$api(`/dictData`, 'GET', {
- type: 'project_type',
- is_use: '0',
- })
- if (res.errcode == '0') that.$set(that, `typeList`, res.data);
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- .one {
- .swiper {
- height: 70vw;
- .list {
- .image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .bottom {
- position: absolute;
- top: 65vw;
- left: 0;
- right: 0;
- background-color: var(--mainColor);
- border-radius: 20px;
- padding: 2vw 0 0 0;
- .two {
- padding: 4vw 2vw;
- .name {
- padding: 1vw 0;
- font-weight: bold;
- font-size: var(--font16Size);
- }
- .two_2 {
- color: var(--f85Color);
- font-size: var(--font12Size);
- }
- }
- .thr {
- padding: 0 2vw;
- .thr_1 {
- display: flex;
- font-size: var(--font14Size);
- padding: 0 0 1vw 0;
- .left {
- padding: 0 1vw 0 0;
- font-weight: bold;
- }
- .right {
- color: var(--f85Color);
- .text_1 {
- font-size: var(--font14Size);
- color: var(--fF0Color);
- }
- }
- }
- }
- .four {
- padding: 2vw;
- .four_1 {
- font-weight: bold;
- font-size: var(--font16Size);
- padding: 0 0 1vw 0;
- }
- }
- }
- }
- </style>
|