Skip to content

Commit

Permalink
增加商品区分门店显示功能
Browse files Browse the repository at this point in the history
  • Loading branch information
woniudiancang committed Nov 23, 2021
1 parent 19ca7b7 commit 03dac6b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 13 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ APPID 务必要改成你自己的小程序的 APPID

重新进入小程序以后,就可以看见 “扫码核销” 的菜单了

# 配置说明

## 如何修改小程序首页标题

登录后台,左侧菜单 “系统设置” --> “系统参数” ,添加一个文本类型的参数: mallName (注意大小写),小程序即可显示你后台填的名称

## 根据选择的不同门店,区分显示商品(只显示当前门店的商品)

登录后台,左侧菜单 “系统设置” --> “系统参数” ,添加一个开关类型的参数: shop_goods_split,开启为区分,关闭为不区分

## 如何显示销量

商品列表接口、商品详情接口,都会返回商品的销量数据,分别是 numberOrders 和 numberSells 两个字段,你可以在界面上任何希望显示销量的地方,进行展示即可

- numberOrders 订单数量
- numberSells 商品数量

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

# 常见问题

## 无法登陆 / 无法获取 openid
Expand All @@ -137,3 +156,8 @@ APPID 务必要改成你自己的小程序的 APPID
- 点击你的小程序开发工具 右上角 的“详情” --> “基本信息” 中的 appid
- 登录你的 api工厂 后台(https://admin.it120.cc),左侧菜单微信设置中的 appid

## 获取手机号码失败,提示没权限

https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html

官方文档有说明,获取手机号码的前提条件是:非个人开发者,且完成了认证的小程序开放(不包含海外主体)
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ App({
wx.hideToast()
}
})
WXAPI.queryConfigBatch('mallName,myBg,mapPos,order_hx_uids,subscribe_ids,share_profile,zxdz,admin_uids').then(res => {
WXAPI.queryConfigBatch('mallName,myBg,mapPos,order_hx_uids,subscribe_ids,share_profile,zxdz,admin_uids,shop_goods_split').then(res => {
if (res.code == 0) {
res.data.forEach(config => {
wx.setStorageSync(config.key, config.value);
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
version: "3.10.0",
note: '扫码点餐bug',
version: "3.11.0",
note: '增加商品区分门店显示功能',
subDomain: "beeorder", // 根据教程 https://www.it120.cc/help/qr6l4m.html 查看并设置你自己的 subDomain
}
26 changes: 19 additions & 7 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ Page({
shopIsOpened: this.checkIsOpened(res.data[0].openingHours)
})
wx.setStorageSync('shopInfo', res.data[0])
const shop_goods_split = wx.getStorageSync('shop_goods_split')
if (shop_goods_split == '1') {
// 商品需要区分门店
wx.setStorageSync('shopIds', res.data[0].id) // 当前选择的门店
this.getGoodsList()
}
}
},
async _showCouponPop() {
Expand Down Expand Up @@ -191,9 +197,20 @@ Page({
categories: res.data,
categorySelected: res.data[0]
})
this.getGoodsList()
const shop_goods_split = wx.getStorageSync('shop_goods_split')
if (shop_goods_split != '1') {
this.getGoodsList()
}
},
async getGoodsList() {
const shop_goods_split = wx.getStorageSync('shop_goods_split')
if (shop_goods_split == '1') {
// 商品需要区分门店
const shopIds = wx.getStorageSync('shopIds') // 当前选择的门店
if (!shopIds) {
return
}
}
wx.showLoading({
title: '',
})
Expand Down Expand Up @@ -237,12 +254,7 @@ Page({
},
async shippingCarInfo() {
const res = await WXAPI.shippingCarInfo(wx.getStorageSync('token'))
if (res.code == 700) {
this.setData({
shippingCarInfo: null,
showCartPop: false
})
} else if (res.code == 0) {
if (res.code == 0) {
this.setData({
shippingCarInfo: res.data
})
Expand Down
1 change: 1 addition & 0 deletions pages/shop/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ 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 == 'pay') {
wx.navigateBack()
} else {
Expand Down
8 changes: 5 additions & 3 deletions project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useMultiFrameRuntime": false,
"useApiHook": false,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
Expand All @@ -35,8 +35,10 @@
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"minifyWXML": true,
"showES6CompileOption": false,
"minifyWXML": true
"useCompilerPlugins": false
},
"compileType": "miniprogram",
"libVersion": "2.19.5",
Expand Down

0 comments on commit 03dac6b

Please sign in to comment.