Commit 3ed5ea22 by songbingqi

修复部分bug

parent 4de1a348
<template>
<view>
<u-picker
@cancel="show = false"
:show="show"
:immediateChange="true"
ref="uPicker"
:columns="columns"
@confirm="confirm"
keyName="name"
@change="changeHandler"
></u-picker>
</view>
</template>
<script>
import Order from '@/request/order'
import User from '@/request/user'
export default {
data(){
return {
show: false,
columns: [],
cityInfo:[]
}
},
props:{
noSwitch:{
type:Boolean,
default(){
return false
}
}
},
methods:{
showArea() {
uni.getSetting({
success: (res) => {
// 已经授权位置不获取默认店铺
if(res.authSetting['scope.userLocation']) {
User.getLocation((state, params) => {
console.log("showArea, state:"+state+", params:" + JSON.stringify(params));
this.showAreaDialog(params);
});
} else {
console.log("showArea no location" );
this.showAreaDialog();
}
}
})
},
showAreaDialog(params) {
Order.getShop(params).then(res => {
const data = res.data.data;
const two = data[0].children;
const three = two[0].children;
this.columns = [[...data], [...two], [...three]];
this.show = true;
})
},
confirm(res) {
const { value } = res;
console.log(value)
const areaName = {
proviceName:value[0]&&value[0].name,
cityName:value[1]&&value[1].name,
disName:value[2]&&value[2].name
}
const shops = value[2].shops;
this.show = false;
// console.log(shops);
uni.setStorageSync('shops', shops);
uni.setStorageSync('areaName', areaName);
if(this.noSwitch){
this.$emit('sendAreaInfo',{shops,areaName})
}else{
uni.navigateTo({ url: '/menuSubPackage/pages/areaSelect/areaSelect' })
}
},
changeHandler(e) {
const {
columnIndex,
index,
picker = this.$refs.uPicker
} = e
if(columnIndex===0){
this.cityInfo = this.columns[0][index].children?this.columns[0][index].children:[]
picker.setColumnValues(1, this.cityInfo)
picker.setColumnValues(2, this.cityInfo[0].children?this.cityInfo[0].children:[])
}
if(columnIndex===1){
picker.setColumnValues(2, this.cityInfo[index].children?this.cityInfo[index].children:[])
}
},
}
}
</script>
<style>
</style>
\ No newline at end of file
......@@ -87,7 +87,7 @@ export default {
end(e) {
this.clientYEnd = e.changedTouches[0].clientY;
const val = parseInt((this.clientYStart-this.clientYEnd))
if(val<-500){
if(val<-300){
this.close()
}
},
......
<template>
<view ew class="product-list">
<view class="provice_city">
<view class="text">
<view class="text" @click="showArea">
<text>{{areaName.proviceName}}-</text>
<text v-show="areaName.proviceName!=areaName.cityName">{{areaName.cityName}}-</text>
<text>{{areaName.disName}}</text>
......@@ -29,13 +29,16 @@
<view :style="{'height':'34rpx'}" class="distance" v-show="item.distance && item.distance!=-1">距离{{ item.distance }}</view>
</div>
</div>
<AreaPicker ref="AreaPicker" noSwitch @sendAreaInfo="updataAreaInfo"/>
</view>
</template>
<script>
import { $EventBus } from '@/utils/EventBus';
import AreaPicker from '@/components/AreaPicker/index.vue'
export default {
components: {AreaPicker},
data() {
return {
show: true,
......@@ -57,6 +60,13 @@ export default {
uni.setStorage({ key: 'shopData', data: item });
uni.switchTab({ url: '/pages/menu/menu' })
$EventBus.$emit('getMenuList', item);
},
updataAreaInfo(data){
this.list = data.shops
this.areaName = data.areaName
},
showArea(){
this.$refs.AreaPicker.showArea()
}
},
}
......
......@@ -47,8 +47,9 @@
</view>
</view>
<MenuAssembly ref="MenuAssembly" @getallNum="getallNum" :buied="buied"/>
<u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns"
@confirm="confirm" keyName="name" @change="changeHandler"></u-picker>
<!-- <u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns"
@confirm="confirm" keyName="name" @change="changeHandler"></u-picker> -->
<AreaPicker ref="AreaPicker" />
<OrderQrCode ref="OrderQrCode" />
<canvas class="canvas-code" canvas-id="myQrcode2"
style="background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;" />
......@@ -59,6 +60,7 @@
</template>
<script>
import MenuAssembly from '@/components/menuAssembly'
import AreaPicker from '@/components/AreaPicker/index.vue'
import User from '@/request/user'
import ShopCar from '../../components/shopCar/shopCar.vue'
import Utils from '@/utils/utils'
......@@ -69,7 +71,7 @@ import Order from '@/request/order'
import OrderQrCode from '@/components/OrderQrCode'
import QRCode from '@/utils/qrCode'
export default {
components: { ShopCar, MenuAssembly, OrderQrCode },
components: { ShopCar, MenuAssembly, OrderQrCode, AreaPicker },
data() {
return {
shopInfo: { name: '请选择' },// 店铺信息
......@@ -77,10 +79,7 @@ export default {
orderInfo: {},//即将取餐的订单信息
classifyData: [],
customerName: '',
show: false,
columns: [],
loginInfo:"",
cityInfo:[]
loginInfo:""
};
},
computed: {
......@@ -171,59 +170,8 @@ export default {
})
},
showArea() {
uni.getSetting({
success: (res) => {
// 已经授权位置不获取默认店铺
if(res.authSetting['scope.userLocation']) {
User.getLocation((state, params) => {
console.log("showArea, state:"+state+", params:" + JSON.stringify(params));
this.showAreaDialog(params);
});
} else {
console.log("showArea no location" );
this.showAreaDialog();
}
}
})
},
showAreaDialog(params) {
Order.getShop(params).then(res => {
const data = res.data.data;
const two = data[0].children;
const three = two[0].children;
this.columns = [[...data], [...two], [...three]];
this.show = true;
})
},
changeHandler(e) {
const {
columnIndex,
index,
picker = this.$refs.uPicker
} = e
if(columnIndex===0){
this.cityInfo = this.columns[0][index].children?this.columns[0][index].children:[]
picker.setColumnValues(1, this.cityInfo)
picker.setColumnValues(2, this.cityInfo[0].children?this.cityInfo[0].children:[])
}
if(columnIndex===1){
picker.setColumnValues(2, this.cityInfo[index].children?this.cityInfo[index].children:[])
}
},
confirm(res) {
const { value } = res;
console.log(value)
const areaName = {
proviceName:value[0]&&value[0].name,
cityName:value[1]&&value[1].name,
disName:value[2]&&value[2].name
}
const shops = value[2].shops;
this.show = false;
// console.log(shops);
uni.setStorageSync('shops', shops);
uni.setStorageSync('areaName', areaName);
uni.navigateTo({ url: '/menuSubPackage/pages/areaSelect/areaSelect' })
console.log(this.$refs)
this.$refs.AreaPicker.showArea()
},
// 手机号授权登录
getPhoneNumber(e) {
......
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