【门店自提列表】

1. 功能实现
pull/1/MERGE
YunaiV 2023-06-29 00:24:30 +08:00
parent 39873a9e3c
commit ec0e0ee234
3 changed files with 127 additions and 154 deletions

11
api/trade/delivery.js Normal file
View File

@ -0,0 +1,11 @@
import request from "@/utils/request.js";
// 获得配送配置
export function getDeliveryConfig() {
return request.get("app-api/trade/delivery/config/get", {});
}
// 获得自提门店列表
export function getDeliveryPickUpStoreList(data) {
return request.get("app-api/trade/delivery/pick-up-store/list", data);
}

View File

@ -2,37 +2,36 @@
<div>
<div class="storeBox" ref="container">
<div class="storeBox-box" v-for="(item, index) in storeList" :key="index" @click.stop="checked(item)">
<div class="store-img"><img :src="item.image" lazy-load="true" /></div>
<div class="store-img">
<img :src="item.logo" lazy-load="true" />
</div>
<div class="store-cent-left">
<div class="store-name">{{ item.name }}</div>
<div class="store-address line1">
{{ item.address }}{{ ", " + item.detailedAddress }}
{{ item.areaName }}{{ ", " + item.detailAddress }}
</div>
</div>
<div class="row-right">
<div>
<!-- #ifdef H5 -->
<a class="store-phone" :href="'tel:' + item.phone"><span
class="iconfont icon-dadianhua01"></span></a>
<a class="store-phone" :href="'tel:' + item.phone">
<span class="iconfont icon-dadianhua01" />
</a>
<!-- #endif -->
<!-- #ifdef MP -->
<view class="store-phone" @click="call(item.phone)"><text
class="iconfont icon-dadianhua01"></text></view>
<view class="store-phone" @click="call(item.phone)">
<text class="iconfont icon-dadianhua01" />
</view>
<!-- #endif -->
</div>
<!-- <div>
<a class="store-phone" :href="'tel:' + item.phone"><span class="iconfont icon-dadianhua01"></span></a>
</div> -->
<div class="store-distance" @click.stop="showMaoLocation(item)">
<span class="addressTxt" v-if="item.distance">{{ item.distance/1000 }}</span>
<span class="addressTxt" v-if="item.distance">{{ item.distance / 1000.0 }}</span>
<span class="addressTxt" v-else></span>
<span class="iconfont icon-youjian"></span>
<span class="iconfont icon-youjian" />
</div>
</div>
</div>
<Loading :loaded="loaded" :loading="loading"></Loading>
<Loading :loaded="loaded" :loading="loading" />
</div>
<div>
<!-- <iframe v-if="locationShow && !isWeixin" ref="geoPage" width="0" height="0" frameborder="0" style="display:none;"
@ -48,24 +47,8 @@
<script>
import Loading from "@/components/Loading";
import {
storeListApi
} from "@/api/store";
import {
isWeixin
} from "@/utils/index";
// #ifdef H5
import {
wechatEvevt,
wxShowLocation
} from "@/libs/wechat";
// #endif
import {
mapGetters
} from "vuex";
// import cookie from "@/utils/store/cookie";
const LONGITUDE = "user_longitude";
import * as DeliveryApi from '@/api/trade/delivery.js';
const LONGITUDE = "user_longitude";
const LATITUDE = "user_latitude";
const MAPKEY = "mapKey";
export default {
@ -73,11 +56,8 @@
components: {
Loading
},
// computed: mapGetters(["goName"]),
data() {
return {
page: 1,
limit: 20,
loaded: false,
loading: false,
storeList: [],
@ -103,9 +83,6 @@
this.selfLocation();
this.getList();
}
// this.$scroll(this.$refs.container, () => {
// !this.loading && this.getList();
// });
},
methods: {
call(phone) {
@ -114,18 +91,17 @@
});
},
selfLocation() {
let self = this
// #ifdef H5
if (self.$wechat.isWeixin()) {
self.$wechat.location().then(res => {
if (this.$wechat.isWeixin()) {
this.$wechat.location().then(res => {
this.user_latitude = res.latitude;
this.user_longitude = res.longitude;
uni.setStorageSync('user_latitude', res.latitude);
uni.setStorageSync('user_longitude', res.longitude);
self.getList();
this.getList();
})
} else {
// #endif
// #endif
uni.getLocation({
type: 'wgs84',
success: (res) => {
@ -135,28 +111,27 @@
uni.setStorageSync('user_latitude', res.latitude);
uni.setStorageSync('user_longitude', res.longitude);
} catch {}
self.getList();
this.getList();
},
complete: function() {
self.getList();
complete: () => {
this.getList();
}
});
// #ifdef H5
// #ifdef H5
}
// #endif
},
showMaoLocation(e) {
let self = this;
// #ifdef H5
if (self.$wechat.isWeixin()) {
self.$wechat.seeLocation({
if (this.$wechat.isWeixin()) {
this.$wechat.seeLocation({
latitude: Number(e.latitude),
longitude: Number(e.longitude)
}).then(res => {
console.log('success');
})
} else {
// #endif
// #endif
uni.openLocation({
latitude: Number(e.latitude),
longitude: Number(e.longitude),
@ -166,42 +141,38 @@
console.log('success');
}
});
// #ifdef H5
// #ifdef H5
}
// #endif
},
//
//
/**
* 选中门店
*/
checked(e) {
uni.$emit("handClick", {
address: e
});
uni.navigateBack();
// if (this.goName === "orders") {
// this.$store.commit("GET_STORE", e);
// this.$router.go(-1); //
// }
},
//
/**
* 获取门店列表数据
*/
getList: function() {
if (this.loading || this.loaded) return;
if (this.loading || this.loaded) {
return;
}
this.loading = true;
let data = {
latitude: this.user_latitude || "", //
longitude: this.user_longitude || "", //
page: this.page,
limit: this.limit
};
storeListApi(data)
.then(res => {
this.loading = false;
this.loaded = res.data.list.length < this.limit;
this.storeList.push.apply(this.storeList, res.data.list);
this.page = this.page + 1;
})
.catch(err => {
this.$dialog.error(err);
});
DeliveryApi.getDeliveryPickUpStoreList({
latitude: this.user_latitude,
longitude: this.user_longitude
}).then(res => {
this.loading = false;
this.loaded = res.data.length < this.limit;
this.storeList = res.data;
}).catch(err => {
this.$dialog.error(err);
});
}
},
onReachBottom() {
@ -209,7 +180,6 @@
}
};
</script>
<style>
.geoPage {
position: fixed;

View File

@ -3,10 +3,10 @@
<view class='order-submission'>
<view class="allAddress" :style="store_self_mention ? '':'padding-top:10rpx;'">
<view class="nav acea-row">
<view class="item font-color" :class="shippingType == 0 ? 'on' : 'on2'" @tap="addressType(0)"
v-if='store_self_mention'></view>
<view class="item font-color" :class="shippingType == 1 ? 'on' : 'on2'" @tap="addressType(1)"
v-if='store_self_mention'></view>
<view class="item font-color" :class="shippingType === 0 ? 'on' : 'on2'"
@tap="addressType(0)" v-if='store_self_mention' />
<view class="item font-color" :class="shippingType === 1 ? 'on' : 'on2'"
@tap="addressType(1)" v-if='store_self_mention' />
</view>
<!-- 收货地址的选择 -->
<view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType === 0'
@ -25,14 +25,14 @@
</view>
<view class='iconfont icon-jiantou'></view>
</view>
<!-- TODO 芋艿还在搞 -->
<!-- 门店的选择 -->
<view class='address acea-row row-between-wrapper' v-else @tap="showStoreList">
<block v-if="storeList.length>0">
<view class='addressCon'>
<view class='name'>{{system_store.name}}
<text class='phone'>{{system_store.phone}}</text>
<view class='name'>{{ system_store.name }}
<text class='phone'>{{ system_store.phone }}</text>
</view>
<view class="line1"> {{system_store.address}}{{", " + system_store.detailedAddress}}
<view class="line1"> {{ system_store.areaName }}{{", " + system_store.detailAddress}}
</view>
</view>
<view class='iconfont icon-jiantou'></view>
@ -97,10 +97,6 @@
</view>
</view>
</view>
<!-- <view class='item acea-row row-between-wrapper' wx:else>
<view>自提门店</view>
<view class='discount'>{{system_store.name}}</view>
</view> -->
<view class='item' v-if="textareaStatus">
<view>备注信息</view>
<textarea v-if="coupon.coupon===false" placeholder-class='placeholder' @input='bindHideKeyboard'
@ -178,10 +174,8 @@
import {
openPaySubscribe
} from '@/utils/SubscribeMessage.js';
import {
storeListApi
} from '@/api/store.js';
import couponListWindow from '@/components/couponListWindow';
import * as DeliveryApi from '@/api/trade/delivery.js';
import couponListWindow from '@/components/couponListWindow';
import addressWindow from '@/components/addressWindow';
import orderGoods from '@/components/orderGoods';
import home from '@/components/home';
@ -224,7 +218,6 @@
}, //
couponId: 0, //id
cartId: '', //id
userInfo: {}, //
mark: '', //
couponTitle: '请选择', //
@ -232,45 +225,37 @@
useIntegral: false, //使
integral_price: 0, //
integral: 0,
ChangePrice: 0, //使
formIds: [], //formid
status: 0,
toPay: false, //
shippingType: 0,
system_store: {},
storePostage: 0,
contacts: '',
contactsTel: '',
mydata: {},
storeList: [],
store_self_mention: 0,
cartInfo: [],
priceGroup: {},
animated: false,
totalPrice: 0,
integralRatio: "0",
pagesUrl: "",
orderKey: "",
offlinePostage: "",
payChannel: '',
news: true,
again: false,
addAgain: false,
bargain: false, //
combination: false, //
secKill: false, //
bargain: false, //
combination: false, //
secKill: false, //
orderInfoVo: {},
addressList: [], //
orderProNum: 0,
preOrderNo: '', //
// ========== ==========
shippingType: 0, // 0 - 1 -
addressId: 0, // param id
addressInfo: {}, //
address: { //
address: false, // addressWindow
addressId: 0 // address addressId
},
// ========== ==========
store_self_mention: false, //
storeList: [], //
system_store: {}, //
};
},
computed: mapGetters(['isLogin', 'systemPlatform', 'productType']),
@ -334,51 +319,22 @@
this.cartArr[1].title = '可用余额:' + orderInfoVo.userBalance;
this.cartArr[1].payStatus = parseInt(res.data.yuePayStatus) === 1 ? 1 : 2;
this.cartArr[0].payStatus = parseInt(res.data.payWeixinOpen) === 1 ? 1 : 0;
this.store_self_mention = res.data.storeSelfMention == 'true'&& this.productType === 'normal' ? true : false;
// TODO
//
this.$nextTick(function() {
this.$refs.addressWindow.getAddressList();
})
}).catch(err => {
return this.$util.Tips({
title: err
});
})
this.$nextTick(function() {
this.$refs.addressWindow.getAddressList();
//
DeliveryApi.getDeliveryConfig().then(res => {
this.store_self_mention = res.data.pickUpEnable && this.productType === 'normal';
})
},
/**
* 获取门店列表数据
*/
getList: function() {
let longitude = uni.getStorageSync("user_longitude"); //
let latitude = uni.getStorageSync("user_latitude"); //
let data = {
latitude: latitude, //
longitude: longitude, //
page: 1,
limit: 10
}
storeListApi(data).then(res => {
let list = res.data.list || [];
this.$set(this, 'storeList', list);
this.$set(this, 'system_store', list[0]);
}).catch(err => {
return this.$util.Tips({
title: err
});
})
},
/*
* 跳转门店列表
*/
showStoreList: function() {
let _this = this
if (this.storeList.length > 0) {
uni.navigateTo({
url: '/pages/users/goods_details_store/index'
})
}
},
//
computedPrice: function() {
let shippingType = this.shippingType;
@ -407,12 +363,6 @@
});
});
},
addressType: function(e) {
let index = e;
this.shippingType = parseInt(index);
this.computedPrice();
if (index == 1) this.getList();
},
bindPickerChange: function(e) {
let value = e.detail.value;
this.shippingType = value;
@ -913,6 +863,48 @@
changeClose: function() {
this.$set(this.address, 'address', false);
},
// ========== ==========
/**
* 切换物流方式
*/
addressType: function(shippingType) {
this.shippingType = shippingType;
this.computedPrice();
if (shippingType === 1) {
this.getList();
}
},
/**
* 跳转门店列表
*/
showStoreList: function() {
if (this.storeList.length > 0) {
uni.navigateTo({
url: '/pages/users/goods_details_store/index'
})
}
},
/**
* 获取门店列表数据
*/
getList: function() {
let longitude = uni.getStorageSync("user_longitude"); //
let latitude = uni.getStorageSync("user_latitude"); //
DeliveryApi.getDeliveryPickUpStoreList({
latitude,
longitude
}).then(res => {
let list = res.data || [];
this.$set(this, 'storeList', list);
this.$set(this, 'system_store', list[0]);
}).catch(err => {
return this.$util.Tips({
title: err
});
})
},
}
}
</script>