<!-- 门店列表 -->
|
<template>
|
<view>
|
<u-toast ref="uToast" /><u-no-network></u-no-network>
|
<u-navbar title="选择门店" safeAreaInsetTop fixed placeholder>
|
<view class="coreshop-navbar-left-slot" slot="left">
|
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
|
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
|
<u-icon name="home" size="22" @click="goHome"></u-icon>
|
</view>
|
<view slot="right">
|
</view>
|
</u-navbar>
|
<label v-for="store in storeList" :key="store.id" @tap="selStore(store.id)">
|
<view class="store-item coreshop-flex coreshop-justify-between">
|
<view class="coreshop-flex coreshop-align-center">
|
<view class="img-box"><image class="store-img" :src="store.logoImage" mode="aspectFill" lazy-load></image></view>
|
<view class="item-left coreshop-flex coreshop-flex-direction coreshop-align-start">
|
<text class="store-title">{{ store.storeName }}</text>
|
<text class="store-content">{{ store.address }}</text>
|
</view>
|
</view>
|
|
<radio style="transform: scale(0.7);" class="orange" :checked="storeId == store.id" :class="{ checked: storeId == store.id }"></radio>
|
</view>
|
</label>
|
|
<view class="coreshop-bg-white coreshop-card-hight-box" />
|
|
<!--底部-->
|
<view class="coreshop-foot-hight-view" />
|
<view class="coreshop-bottomBox">
|
<button class="coreshop-btn coreshop-btn-square coreshop-btn-w" @click="saveAllStore" v-if="isShopManager">查看所有数据</button>
|
<button class="coreshop-btn coreshop-btn-square coreshop-btn-b" @click="saveStore">选择门店数据</button>
|
</view>
|
|
</view>
|
</template>
|
|
<script>
|
export default {
|
components: {},
|
data() {
|
return {
|
storeList: [],
|
storeId: 0,
|
isShopManager: false
|
};
|
},
|
computed: {},
|
onLoad() {
|
this.getStoreAddress();
|
//判断是否是店员
|
this.$u.api.isStoreUser().then(res => {
|
this.isShopManager = res.data.isShopManager
|
})
|
},
|
methods: {
|
// 选择门店
|
selStore(id) {
|
this.storeId = id;
|
},
|
// 确认门店
|
saveStore() {
|
if (this.storeId == 0) {
|
this.$u.toast("请选择门店")
|
return false;
|
}
|
this.$u.route('/pages/member/merchant/index/index', {
|
storeId: this.storeId,
|
isShopManager: this.isShopManager,
|
});
|
},
|
// 确认门店
|
saveAllStore() {
|
this.$u.route('/pages/member/merchant/index/index', {
|
storeId: this.storeId,
|
isShopManager: this.isShopManager,
|
});
|
},
|
//获取门店列表
|
getStoreAddress() {
|
let _this = this;
|
// #ifdef MP-WEIXIN
|
wx.getFuzzyLocation({
|
type: 'wgs84',
|
success(res) {
|
_this.latitude = res.latitude
|
_this.longitude = res.longitude
|
//console.log('当前位置的经度1:' + res);
|
},
|
fail: function () {
|
_this.$u.toast("获取您的经纬度坐标失败")
|
},
|
complete: function (res) {
|
if (!_this.longitude || !_this.latitude) {
|
_this.longitude = '0';
|
_this.latitude = '0';
|
}
|
let data = {
|
'key': _this.key,
|
'longitude': _this.longitude,
|
'latitude': _this.latitude,
|
'page': _this.page,
|
'limit': _this.limit,
|
}
|
_this.$u.api.getStoreListForUser(data).then(e => {
|
if (e.status) {
|
console.log(e);
|
_this.storeList = [..._this.storeList, ...e.data]
|
} else {
|
_this.$u.toast("门店数据获取失败。");
|
}
|
});
|
}
|
})
|
// #endif
|
// #ifndef MP-WEIXIN
|
uni.getLocation({
|
type: 'wgs84',
|
success: function (res) {
|
_this.longitude = res.longitude;
|
_this.latitude = res.latitude;
|
//console.log('当前位置的经度2:' + res);
|
},
|
fail: function () {
|
_this.latitude = 0;
|
_this.longitude = 0;
|
_this.$u.toast("获取您的经纬度坐标失败")
|
},
|
complete: function (res) {
|
let data = {
|
'key': _this.key,
|
'longitude': _this.longitude,
|
'latitude': _this.latitude,
|
'page': _this.page,
|
'limit': _this.limit,
|
}
|
_this.$u.api.getStoreListForUser(data).then(e => {
|
if (e.status) {
|
console.log(e);
|
_this.storeList = [..._this.storeList, ...e.data]
|
} else {
|
_this.$u.toast("门店数据获取失败。");
|
}
|
});
|
}
|
});
|
// #endif
|
},
|
}
|
};
|
</script>
|
|
|
<style lang="scss" scoped>
|
@import "storeList.scss";
|
</style>
|