123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- <template>
- <app-layout>
- <view class="list-head">
- <view class="dir-left-nowrap cross-center mch-list-input">
- <view class="box-grow-1 box dir-left main-center cross-center">
- <view v-if="toSearch" class="search-content">
- <input class="input"
- :value="keyword"
- @input="bindInput"
- @confirm="bindConfirm"
- @blur="beSearch"
- confirm-type="search"
- :focus="getFocus"/>
- <view v-if="keyword.length" @click="cancelPrint" class="main-center cross-center close-word">
- <icon class="icon-close"></icon>
- </view>
- </view>
- <view v-else @click="beSearch" class="main-center search-content cross-center">
- <icon class="icon-search"></icon>
- <text class="search-text">搜索</text>
- </view>
- </view>
- <view @click="changeCat" class="cross-center">
- <icon class="icon-cats"></icon>
- </view>
- </view>
- <view v-if="catModel" class="list-cat-model dir-left-wrap cross-center">
- <view v-for="(v,k) in cat_list" :key="k">
- <view @click="cat(v.id)">
- <view class="cat-name">{{v.name}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="gap"></view>
- <app-good-shop-recommendation :theme="getTheme" :coupon_req="true" :mch_list="list" :show-goods="true"></app-good-shop-recommendation>
- <view class="no-content" v-if="!list || list.length === 0">暂无店铺记录</view>
- </app-layout>
- </template>
- <script>
- import appGoodShopRecommendation
- from '../../../components/page-component/app-good-shop-recommendation/app-good-shop-recommendation.vue';
- import {mapGetters} from "vuex";
- export default {
- name: "list",
- components: {appGoodShopRecommendation},
- data() {
- return {
- catModel: false,
- toSearch: false,
- list: [],
- cat_list: [],
- page: 1,
- keyword: '',
- mch_common_cat_id: 0,
- load: false,
- args: false,
- latitude: 0,
- longitude: 0,
- page_loading: false,
- getFocus: false
- }
- },
- onLoad: function (options) {
- this.getLocation();
- this.getCats();
- },
- onReachBottom: function () {
- const self = this;
- if (self.args || self.load)
- return;
- self.load = true;
- let page = self.page + 1;
- self.$request({
- url: self.$api.mch.index,
- data: {
- keyword: self.keyword,
- latitude: self.latitude,
- longitude: self.longitude,
- mch_common_cat_id: self.mch_common_cat_id,
- page: page,
- }
- }).then(info => {
- if (info.code === 0) {
- [self.page, self.args, self.list] = [page, info.data.list.length === 0, self.list.concat(self.dataMap(info.data.list))];
- }
- self.load = false;
- });
- },
- onShareAppMessage(e) {
- return this.$shareAppMessage({
- title: `好店推荐`,
- path: '/plugins/mch/list/list',
- params: {}
- });
- },
- methods: {
- dataMap(list) {
- if (!list)
- return;
- list.forEach(item => {
- item.pic_url = item.store.cover_url;
- item.name = item.store.name;
- item.goods_num = item.goods_count;
- item.order_num = item.order_goods_count;
- item.goodsList = item.goods;
- item.goodsList.forEach(item1 => {
- item1.picUrl = item1.goodsWarehouse.cover_pic;
- })
- });
- return list;
- },
- getLocation() {
- const self = this;
- uni.getLocation({
- type: 'wgs84',
- success(res) {
- [self.latitude, self.longitude] = [res.latitude, res.longitude];
- },
- complete() {
- self.loadData();
- }
- })
- },
- loadData() {
- const self = this;
- self.$showLoading();
- self.$request({
- url: self.$api.mch.index,
- data: {
- keyword: self.keyword,
- latitude: self.latitude,
- longitude: self.longitude,
- mch_common_cat_id: self.mch_common_cat_id,
- }
- }).then(info => {
- self.$hideLoading();
- if (info.code === 0) {
- self.list = self.dataMap(info.data.list);
- }
- }).catch(info => {
- self.$hideLoading();
- })
- },
- //分类处理
- getCats() {
- const self = this;
- self.$request({
- url: self.$api.mch.category,
- }).then(info => {
- self.cat_list = info.data.list;
- });
- },
- navShop(mch_id) {
- uni.navigateTo({url: `/plugins/mch/shop/shop?mch_id=` + mch_id});
- },
- navGoods(mch_id, goods_id) {
- uni.navigateTo({url: `/plugins/mch/goods/goods?id=` + goods_id + `&mch_id=` + mch_id});
- },
- beSearch: function (e) {
- if (this.keyword.length === 0) {
- this.toSearch = !this.toSearch;
- this.getFocus = this.toSearch;
- }
- },
- //搜索
- bindConfirm() {
- [
- this.page,
- this.mch_common_cat_id,
- this.catModel,
- this.list
- ] = [
- 1,
- 0,
- false,
- []
- ]
- this.loadData();
- },
- cat(id) {
- [this.mch_common_cat_id, this.list, this.page, this.catModel] = [id, [], 1, false];
- this.loadData();
- },
- changeCat() {
- this.catModel = !this.catModel;
- },
- bindInput: function (e) {
- this.keyword = e.detail.value;
- },
- cancelPrint() {
- this.keyword = '';
- this.toSearch = false;
- this.bindConfirm();
- },
- },
- computed: {
- ...mapGetters('mallConfig', {
- getTheme: 'getTheme',
- }),
- },
- }
- </script>
- <style scoped lang="scss">
- .search-content {
- height: #{56rpx};
- border-radius: #{28rpx};
- background: #fff;
- position: relative;
- width: 100%;
- margin-left: #{24rpx};
- .input {
- height: #{56rpx};
- border-radius: #{28rpx};
- color: #353535;
- width: 90%;
- background-color: #ffffff;
- }
- .icon-search {
- background-image: url("../../../static/image/icon/icon-search.png");
- height: #{24rpx};
- width: #{24rpx};
- background-size: 100% auto;
- margin-right: #{10rpx};
- background-repeat: no-repeat;
- }
- }
- .search-text {
- color: #b2b2b2;
- font-size: #{24rpx};
- margin: 0 #{5rpx};
- }
- .list-head {
- position: fixed;
- top: var(--window-top);
- z-index: 1;
- width: 100%;
- }
- .no-content {
- color: #888;
- padding: #{100rpx} 0 0 0;
- text-align: center;
- }
- .mch-list-input {
- height: #{88rpx};
- padding: 0 #{24rpx};
- background: #EFEFF4;
- .box {
- margin-right: #{24rpx};
- height: #{56rpx};
- border-radius: #{28rpx};
- background: #FFFFFF;
- input {
- border-radius: #{28rpx};
- }
- }
- .icon-cats {
- background-image: url("./../image/list-cat.png");
- background-repeat: no-repeat;
- background-size: 100% auto;
- height: #{30rpx};
- width: #{38rpx};
- }
- .close-word {
- height: #{56rpx};
- width: #{70rpx};
- position: absolute;
- right: 0;
- top: 0;
- z-index: 20;
- .icon-close {
- background-image: url("../../../static/image/icon/icon-close.png");
- background-repeat: no-repeat;
- background-size: 100% auto;
- height: #{25rpx};
- width: #{25rpx};
- }
- }
- }
- .list-cat-model {
- padding-top: #{12rpx};
- padding-bottom: #{12rpx};
- padding-left: #{20rpx};
- background: #f7f7f7;
- .cat-name {
- color: #353535;
- font-size: #{24rpx};
- border: #{1rpx} solid #e7e7e7;
- border-radius: #{28rpx};
- line-height: #{56rpx};
- height: #{56rpx};
- background: #ffffff;
- padding: 0 #{24rpx};
- margin: #{10rpx} #{12rpx} #{10rpx} #{12rpx};
- }
- }
- .gap {
- height: #{88rpx};
- }
- .list-shop {
- margin: #{10rpx} #{20rpx};
- width: #{710rpx};
- background: #fff;
- border-radius: #{16rpx};
- }
- .list-shop .shop-info {
- padding-right: #{24rpx};
- }
- .list-shop .distance {
- align-self: flex-start;
- padding-top: #{36rpx};
- font-size: #{24rpx};
- color: #999999;
- padding-right: #{50rpx};
- }
- .list-shop .list-shop-icon {
- border-radius: #{8rpx};
- height: #{100rpx};
- width: #{100rpx};
- margin: #{24rpx};
- }
- .list-shop .name {
- color: #353535;
- font-size: #{28rpx};
- margin-bottom: #{24rpx};
- }
- .list-shop .shop {
- font-size: #{24rpx};
- color: #999;
- }
- .list-shop .goods-num {
- padding-right: #{32rpx};
- }
- .list-shop .goods {
- padding-bottom: #{24rpx};
- margin: 0 #{16rpx};
- }
- .list-shop .goods-box {
- margin: 0 #{8rpx};
- }
- .list-shop .goods-info {
- position: relative;
- height: #{210rpx};
- width: #{210rpx};
- }
- .list-shop .goods-info view {
- background: #fff;
- font-size: #{28rpx};
- opacity: 0.8;
- width: #{210rpx};
- color: #ff4544;
- height: #{50rpx};
- position: absolute;
- bottom: 0;
- }
- .list-shop .goods-info image {
- height: 100%;
- width: 100%;
- }
- </style>
|