123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品">
- </view>
- <view class="two">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="two_1">
- <view :class="['list',condActive==index?'activeList':'']" v-for="(item,index) in condList"
- :key="index" @tap="toCond(index,item)">
- <view class="name">
- {{item.name}}
- </view>
- <view class="icon">
- <view class="icon_1">
- <text :class="['iconfont',item.shangActive]"
- v-if="condActive==index&&shang=='1'"></text>
- <text :class="['iconfont',item.shang]" v-else></text>
- </view>
- <view class="icon_1">
- <text :class="['iconfont', item.xiaActive]"
- v-if="condActive==index&&xia=='-1'"></text>
- <text :class="['iconfont', item.xia]" v-else></text>
- </view>
- </view>
- </view>
- <view class="screenList" v-if="pid">
- <picker @change="screenChange" name="screen" :value="screen" :range="screenList"
- range-key="label">
- <view class="uni-input">{{screen_name||'筛选'}}</view>
- </picker>
- </view>
- </view>
- <view class="two_2">
- <view class="pubu">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode="">
- </image>
- <view class="sale" v-if="item.is_sale==true">
- <text>已售尽</text>
- </view>
- <view class="name textOver">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <text>¥</text>
- <text>{{item.sell_money}}</text>
- </view>
- <view class="other_1">
- {{item.view_num||0}}人浏览
- </view>
- <view class="btn" v-if="item.is_sale==false">
- <text class="iconfont icon-gouwuche"></text>
- </view>
- </view>
- <view class="label" v-if="item.p_act">
- <text class="act" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
- </view>
- <view class="other" v-if="item.leader_price">
- <view class="leader">
- <text>会员价</text><text>¥</text><text>{{item.leader_price||0}}</text>
- </view>
- </view>
- <view class="acttags">
- <text v-for="(i,indexx) in item.actTagsShow" :key="indexx">{{i.label}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-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: {},
- tags: '',
- // 一级id
- pid: '',
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- condActive: 0,
- shang: '',
- xia: '',
- condList: [ // 筛选
- ],
- // 筛选
- screenList: [],
- screen: '',
- screen_name: '',
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `tags`, e.tags || '');
- that.$set(that, `pid`, e.pid || '');
- that.searchConfig();
- await that.searchOther();
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPage();
- await that.search();
- uni.stopPullDownRefresh();
- },
- 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);
- }
- })
- },
- // 选择二级
- screenChange(e) {
- const that = this;
- let data = that.screenList[e.detail.value];
- if (data) {
- that.$set(that, `tags`, data.code);
- that.$set(that, `screen_name`, data.label);
- that.clearPage();
- that.search();
- }
- },
- async searchOther() {
- const that = this;
- let config = that.$config;
- if (config) {
- // 筛选条件
- that.$set(that, `condList`, config.condList)
- }
- if (that.pid) {
- let info = {};
- info.pid = that.pid;
- const res = await that.$api(`/goodsTags/tree`, 'GET', {
- ...info
- })
- if (res.errcode == '0' && res.data.length > 0) {
- that.$set(that, `screenList`, res.data[0].children)
- }
- }
- },
- async search() {
- const that = this;
- let info = {
- skip: that.skip,
- limit: that.limit,
- tags: that.tags
- }
- const res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
- ...info,
- ...that.searchInfo
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data]
- that.$set(that, `list`, list)
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- },
- // 分页
- 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);
- },
- // 输入框
- toInput(e) {
- const that = this;
- if (e.detail.value) that.$set(that.searchInfo, `name`, e.detail.value);
- that.clearPage();
- that.search();
- },
- // 筛选
- toCond(index, e) {
- const that = this;
- let condActive = that.condActive;
- that.$set(that, `condActive`, index);
- if (condActive != index && that.xia == '') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- } else if (condActive == index && that.xia == '-1') {
- that.$set(that, `shang`, '1');
- that.$set(that, `xia`, '0');
- } else if (condActive == index && that.shang == '1') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- } else if (condActive = index && that.shang == '1') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- }
- let value;
- if (index != 0) {
- value = that.shang == '0' ? that.xia : that.shang;
- }
- if (index == 1) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `sell_num`, value);
- } else if (index == 2) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `sell_money`, value);
- } else if (index == 3) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `view_num`, value);
- }
- that.clearPage();
- that.search();
- },
- toBuy(e) {
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${e.id||e._id}`
- })
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- border-bottom: 1px solid var(--f85Color);
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .two {
- position: relative;
- flex-grow: 1;
- .two_1 {
- background-color: var(--fffColor);
- padding: 2vw;
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- .list {
- display: flex;
- flex-direction: row;
- .icon {
- position: relative;
- top: -5px;
- left: 2px;
- .icon_1 {
- height: 10px;
- .iconfont {
- font-size: 12px;
- }
- }
- }
- }
- .activeList {
- .name {
- color: var(--fFB1Color);
- }
- }
- .screenList {
- width: 17vw;
- display: inline-block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- .uni-input {
- text-align: center;
- }
- }
- }
- .two_2 {
- display: flex;
- flex-direction: column;
- padding: 2vw;
- background-color: var(--f1Color);
- .pubu {
- // column-count: 2;
- // column-gap: 2vw;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list {
- width: 43vw;
- // break-inside: avoid;
- position: relative;
- background-color: var(--fffColor);
- padding: 2vw;
- margin: 0 0 2vw 0;
- border-radius: 9px;
- .image {
- width: 100%;
- height: 40vw;
- }
- .sale {
- position: absolute;
- top: 18vw;
- text-align: center;
- width: 43vw;
- text {
- background-color: #0000005f;
- border-radius: 90px;
- display: inline-block;
- width: 15vw;
- height: 15vw;
- color: var(--fffColor);
- text-align: center;
- line-height: 15vw;
- }
- }
- .name {
- font-size: var(--font16Size);
- }
- .other {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 1vw 0 0 0;
- .money {
- font-size: var(--font14Size);
- color: var(--fFB1Color);
- text:nth-child(1) {
- font-size: var(--font12Size);
- }
- }
- .other_1 {
- font-size: var(--font12Size);
- color: var(--f85Color);
- text {
- font-weight: bold;
- padding: 0 2vw;
- color: var(--fFB1Color);
- }
- }
- .btn {
- button {
- font-size: var(--font20Size);
- }
- }
- .leader {
- font-size: 12px;
- text-align: center;
- color: #23B67A;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .label {
- display: flex;
- padding: 1vw 0 0 0;
- .act {
- font-size: 12px;
- color: #FFA500;
- border: 1px solid #FFA500;
- border-radius: 5px;
- padding: 0 1vw;
- margin: 0 1vw 0 0;
- }
- }
- .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;
- }
- }
- }
- }
- }
- }
- }
- .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;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|