123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <template>
- <mobile-frame>
- <view class="main">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="one">
- <rich-text :nodes="info.content&&info.content.value"></rich-text>
- </view>
- <view class="two">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
- <view class="img">
- <image class="image" :src="item.file&&item.file.length?item.file[0].url:''" mode="">
- </image>
- </view>
- <view class="name textOver">
- <text>{{item.goods_name}}</text>
- </view>
- <view class="money">
- <view class="money_1">
- <text>{{item.platform_act_type=='3'?'特价¥':'¥'}}</text><text>{{item.platform_act_type=='3'?item.config&&item.config.sp_price:item.sell_money}}</text>
- </view>
- <view class="money_2">
- <text>¥</text><text>{{item.flow_money||0}}</text>
- </view>
- </view>
- <view class="acttags">
- <text v-for="(i,indexx) in item.act_tags" :key="indexx">{{i.label}}</text>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- // 系统设置
- config: {},
- id: '',
- // 详情
- info: {},
- // 商品列表
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e.id || '');
- that.searchConfig();
- await that.searchAct();
- await that.configShare();
- },
- onUnload: function() {
- // 页面卸载,重新部署分享内容
- const that = this;
- if (that.config) {
- // 赋值默认值
- that.$config.share = {
- title: that.config.title,
- path: '/pages/index/index',
- imageUrl: that.config.config.share[0].url
- }
- }
- },
- methods: {
- // 查询基本设置
- searchConfig() {
- const that = this;
- uni.getStorage({
- key: 'config',
- success: function(res) {
- if (res.data) that.$set(that, `config`, res.data)
- },
- fail: function(err) {
- console.log(err);
- }
- })
- },
- async searchAct() {
- const that = this;
- // 查询详情
- let res = await that.$api(`/platformAct/${that.id}`, 'GET');
- if (res.errcode == '0') {
- uni.setNavigationBarTitle({
- title: res.data.act_time.title
- });
- if (res.data.content.value) res.data.content.value = res.data.content.value.replace(/\<img/gi,
- '<img class="rich-img"');
- that.$set(that, `info`, res.data);
- that.search()
- }
- },
- async search() {
- const that = this;
- // 查询商品列表
- let info = {
- skip: that.skip,
- limit: that.limit,
- platform_act: that.id,
- status: '0',
- goods_status: '1'
- }
- let res = await that.$api(`/goodsJoinAct`, 'GET', {
- ...info,
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list)
- that.$set(that, `total`, res.total)
- }
- },
- toPage() {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.search();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 购买
- toBuy(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${e.goods}`
- })
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- // 配置分享内容
- configShare() {
- const that = this;
- let info = that.info;
- let imageUrl = that.config?.config?.logo[0].url;
- if (info.share.length > 0) imageUrl = info.share[0].url;
- that.$config.share = {
- title: info.act_time.title,
- path: `/pagesRest/activity/info?id=${that.id}`,
- imageUrl: imageUrl
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- .rich-img {
- width: 100% !important;
- display: block;
- }
- }
- .two {
- display: flex;
- flex-wrap: wrap;
- padding: 2vw;
- .list {
- position: relative;
- padding: 2vw;
- background-color: var(--f1Color);
- margin: 0 2vw 2vw 0;
- border-radius: 5px;
- width: 43vw;
- .img {
- .image {
- width: 100%;
- height: 28vh;
- border-radius: 5px;
- }
- }
- .name {
- margin: 0 0 1vw 0;
- text {
- font-size: var(--font14Size);
- }
- }
- .money {
- display: flex;
- .money_1 {
- color: var(--fFB1Color);
- font-size: 12px;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- .money_2 {
- font-size: 12px;
- margin: 0 0 0 2vw;
- color: var(--f99Color);
- text {
- text-decoration: line-through;
- }
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .acttags {
- position: absolute;
- top: 2vw;
- width: 93%;
- text {
- display: inline-block;
- background-color: var(--fFB1Color);
- color: #fff;
- border-radius: 1vw;
- padding: 0.5vw;
- font-size: 12px;
- margin: 0 1vw 0 0;
- }
- }
- }
- .list:nth-child(2n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .is_bottom {
- text-align: center;
- width: 100vw;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|