Commit db8a9999 by songbingqi

修复部分bug

parent 11511525
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
</scroll-view> </scroll-view>
<scroll-view class="nav-right" :style="[heightStyle]" :class="[shopCarFlag?'shopCarcss':'' ]" scroll-y :scroll-top="scrollTop" @scroll="scroll" @touchstart="openScroll" <scroll-view class="nav-right" :style="[heightStyle]" :class="[shopCarFlag?'shopCarcss':'' ]" scroll-y :scroll-top="scrollTop" @scroll="scroll" @touchstart="openScroll"
scroll-with-animation> scroll-with-animation>
<view v-for="(category,index) in classifyData" :id="category.id" :key="category.id" class="box" :style="[goodBottom]"> <view v-for="(category,index) in classifyData" :id="category.id" :key="category.id" class="box" :style="[goodBottom,scrollBottom]">
<view :style="loads" class="right-title">{{ category.name }}</view> <view :style="loads" class="right-title">{{ category.name }}</view>
<view class="nav-right-item" v-for="item in category.goods" :key="item.goodsId" :style="[scrollBottom]"> <view class="nav-right-item" v-for="item in category.goods" :key="item.goodsId">
<view class="thumbnailBox"> <view class="thumbnailBox">
<image src="/static/imgs/aixin.png" v-if="item.isRecommend == 1" class="isRecommend" /> <image src="/static/imgs/aixin.png" v-if="item.isRecommend == 1" class="isRecommend" />
<image @click="cart(item, category)" class="thumbnail" v-if="item.pics.thumbnailApplet" :src="item.pics.thumbnailApplet" /> <image @click="cart(item, category)" class="thumbnail" v-if="item.pics.thumbnailApplet" :src="item.pics.thumbnailApplet" />
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<view class="discount"><text class="moneyLog"></text>{{ Utils.isInteger(getSku(item).discount) }}</view> <view class="discount"><text class="moneyLog"></text>{{ Utils.isInteger(getSku(item).discount) }}</view>
<view class="price" v-if="getSku(item).price!=getSku(item).discount"><text class="num">{{ Utils.isInteger(getSku(item).price) }}</text></view> <view class="price" v-if="getSku(item).price!=getSku(item).discount"><text class="num">{{ Utils.isInteger(getSku(item).price) }}</text></view>
</view> </view>
<view class="addbox" v-if="shopState"> <view class="addbox" v-if="shopState&&isInRange">
<image v-if="getSku(item).state==1" @click.stop="cart(item, category)" class="add" :src="'../../static/imgs/jiahao.png'" /> <image v-if="getSku(item).state==1" @click.stop="cart(item, category)" class="add" :src="'../../static/imgs/jiahao.png'" />
<!-- <u-icon class="add" name="plus-circle-fill" color="#0050F6" @click.stop="getallNum(item, category)" size="22"></u-icon> --> <!-- <u-icon class="add" name="plus-circle-fill" color="#0050F6" @click.stop="getallNum(item, category)" size="22"></u-icon> -->
<div v-if="getSku(item).state!=1" style="color: #858585;font-size: 20rpx;margin-top:16rpx">已售罄</div> <div v-if="getSku(item).state!=1" style="color: #858585;font-size: 20rpx;margin-top:16rpx">已售罄</div>
...@@ -53,7 +53,7 @@ import Utils from '@/utils/utils' ...@@ -53,7 +53,7 @@ import Utils from '@/utils/utils'
import Order from '@/request/order' import Order from '@/request/order'
export default { export default {
name: 'menuAssembly', name: 'menuAssembly',
props:['buied','shopState'], props:['buied','shopState','isInRange'],
data() { data() {
return { return {
scrollBottom: { scrollBottom: {
...@@ -80,22 +80,28 @@ export default { ...@@ -80,22 +80,28 @@ export default {
} }
}, },
watch:{ watch:{
isInRange(val) {
if(!val) {
this.scrollBottom['--scroll-marginbottom'] = 131+'rpx'
}else{
this.scrollBottom['--scroll-marginbottom'] = 0+'rpx'
}
},
shopState(val) { shopState(val) {
if(!val) { if(!val) {
this.scrollBottom['--scroll-marginbottom'] = 100+'rpx' this.scrollBottom['--scroll-marginbottom'] = 131+'rpx'
}else{ }else{
this.scrollBottom['--scroll-marginbottom'] = 0+'rpx' this.scrollBottom['--scroll-marginbottom'] = 0+'rpx'
} }
console.log(this.scrollBottom['--scroll-marginbottom'])
}, },
goods(val){ goods(val){
this.shopCarFlag = val.length>0 this.shopCarFlag = val.length>0
}, },
buied(val) { buied(val) {
if(val){ if(val){
this.heightStyle['--scroll-height'] = (this.taBarHeight+100)+'rpx' this.heightStyle['--scroll-height'] = (this.taBarHeight+122)+'rpx'
}else{ }else{
this.heightStyle['--scroll-height'] = (this.taBarHeight)+'rpx' this.heightStyle['--scroll-height'] = (this.taBarHeight+22)+'rpx'
} }
} }
}, },
...@@ -145,7 +151,7 @@ export default { ...@@ -145,7 +151,7 @@ export default {
mounted(){ mounted(){
this.$nextTick(()=>{ this.$nextTick(()=>{
this.taBarHeight = uni.getStorageSync('taBarHeight') this.taBarHeight = uni.getStorageSync('taBarHeight')
this.heightStyle['--scroll-height'] = (this.taBarHeight)+'rpx' this.heightStyle['--scroll-height'] = (this.taBarHeight+44)+'rpx'
}) })
this.goods = uni.getStorageSync('shopCarInfo') || []; this.goods = uni.getStorageSync('shopCarInfo') || [];
$EventBus.$on('updateCar', () => { $EventBus.$on('updateCar', () => {
...@@ -260,10 +266,9 @@ export default { ...@@ -260,10 +266,9 @@ export default {
icon: 'none', icon: 'none',
}) })
}else{ }else{
if(this.shopState){ if(this.shopState&&this.isInRange){
const {data} = await Order.checkSku({skuId:skuStatus[0].skuId}) const {data} = await Order.checkSku({skuId:skuStatus[0].skuId})
const {goods} = data.data const {goods} = data.data
console.log(goods)
uni.setStorageSync('goodsInfo', JSON.stringify({ ...goods, category })); uni.setStorageSync('goodsInfo', JSON.stringify({ ...goods, category }));
} else { } else {
uni.setStorageSync('goodsInfo', JSON.stringify({ ...item, category })); uni.setStorageSync('goodsInfo', JSON.stringify({ ...item, category }));
...@@ -518,7 +523,7 @@ export default { ...@@ -518,7 +523,7 @@ export default {
width: 150rpx; width: 150rpx;
height: 150rpx; height: 150rpx;
} }
.nav-right-item:last-child { .box:last-child {
margin-bottom: var(--scroll-marginbottom); margin-bottom: var(--scroll-marginbottom);
border-bottom: none; border-bottom: none;
} }
......
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
@getphonenumber="saveReserve">结算 @getphonenumber="saveReserve">结算
</button> </button>
</view> </view>
<view class="shopClose" v-if="!shopState" :style="{'bottom':shopCar+'rpx'}"> <view class="shopClose" v-if="!shopState||!isInRange" :style="{'bottom':shopCar+'rpx'}">
<view class="content">门店已休息</view> <view class="content">{{!shopState?"门店已休息":"距离较远,门店暂停接单"}}</view>
</view> </view>
<show-toast ref="toast"/> <show-toast ref="toast"/>
</view> </view>
...@@ -98,7 +98,7 @@ import Menu from '@/request/menu'; ...@@ -98,7 +98,7 @@ import Menu from '@/request/menu';
import User from '@/request/user'; import User from '@/request/user';
import Utils from '@/utils/utils' import Utils from '@/utils/utils'
export default { export default {
props:['shopState'], props:['shopState','isInRange'],
data() { data() {
return { return {
showShopCar: false,//是否弹出购物车列表 showShopCar: false,//是否弹出购物车列表
......
...@@ -65,16 +65,16 @@ ...@@ -65,16 +65,16 @@
</view> </view>
<view v-if="size > 0" class="good-select-cont"> <view v-if="size > 0" class="good-select-cont">
<view> <view>
<a :class="!shopState?'good-select-btn1-close':'good-select-btn1'" @click="getallNum()" v-if="userms"> <a :class="!shopState||!isInRange?'good-select-btn1-close':'good-select-btn1'" @click="getallNum()" v-if="userms">
立即购买 立即购买
</a> </a>
<button v-if="!userms" :class="!shopState?'good-select-btn1-close':'good-select-btn1'" style="border-radius: 0;" open-type="getPhoneNumber" <button v-if="!userms" :class="!shopState||!isInRange?'good-select-btn1-close':'good-select-btn1'" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="getallNum"> @getphonenumber="getallNum">
立即购买 立即购买
</button> </button>
</view> </view>
<span :class="!shopState?'good-select-btn2-close':'good-select-btn2'" @click="shoppingCart" type="default">加入购物袋</span> <span :class="!shopState||!isInRange?'good-select-btn2-close':'good-select-btn2'" @click="shoppingCart" type="default">加入购物袋</span>
</view> </view>
</view> </view>
</view> </view>
...@@ -106,7 +106,8 @@ export default { ...@@ -106,7 +106,8 @@ export default {
BottomSafeHeight:0, BottomSafeHeight:0,
Utils, Utils,
shopState:true, shopState:true,
showSku:[] showSku:[],
isInRange:true
} }
}, },
onShow() { onShow() {
...@@ -114,6 +115,7 @@ export default { ...@@ -114,6 +115,7 @@ export default {
uni.removeStorageSync('goodsList'); uni.removeStorageSync('goodsList');
this.BottomSafeHeight = uni.getStorageSync('BottomSafeHeight') this.BottomSafeHeight = uni.getStorageSync('BottomSafeHeight')
this.shopState = JSON.parse(uni.getStorageSync("shopState")) this.shopState = JSON.parse(uni.getStorageSync("shopState"))
this.isInRange = uni.getStorageSync("isInRange")===''?true:uni.getStorageSync("isInRange")
}, },
mounted(){ mounted(){
// 获取胶囊坐标位置 // 获取胶囊坐标位置
...@@ -299,7 +301,7 @@ export default { ...@@ -299,7 +301,7 @@ export default {
} }
}, },
async shoppingCart() { async shoppingCart() {
if(!this.shopState){ if(!this.shopState&&!this.isInRange){
return return
} }
if(this.checkNum('addShop')){ if(this.checkNum('addShop')){
...@@ -329,9 +331,10 @@ export default { ...@@ -329,9 +331,10 @@ export default {
this.loginByPhoneNumber(e); this.loginByPhoneNumber(e);
return return
} }
if(!this.shopState){ if(!this.shopState&&!this.isInRange){
return return
} }
const { goods } = this; const { goods } = this;
const { data } = await Order.checkSku({skuId:goods.skuId}) const { data } = await Order.checkSku({skuId:goods.skuId})
const {state,goods:newgoods} = data.data const {state,goods:newgoods} = data.data
...@@ -373,7 +376,7 @@ export default { ...@@ -373,7 +376,7 @@ export default {
} }
}, },
UseIt(ruleId) { UseIt(ruleId) {
return this.available.indexOf(ruleId) == -1&&this.shopState return this.available.indexOf(ruleId) == -1&&this.shopState&&this.isInRange
}, },
ShowIt(ruleId) { ShowIt(ruleId) {
return this.showSku.indexOf(ruleId) !== -1 return this.showSku.indexOf(ruleId) !== -1
......
...@@ -156,6 +156,14 @@ export default { ...@@ -156,6 +156,14 @@ export default {
this.userInfo.sex = sex?sex?1:0:gender this.userInfo.sex = sex?sex?1:0:gender
this.userInfo.name = userName?userName:nickName this.userInfo.name = userName?userName:nickName
this.userInfo.phone = phone.substr(0,3) + "****" + phone.substr(7) this.userInfo.phone = phone.substr(0,3) + "****" + phone.substr(7)
const {...result} = this.userInfoStorage
const sendData ={
...result,
avatarUrl
}
Store.commit('setUserInfo', sendData);
}, },
methods:{ methods:{
async choseTime(e) { async choseTime(e) {
...@@ -166,6 +174,7 @@ export default { ...@@ -166,6 +174,7 @@ export default {
const {data} = await Mine.editBirthdat(sendDate) const {data} = await Mine.editBirthdat(sendDate)
const {code} = data const {code} = data
if(code===200){ if(code===200){
this.canEditBirthday = false
this.showToast({ title: '修改成功'}) this.showToast({ title: '修改成功'})
this.userInfo.birthday = e.value this.userInfo.birthday = e.value
} }
...@@ -192,7 +201,7 @@ export default { ...@@ -192,7 +201,7 @@ export default {
async save() { async save() {
const {customerName,...result} = this.userInfoStorage const {customerName,...result} = this.userInfoStorage
if(!this.valate){ if(!this.valate){
const {sex,name,id} = this.userInfo const {sex,name,id,avatarUrl} = this.userInfo
const sendData = { const sendData = {
sex: Number(sex)===0?false:true, sex: Number(sex)===0?false:true,
userName: name, userName: name,
...@@ -204,7 +213,8 @@ export default { ...@@ -204,7 +213,8 @@ export default {
if(code===200){ if(code===200){
const data = { const data = {
...result, ...result,
customerName:name customerName:name,
avatarUrl
} }
Store.commit('setUserInfo', data); Store.commit('setUserInfo', data);
uni.setStorage({ key: 'userInfo', data: data }); uni.setStorage({ key: 'userInfo', data: data });
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</view> </view>
<view class="login-area"> <view class="login-area">
<view class="avatar"> <view class="avatar">
<image :src="'../../static/touxiang.png'"></image> <image :src="userInfo.avatarUrl?userInfo.avatarUrl:'../../static/touxiang.png'"></image>
</view> </view>
<view class="user-info" @click="goToMyPage(userms)"> <view class="user-info" @click="goToMyPage(userms)">
<view class="user-infocontent"> <view class="user-infocontent">
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<view class="barCode-dis">点击二维码取单</view> <view class="barCode-dis">点击二维码取单</view>
</view> </view>
</view> </view>
<MenuAssembly ref="MenuAssembly" @getallNum="getallNum" :buied="buied" :shopState="shopState"/> <MenuAssembly ref="MenuAssembly" @getallNum="getallNum" :buied="buied" :shopState="shopState" :isInRange="isInRange"/>
<!-- <u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns" <!-- <u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns"
@confirm="confirm" keyName="name" @change="changeHandler"></u-picker> --> @confirm="confirm" keyName="name" @change="changeHandler"></u-picker> -->
<AreaPicker ref="AreaPicker" /> <AreaPicker ref="AreaPicker" />
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
style="background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;" /> style="background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;" />
<show-toast ref="toast"/> <show-toast ref="toast"/>
<taBar select="0"></taBar> <taBar select="0"></taBar>
<ShopCar ref="shopbar" :shopState="shopState" /> <ShopCar ref="shopbar" :shopState="shopState" :isInRange="isInRange"/>
</view> </view>
</template> </template>
<script> <script>
...@@ -84,7 +84,8 @@ export default { ...@@ -84,7 +84,8 @@ export default {
classifyData: [], classifyData: [],
customerName: '', customerName: '',
loginInfo:"", loginInfo:"",
img:'' img:'',
isInRange:true
}; };
}, },
computed: { computed: {
...@@ -171,9 +172,9 @@ export default { ...@@ -171,9 +172,9 @@ export default {
}, },
methods: { methods: {
getShopMenus(params) { getShopMenus(params) {
$EventBus.$off('getMenuList'); $EventBus.$off('getMenuList');
$EventBus.$on('getMenuList', (data) => { $EventBus.$on('getMenuList', (data) => {
console.log("shop:"+JSON.stringify(data));
if(this.shopInfo && this.shopInfo.id != data.id) { if(this.shopInfo && this.shopInfo.id != data.id) {
// 切换店铺清空购物车 // 切换店铺清空购物车
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync('shopCarInfo');
...@@ -183,6 +184,19 @@ export default { ...@@ -183,6 +184,19 @@ export default {
uni.setStorageSync("shopInfo",JSON.stringify(this.shopInfo)) uni.setStorageSync("shopInfo",JSON.stringify(this.shopInfo))
this.getMenuList(data.id); this.getMenuList(data.id);
this.getHomeOrder(data.id) this.getHomeOrder(data.id)
// 判断店铺是否在范围内
const location = uni.getStorageSync("location")
const shopInfo = uni.getStorageSync("shopInfo")
const {lat:latloc,lng:lngloc} = location
const {lat:latshop,lng:lngshop,distance:shopdistanceshop} = JSON.parse(shopInfo)
const distance = Utils.getDistances(latloc,lngloc,latshop,lngshop)
if(!shopdistanceshop){
this.isInRange = true
}else{
console.log(parseInt(distance.distance_str)<parseInt(shopdistanceshop))
this.isInRange = parseInt(distance.distance_str)<parseInt(shopdistanceshop)
}
uni.setStorageSync("isInRange",this.isInRange)
}); });
User.getShopInfo(params); User.getShopInfo(params);
}, },
...@@ -251,17 +265,6 @@ export default { ...@@ -251,17 +265,6 @@ export default {
this.showToast({ "title" : "获取位置失败,请打开位置授权", icon : 'error'}) this.showToast({ "title" : "获取位置失败,请打开位置授权", icon : 'error'})
} }
}) })
// if (res.authSetting['scope.userLocation']) {
// console.log("以前允许授权位置");
// User.getLocation((state, params) => {
// if(state != 1){
// return;
// }
// callback && callback(params);
// });
// } else {
// }
} }
}) })
}, },
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> --> <!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> -->
<view class="mod11" @click="goToPage('userInfo')"> <view class="mod11" @click="goToPage('userInfo')">
<view class="avatar"> <view class="avatar">
<image :src="'../../static/touxiang.png'"></image> <image :src="userInfo.avatarUrl?userInfo.avatarUrl:'../../static/touxiang.png'"></image>
</view> </view>
<view class="user-info"> <view class="user-info">
<view class="user-infocontent"> <view class="user-infocontent">
......
...@@ -162,5 +162,45 @@ export default { ...@@ -162,5 +162,45 @@ export default {
}, },
isInteger(value) { isInteger(value) {
return parseFloat(Number(value).toFixed(2)) return parseFloat(Number(value).toFixed(2))
},
// 计算经纬度之间的距离
// 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
getDistances(lat1, lng1, lat2, lng2) {
function rad(d) {
return d * Math.PI / 180.0;
}
var radLat1 = rad(lat1);
var radLat2 = rad(lat2);
var a = radLat1 - radLat2;
var b = rad(lng1) - rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137; // EARTH_RADIUS;
// 输出为公里
s = Math.round(s * 10000) / 10000;
var distance = s;
var distance_str = "";
if (parseInt(distance) >= 1) {
// distance_str = distance.toFixed(1) + "km";
distance_str = distance.toFixed(2) + "km";
} else {
// distance_str = distance * 1000 + "m";
distance_str = (distance * 1000).toFixed(2) + "m";
}
//s=s.toFixed(4);
// console.info('距离是', s);
// console.info('距离是', distance_str);
// return s;
//小小修改,这里返回对象
let objData = {
distance: distance,
distance_str: distance_str
}
return objData
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment