| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <template>
- <view class="stores-wrapper">
- <scroll-view scroll-y="true" :style="{ height: height }" @scrolltolower="loadDate()" class="scroll-wrapper">
- <empty v-if="loaded === true && list.length === 0"></empty>
- <view class="store" v-for="item in list" @click="sele(item)">
- <view class="store-logo">
- <image :src="item.image" mode="" v-if="type == 1"></image>
- <text class="store-name clamp">{{ item.name }}</text>
- </view>
- <view class="store-addr store-base">
- 地区:
- <text>{{ item.detailed_address }}</text>
- </view>
- <view class="store-addr store-base">
- 电话:
- <text>{{ item.phone }}</text>
- </view>
- <view class="store-addr store-base">
- 距离:
- <text>{{ item.distance | distance }}</text>
- </view>
- <view class="store-addr store-base">
- 营业时间:
- <text>{{ item.day_time }}</text>
- </view>
- <view class="store-lv ">{{ type == 1 ? '门店' : '自提点' }}</view>
- <view class="store-lv " v-if="item.store_user" style="background: #9a0b09;">采购</view>
- <!-- <view class="store-can">支持自取</view> -->
- <view class="tocall flex" style="background-color: #9a0b09;" @click.stop="tocall(item.phone)">
- <image src="../../static/icon/tocall.png" mode=""></image>
- </view>
- <view class="todh flex" style="background-color: #388bff;" @click.stop="todh(item)">
- <image src="../../static/icon/todh.png" mode=""></image>
- </view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- import {
- loadIndexs,
- getIndexData,
- getStoreList,
- getPointList
- } from '@/api/index.js';
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import empty from '@/components/empty';
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- export default {
- components: {
- empty,
- uniLoadMore
- },
- data() {
- return {
- list: [],
- page: 1,
- limit: 10,
- loadingType: 'more',
- loaded: false,
- height: '',
- type: 0, //1为选择门店,2为选择自提点
- store_id: 0
- };
- },
- onLoad(opt) {
- this.type = opt.type;
- if (this.type == 2) {
- this.store_id = opt.id;
- uni.setNavigationBarTitle({
- title: '选择自提点'
- });
- }
- this.loadDate();
- },
- onReady() {
- var _this = this;
- uni.getSystemInfo({
- success: resu => {
- const query = uni.createSelectorQuery();
- query.select('.scroll-wrapper').boundingClientRect();
- query.exec(function(res) {
- console.log(res, 'ddddddddddddd');
- _this.height = resu.windowHeight - res[0].top + 'px';
- console.log('打印页面的剩余高度', _this.height);
- });
- },
- fail: res => {}
- });
- },
- computed: {
- ...mapState('user', ['userInfo', 'checkedStore', 'des', 'latlng', 'latitude', 'longitude'])
- },
- filters: {
- distance(val) {
- let str = '';
- if (val) {
- if (val * 1 > 1000) {
- return (str = ((val * 1) / 1000).toFixed(1) + 'km');
- } else {
- return (str = (val * 1).toFixed(0) + 'm');
- }
- }
- return str;
- }
- },
- methods: {
- ...mapMutations('user', ['setUserInfo', 'setOrderInfo', 'setStoreInfo', 'setPointInfo', 'setDes']),
- loadDate() {
- if (this.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- //修改当前对象状态为加载中
- this.loadingType = 'loading';
- if (this.type == 1) {
- getStoreList({
- page: this.page,
- limit: this.limit,
- latitude: this.latitude,
- longitude: this.longitude
- })
- .then(({
- data
- }) => {
- console.log(data.list, '店面列表');
- let arr = data.list.map(item => {
- return item;
- });
- this.list = this.list.concat(arr);
- this.page++;
- if (this.limit == data.list.length) {
- this.loadingType = 'more';
- } else {
- this.loadingType = 'noMore';
- }
- this.$set(this, 'loaded', true);
- })
- .catch(err => {
- console.log(err);
- });
- } else {
- getPointList({
- page: this.page,
- limit: this.limit,
- latitude: this.latitude,
- longitude: this.longitude
- },
- this.store_id
- )
- .then(({
- data
- }) => {
- console.log(data.list, '自提点列表');
- let arr = data.list.map(item => {
- return item;
- });
- this.list = this.list.concat(arr);
- this.page++;
- if (this.limit == data.list.length) {
- this.loadingType = 'more';
- } else {
- this.loadingType = 'noMore';
- }
- this.$set(this, 'loaded', true);
- })
- .catch(err => {
- console.log(err);
- });
- }
- },
- sele(item) {
- this.getCurrentPages;
- let obj = this;
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2];
- if (this.type == 1) {
- this.setStoreInfo(item);
- this.setDes(item.distance);
- this.setPointInfo('');
- uni.navigateBack({
- success: function() {
- console.log(prevPage.$vm);
- prevPage.$vm.refrech(); // 执行上一页的onLoad方法
- }
- });
- } else if (this.type == 2) {
- this.setPointInfo(item);
- uni.navigateBack({});
- }
- },
- tocall(phone) {
- uni.makePhoneCall({
- phoneNumber: phone
- })
- },
- // 导航
- todh(item) {
- console.log(item)
- wx.openLocation({
- latitude: item.latitude * 1,
- longitude: item.longitude * 1,
- name: item.name,
- address: item.detailed_address
- })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- background-color: #f8f6f6;
- height: 100%;
- }
- .stores-wrapper {
- padding-top: 20rpx;
- height: 100%;
- .store {
- width: 710rpx;
- // height: 231rpx;
- background: #ffffff;
- box-shadow: 0px 0px 20rpx 0rpx rgba(50, 50, 52, 0.06);
- border-radius: 10rpx;
- // margin-bottom: 15rpx;
- margin: 0 auto 15rpx;
- position: relative;
- padding: 25rpx 0 20rpx 20rpx;
- .store-logo {
- height: 65rpx;
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- line-height: 65rpx;
- margin-bottom: 20rpx;
- position: relative;
- image {
- width: 65rpx;
- height: 65rpx;
- border-radius: 50%;
- }
- .store-name {
- max-width: 500rpx;
- display: inline-block;
- padding-left: 12rpx;
- position: absolute;
- top: 0;
- }
- }
- .store-base {
- height: 37rpx;
- line-height: 37rpx;
- font-size: 24rpx;
- font-weight: bold;
- color: #333333;
- text {
- font-weight: normal;
- }
- }
- .store-lv {
- display: inline-block;
- // width: 60rpx;
- padding: 0 10rpx;
- height: 40rpx;
- background: linear-gradient(-90deg, #dcb876 0%, #eecd92 100%);
- border-radius: 5rpx;
- text-align: center;
- line-height: 40rpx;
- color: #fff;
- font-size: 23rpx;
- position: absolute;
- right: 20rpx;
- top: 38rpx;
- }
- .store-can {
- width: 113rpx;
- height: 44rpx;
- border: 2px solid #901b21;
- border-radius: 5rpx;
- font-size: 23rpx;
- text-align: center;
- line-height: 44rpx;
- font-weight: 500;
- color: #901b21;
- position: absolute;
- right: 20rpx;
- bottom: 25rpx;
- }
- }
- }
- .tocall {
- position: absolute;
- right: 25rpx;
- bottom: 50rpx;
- height: 50rpx;
- width: 50rpx;
- border-radius: 25rpx;
- color: #fff;
- font-size: 28rpx;
- justify-content: center;
- line-height: 50rpx;
- image {
- width: 32rpx;
- height: 32rpx;
- }
- }
- .todh {
- position: absolute;
- right: 100rpx;
- bottom: 50rpx;
- height: 50rpx;
- width: 50rpx;
- border-radius: 25rpx;
- color: #fff;
- font-size: 28rpx;
- justify-content: center;
- line-height: 50rpx;
- image {
- width: 32rpx;
- height: 32rpx;
- }
- }
- </style>
|