123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- <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" v-if="index!=2">
- {{item.name}}
- </view>
- <view v-if="index==2" class="icon4">
- <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>
- <view v-else 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>
- <view class="two_2" v-if="type=='list'">
- <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
- <image class="image" :src="item.logo&&item.logo.length>0?item.logo[0].url:''" mode="">
- </image>
- <view class="other">
- <view class="name">{{item.name}}</view>
- <view class="other_1">
- 店铺地址 <text>{{item.address}}</text>
- </view>
- <view class="other_1">
- 关注时间 <text>{{item.time}}</text>
- </view>
- </view>
- <view class="btn">
- <text @tap.stop="toDel(item)" class="iconfont icon-del"></text>
- </view>
- </view>
- </view>
- <view class="two_3" v-else>
- <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
- <image class="image" :src="item.logo&&item.logo.length>0?item.logo[0].url:''" mode="">
- </image>
- <view class="name">
- {{item.name||'暂无'}}
- </view>
- <view class="address">
- <text>{{item.address}}</text>
- </view>
- <view class="other">
- <view class="other_1">
- {{item.time}}
- </view>
- <view class="other_2">
- <text @tap.stop="toDel(item)" class="iconfont icon-del"></text>
- </view>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- searchInfo: {},
- user: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 10,
- page: 0,
- condActive: 0,
- shang: '',
- xia: '',
- condList: [ // 筛选
- {
- name: '默认',
- },
- {
- name: '关注时间',
- shang: 'icon-shangjiantou',
- shangActive: 'icon-shangjiantou-copy',
- xia: 'icon-xiajiantou',
- xiaActive: 'icon-xiajiantou-copy'
- },
- {
- shang: 'icon-liebiaoxingshi',
- shangActive: 'icon-liebiaoxingshi',
- }
- ],
- type: 'list',
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0
- };
- },
- onShow: function() {
- const that = this;
- that.searchConfig();
- that.watchLogin();
- },
- 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);
- }
- })
- },
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user);
- that.search()
- },
- fail: function(err) {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- })
- },
- // 查询列表
- async search() {
- const that = this;
- let user = that.user;
- let info = {
- skip: that.skip,
- limit: that.limit,
- customer: user._id
- }
- const res = await that.$api(`/storeShop/userView`, '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)
- }
- },
- // 分页
- 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;
- } else {
- that.$set(that, `searchInfo`, {})
- }
- if (index == 1) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `time`, value);
- } else if (index == 2) {
- if (e.shang == 'icon-shitugonggeListBox') {
- that.$set(e, `shang`, 'icon-liebiaoxingshi');
- that.$set(that, `type`, 'list');
- } else {
- that.$set(e, `shang`, 'icon-shitugonggeListBox');
- that.$set(that, `type`, 'gongge');
- }
- }
- that.clearPage();
- that.search();
- },
- // 详细信息
- toView(e) {
- const that = this;
- that.clearPage();
- uni.navigateTo({
- url: `/pagesHome/shop/index?id=${e._id}`
- })
- },
- // 删除
- async toDel(e) {
- const that = this;
- let user = that.user;
- uni.showModal({
- title: '提示',
- content: '确定取消收藏吗?',
- success: async function(res) {
- if (res.confirm) {
- const arr = await that.$api(`/storeShop`, 'POST', {
- customer: user._id,
- shop: e._id
- });
- if (arr.errcode == '0') {
- uni.showToast({
- title: '取消收藏成功',
- icon: 'none'
- })
- that.clearPage();
- that.search();
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none'
- })
- }
- }
- }
- });
- },
- // 清空列表
- 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;
- padding: 2vw 0 0 0;
- .two_1 {
- background-color: var(--fffColor);
- padding: 2vw;
- display: flex;
- width: 100vw;
- 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;
- }
- }
- }
- .icon4 {
- .icon_1 {
- .iconfont {
- font-size: 17px;
- }
- }
- }
- }
- .activeList {
- .name {
- color: var(--fFB1Color);
- }
- }
- }
- .two_2 {
- width: 100vw;
- .list {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- width: 91vw;
- border: 1px solid var(--f1Color);
- margin: 2vw 2vw 0 2vw;
- padding: 2vw;
- border-radius: 5px;
- .image {
- width: 25vw;
- height: 25vw;
- border-radius: 5px;
- margin: 0 2vw 0 0;
- }
- .other {
- display: flex;
- flex-direction: column;
- flex-grow: 1;
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .other_1 {
- font-size: var(--font14Size);
- color: var(--f85Color);
- text {
- padding: 0 2vw;
- color: var(--fFB1Color);
- }
- }
- }
- }
- }
- .two_3 {
- width: 100vw;
- display: flex;
- flex-wrap: wrap;
- .list {
- width: 42vw;
- border: 1px solid var(--f1Color);
- margin: 2vw 2vw 0 2vw;
- padding: 2vw;
- border-radius: 5px;
- .image {
- width: 100%;
- height: 40vw;
- border-radius: 5px;
- }
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .address {
- font-size: var(--font14Size);
- color: var(--fFB1Color);
- margin: 0 0 1vw 0;
- }
- .other {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- .other_1 {
- font-size: var(--font14Size);
- color: var(--f85Color);
- }
- }
- }
- .list:nth-child(2n) {
- margin: 2vw 0 0 0;
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- }
- }
- .is_bottom {
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|