123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <image class="image" :src="topUrl" mode="aspectFit"></image>
- </view>
- <view class="two">
- <view class="pubu">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
- <view class="list_1">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
- </view>
- <view class="name textOver">
- {{item.name}}
- </view>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- // 路由参数
- type: '1',
- tags: '',
- act_tags: '',
- topUrl: '',
- // 数据列表
- list: [],
- is_bottom: false
- };
- },
- onLoad(e) {
- const that = this;
- if (e && e.tags) {
- that.$set(that, `type`, '1')
- that.$set(that, `tags`, e.tags || '');
- } else if (e && e.act_tags) {
- that.$set(that, `type`, '2')
- that.$set(that, `act_tags`, e.act_tags || '');
- }
- that.searchConfig();
- that.searchOther();
- that.search();
- },
- methods: {
- // 查询基本设置
- searchConfig() {
- const that = this;
- uni.getStorage({
- key: 'config',
- success: function(res) {
- if (res.data) that.$set(that, `config`, res.data)
- }
- })
- },
- async search() {
- const that = this;
- let info = {};
- if (that.type == '1') info.tags = that.tags;
- else if (that.type == '2') info.act_tags = that.act_tags;
- let res = await that.$api(`/goods`, 'GET', {
- ...info,
- status: '1'
- });
- if (res.errcode == '0') {
- that.$set(that, `list`, res.data)
- }
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let type = that.type;
- let act_tags = that.act_tags;
- let tags = that.tags;
- let topUrl = [];
- let res;
- if (type == '1') {
- res = await that.$api(`/goodsTags/getData`, 'GET', {
- code: tags
- })
- } else if (type == '2') {
- res = await that.$api(`/actTags/getData`, 'GET', {
- value: act_tags
- })
- }
- if (res.errcode == '0') {
- let data = res.data;
- uni.setNavigationBarTitle({
- title: data.label
- });
- if (that.type == '1' && data.tags_file.length > 0) topUrl = data.tags_file
- else if (that.type == '2' && data.file.length > 0) topUrl = data.file
- }
- if (topUrl.length > 0) {
- that.$set(that, `topUrl`, topUrl[0].url)
- } else {
- that.$set(that, `topUrl`, that.config.config.logo[0].url)
- }
- },
- // 购买
- toBuy(e) {
- const that = this;
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${e._id}`
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- padding: 2vw;
- background-color: #ffffff;
- .image {
- width: 100%;
- height: 200px;
- box-shadow: 0 0 5px #f1f1f1;
- border-radius: 10px;
- }
- }
- .two {
- padding: 0 2vw;
- margin: 0 0 2vw 0;
- .pubu {
- // column-count: 2;
- // column-gap: 3vw;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list {
- width: 43vw;
- // break-inside: avoid;
- margin: 0 0 2vw 0;
- box-shadow: 0 0 5px #f1f1f1;
- padding: 2vw;
- border-radius: 5px;
- .list_1 {
- margin: 0 0 1vw 0;
- .image {
- width: 100%;
- height: 30vh;
- border-radius: 10px;
- box-shadow: 0 0 5px #f1f1f1;
- }
- }
- .name {
- font-size: 16px;
- }
- }
- }
- }
- }
- .is_bottom {
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|