Skip to content

Commit

Permalink
首页增加切换门店
Browse files Browse the repository at this point in the history
  • Loading branch information
woniudiancang committed Dec 26, 2021
1 parent ffae488 commit edadba1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ APPID 务必要改成你自己的小程序的 APPID

假如说用户下了一个订单一次性购买10份这个商品,那么 numberOrders = 1 ,numberSells = 10

## 如何区分门店显示商品

后台左侧菜单“系统设置” -> “系统参数”,增加一个开关类型的参数: shop_goods_split

开启则只会显示当前门店的商品,关闭则显示所有门店的商品

# 常见问题

## 无法登陆 / 无法获取 openid
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
version: "3.12.0",
note: '外卖配送判断服务距离,超过距离不配送',
version: "3.13.0",
note: '首页增加切换门店',
subDomain: "beeorder", // 根据教程 https://www.it120.cc/help/qr6l4m.html 查看并设置你自己的 subDomain
baiduMapKey: "TJ3BZ-6LVCF-C25JP-JOA3O-EWZFJ-5FBMI", // 百度地图开放平台去申请自己的key,用来计算配送距离
}
27 changes: 25 additions & 2 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ Page({
peisongType
})
// 读取最近的门店数据
this.getshopInfo()
this.categories()
this.noticeLastOne()
this.banners()
},
onShow: function(){
this.shippingCarInfo()
const refreshIndex = wx.getStorageSync('refreshIndex')
if (refreshIndex) {
this.getshopInfo()
wx.removeStorageSync('refreshIndex')
}
},
async cyTableToken(tableId, key) {
const res = await WXAPI.cyTableToken(tableId, key)
Expand All @@ -117,6 +121,20 @@ Page({
wx.setStorageSync('token', res.data.token)
},
getshopInfo(){
const shopInfo = wx.getStorageSync('shopInfo')
if (shopInfo) {
this.setData({
shopInfo: shopInfo,
shopIsOpened: this.checkIsOpened(shopInfo.openingHours)
})
const shop_goods_split = wx.getStorageSync('shop_goods_split')
if (shop_goods_split == '1') {
// 商品需要区分门店
wx.setStorageSync('shopIds', shopInfo.id) // 当前选择的门店
this.getGoodsList()
}
return
}
wx.getLocation({
type: 'wgs84', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: (res) => {
Expand All @@ -142,7 +160,6 @@ Page({
ele.distance = ele.distance.toFixed(1) // 距离保留3位小数
})
this.setData({
shops: res.data,
shopInfo: res.data[0],
shopIsOpened: this.checkIsOpened(res.data[0].openingHours)
})
Expand Down Expand Up @@ -199,6 +216,7 @@ Page({
categories: res.data,
categorySelected: res.data[0]
})
this.getshopInfo()
const shop_goods_split = wx.getStorageSync('shop_goods_split')
if (shop_goods_split != '1') {
this.getGoodsList()
Expand Down Expand Up @@ -897,4 +915,9 @@ Page({
goods
})
},
selectshop() {
wx.navigateTo({
url: '/pages/shop/select?type=index',
})
},
})
2 changes: 1 addition & 1 deletion pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</view>
<view wx:if="{{ !scanDining }}" class="box">
<view class="shop-name">
<view class="name">{{shopInfo.name}}</view>
<view class="name" bindtap="selectshop">{{shopInfo.name}}</view>
<view class="select">
<view class="{{peisongType == 'zq' ? 'on' : 'off'}}" data-type="zq" bindtap="changePeisongType">自取</view>
<view class="{{peisongType == 'kd' ? 'on' : 'off'}}" data-type="kd" bindtap="changePeisongType">外卖</view>
Expand Down
4 changes: 3 additions & 1 deletion pages/shop/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ Page({
goShop(e){
const idx = e.currentTarget.dataset.idx
wx.setStorageSync('shopInfo', this.data.shops[idx])
wx.setStorageSync('shopIds', this.data.shops[idx].id) // 当前选择的门店
if (this.data.type == 'index') {
wx.setStorageSync('refreshIndex', 1)
}
if (this.data.type == 'pay') {
wx.navigateBack()
} else {
Expand Down
2 changes: 1 addition & 1 deletion project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"useIsolateContext": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
Expand Down

0 comments on commit edadba1

Please sign in to comment.