diff --git a/README.md b/README.md index 8246477..4f0d047 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ ### 营销管理 - [x] 卡券展示; - [x] 制券; +- [x] 会员卡管理; - [x] 编辑/删除; - [x] 卡券核销; - [x] 发放卡券; @@ -86,7 +87,9 @@ - 2017/09/24:增加分类管理、配送员管理、店铺管理、优惠管理; - 2017/10/09:增加卡券核销; - 2017/10/25:增加用户详情、用户订单、常购商品、用户优惠券、用户统计; -- 2017/10/27:堂食外卖、访客详情、优惠券领取记录、优惠券投放 +- 2017/10/27:堂食外卖、访客详情、优惠券领取记录、优惠券投放; +- 2017/11/07:会员卡管理、会员级别; +- 2017/11/12:会员积分管理、会员折扣管理; ## License MIT diff --git a/package.json b/package.json index 290a287..0cfaa46 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "author": "", "license": "MIT", "dependencies": { - "wepy": "^1.5.7", + "wepy": "^1.6.0", "wepy-async-function": "^1.4.4", "wepy-com-toast": "^1.0.2" }, @@ -32,6 +32,9 @@ "wepy-compiler-babel": "^1.5.1", "wepy-compiler-less": "^1.3.10", "wepy-compiler-sass": "^1.3.7", - "wepy-eslint": "^1.5.2" + "wepy-eslint": "^1.5.2", + "wepy-plugin-autoprefixer": "^1.5.9", + "wepy-plugin-imagemin": "^1.5.2", + "wepy-plugin-uglifyjs": "^1.3.6" } } diff --git a/src/api/auth.js b/src/api/auth.js index 65d2562..bce7f02 100644 --- a/src/api/auth.js +++ b/src/api/auth.js @@ -13,7 +13,8 @@ export default class auth extends base { * 登录 */ static async login(phone, code) { - const url = `${this.baseUrl}/auth/login?phone=${phone}&sms_code=${code}`; + const appCode = wepy.$instance.globalData.app_code; + const url = `${this.baseUrl}/auth/login?phone=${phone}&sms_code=${code}&app_code=${appCode}`; const dara = await this.get(url); return dara.login_code; } @@ -21,7 +22,7 @@ export default class auth extends base { * 短信验证码 */ static async sms (phone) { - const url = `${this.baseUrl}/auth/sms_code?phone=${phone}` + const url = `${this.baseUrl}/auth/sms_code?phone=${phone}`; const data = await this.get(url); return data.message; } diff --git a/src/api/coupon.js b/src/api/coupon.js index d8c4404..f93e7ea 100644 --- a/src/api/coupon.js +++ b/src/api/coupon.js @@ -30,16 +30,16 @@ export default class coupon extends base { switch (item.status) { case 'USED': - item.status = '进行中'; + item.status = '已使用'; break; case 'NEVER_USED': - item.status = '未开始'; + item.status = '未使用'; break; case 'EXPIRED': - item.status = '已失效'; + item.status = '已过期'; break; default: - item.status = '无效' + item.status = '已失效' } } diff --git a/src/api/customer_info.js b/src/api/customer_info.js index d0fe3ad..0008dc8 100644 --- a/src/api/customer_info.js +++ b/src/api/customer_info.js @@ -2,6 +2,16 @@ import base from './base'; import Page from '../utils/Page'; export default class customerInfo extends base { + + /** + * 根据客户发放优惠券 + * @param params(couponId, cusomterId) + */ + static async sendCoupon(params) { + const url = `${this.baseUrl}/coupons/send`; + return await this.post(url, params); + } + /** * 获取客户地址 * @param customerId @@ -28,6 +38,9 @@ export default class customerInfo extends base { static async detailInfo(customerId) { const url = `${this.baseUrl}/customers/${customerId}/detail_info`; return this.get(url).then(data => { + if (data.message) { + return Promise.reject(new Error(data.message)); + } let price = data.countCustomerInfo.totalPrice; if (price > 1000 * 1000) { data.countCustomerInfo.totalPrice = (price / 1000).toFixed(2) + 'k'; diff --git a/src/api/member.js b/src/api/member.js new file mode 100644 index 0000000..91c60c7 --- /dev/null +++ b/src/api/member.js @@ -0,0 +1,57 @@ +import base from './base'; +import Page from '../utils/Page'; + +export default class Member extends base { + /** + * 获取会员信息 + */ + static async Info (number) { + const url = `${this.baseUrl}/members/number?number=${number}`; + return await this.get(url); + } + + /** + * 增加积分信息 + */ + static async memberAdd (bonusDetail) { + const url = `${this.baseUrl}/members/bonus_detail`; + return this.post(url, bonusDetail); + } + + /** + * 获取买家会员数据 + */ + static async customerInfo (customerId) { + const url = `${this.baseUrl}/members?customer_id=${customerId}`; + return await this.get(url); + } + + /** + * 获取买家会员卡数据 + */ + static async cardInfo () { + const url = `${this.baseUrl}/memberCards`; + return await this.get(url); + } + + /** + * 历史积分信息 + */ + static async bonusPage(customerId) { + const url = `${this.baseUrl}/members/bonus_detail?by=create_time&sort=desc&customer_id=${customerId}`; + return new Page(url, this.processBonusTransformation.bind(this)); + } + static processBonusTransformation (bonusInfo) { + const comment = {}; + if (bonusInfo.addBonus > 0) { + comment.costMoney = `消费金额:¥ ${bonusInfo.costMoney.toFixed(2)}`; + } else { + comment.costMoney = `抵扣金额:¥ ${bonusInfo.costMoney.toFixed(2)}`; + } + comment.addBonus = bonusInfo.addBonus; + comment.createTime = bonusInfo.createTime; + comment.orderId = bonusInfo.orderId; + comment.typeDesc = bonusInfo.typeDesc; + return comment; + } +} diff --git a/src/api/order.js b/src/api/order.js index 5c76cda..f444938 100644 --- a/src/api/order.js +++ b/src/api/order.js @@ -358,6 +358,7 @@ export default class order extends base { order.dealPrice = this._fixedPrice(order.dealPrice); order.finalPrice = this._fixedPrice(order.finalPrice); order.couponPrice = this._fixedPrice(order.couponPrice); + order.bonusPrice = this._fixedPrice(order.bonusPrice); } /** diff --git a/src/api/shop.js b/src/api/shop.js index 1f956ff..0c1d2e7 100644 --- a/src/api/shop.js +++ b/src/api/shop.js @@ -14,7 +14,7 @@ export default class shop extends base { /** * 店铺分类 */ - static async getShopCategories() { + static async getShopCategories () { const url = `${this.baseUrl}/shop_parent_categories/0`; return await this.get(url); } @@ -39,14 +39,14 @@ export default class shop extends base { /** * 上传图片 */ - static async image(filePath) { + static async image (filePath) { // const url = `${this.baseUrl}/images`; const url = `${this.baseUrl}/images`; const param = { url, filePath, name: 'image' - } + }; return await wepy.uploadFile(param); } @@ -93,7 +93,7 @@ export default class shop extends base { /** * 创建 */ - static createReduce(reduce) { + static createReduce (reduce) { const url = `${this.baseUrl}/reduce_rule`; return this.post(url, reduce); } @@ -101,7 +101,7 @@ export default class shop extends base { /** * 删除 */ - static removeReduce(id) { + static removeReduce (id) { const url = `${this.baseUrl}/reduce_rule/${id}`; return this.delete(url); } @@ -109,7 +109,7 @@ export default class shop extends base { /** * 更新 */ - static updateReduce(reduce) { + static updateReduce (reduce) { const url = `${this.baseUrl}/reduce_rule`; return this.put(url, reduce); } diff --git a/src/api/vip_card.js b/src/api/vip_card.js new file mode 100644 index 0000000..26a993d --- /dev/null +++ b/src/api/vip_card.js @@ -0,0 +1,27 @@ +import base from './base'; + +export default class vip extends base { + /** + * 会员卡信息 + */ + static async info () { + const url = `${this.baseUrl}/memberCards`; + return await this.get(url); + } + + /** + * 添加会员卡 + */ + static async create (cardParam) { + const url = `${this.baseUrl}/memberCards`; + return this.post(url, cardParam); + } + + /** + * 编辑会员卡 + */ + static async update (cardParam) { + const url = `${this.baseUrl}/memberCards`; + return this.put(url, cardParam); + } +} diff --git a/src/app.wpy b/src/app.wpy index 1931f43..6380eeb 100644 --- a/src/app.wpy +++ b/src/app.wpy @@ -1,6 +1,7 @@ @@ -62,6 +63,7 @@ globalData = { auth: {}, shop: {}, + app_code: '1jAB5uZLs57cH1gq6ujRnOdVLDqu2qle', // baseUrl: 'https://api.leshare.shop/v2/seller' // baseUrl: 'http://192.168.31.124:9999/v2/seller' baseUrl: 'http://106.14.195.68:9999/v2/seller' @@ -70,6 +72,7 @@ pages: [ 'pages/home/index', 'pages/customer/address_list', + 'pages/customer/coupon_send', 'pages/customer/info', 'pages/order/index', 'pages/shop/index', @@ -105,7 +108,14 @@ 'pages/order/reprice', 'pages/order/detail', 'pages/order/close', - 'pages/order/remark' + 'pages/order/remark', + 'pages/vip/vip_scan', + 'pages/vip/vip_detail', + 'pages/vip/discount_category', + 'pages/vip/vip_card', + 'pages/vip/supply_bonus', + 'pages/vip/vip_context', + 'pages/vip/supply_discount' ], window: { backgroundTextStyle: 'dark', diff --git a/src/components/customer/coupon_item.wpy b/src/components/customer/coupon_item.wpy index 90a1479..c4a68fc 100644 --- a/src/components/customer/coupon_item.wpy +++ b/src/components/customer/coupon_item.wpy @@ -13,15 +13,22 @@ + 通用 + 线上 + 线下 {{coupon.name}} {{coupon.beginTime}}-{{coupon.dueTime}} - - 领取时间:{{coupon.acceptTime}} - 状态:{{coupon.status}} + + 发放 + + + 领取时间:{{coupon.acceptTime}} + 状态:{{coupon.status}} + @@ -29,18 +36,30 @@ @@ -78,6 +97,16 @@ padding: rpx(10) rpx(20) 0 rpx(20); height: rpx(200); + .img-select { + position: relative; + top: rpx(-15); + left: rpx(350); + + image { + @include icon-image(rpx(50)); + } + } + .btn-box { padding: 5px 0; margin-top: rpx(5); diff --git a/src/components/notice/item.wpy b/src/components/notice/item.wpy index 726076d..0d17426 100644 --- a/src/components/notice/item.wpy +++ b/src/components/notice/item.wpy @@ -2,7 +2,7 @@ 首页 - {{notice.content}} + {{notice.content}} 删除 @@ -31,7 +31,7 @@ const param = { mode: 'edit', noticeId - } + }; this.$root.$navigate('edit', param) } } @@ -52,5 +52,8 @@ padding-top: 20rpx; border-top: $border-dot; } + .notice-content { + flex: 1; + } } diff --git a/src/components/vip/bonus_item.wpy b/src/components/vip/bonus_item.wpy new file mode 100644 index 0000000..9ae7268 --- /dev/null +++ b/src/components/vip/bonus_item.wpy @@ -0,0 +1,66 @@ + + + diff --git a/src/components/vip/category_item.wpy b/src/components/vip/category_item.wpy new file mode 100644 index 0000000..6dfd5d5 --- /dev/null +++ b/src/components/vip/category_item.wpy @@ -0,0 +1,34 @@ + + + diff --git a/src/components/vip/discount.wpy b/src/components/vip/discount.wpy new file mode 100644 index 0000000..3775967 --- /dev/null +++ b/src/components/vip/discount.wpy @@ -0,0 +1,93 @@ + + + + + diff --git a/src/components/vip/vip_card.wpy b/src/components/vip/vip_card.wpy new file mode 100644 index 0000000..0db803d --- /dev/null +++ b/src/components/vip/vip_card.wpy @@ -0,0 +1,105 @@ + + + + + diff --git a/src/components/weui/navigator.wpy b/src/components/weui/navigator.wpy index b6c740e..a6adfd1 100644 --- a/src/components/weui/navigator.wpy +++ b/src/components/weui/navigator.wpy @@ -1,12 +1,13 @@ diff --git a/src/components/weui/search_bar.wpy b/src/components/weui/search_bar.wpy index d0a4e6d..838c5d3 100644 --- a/src/components/weui/search_bar.wpy +++ b/src/components/weui/search_bar.wpy @@ -41,7 +41,7 @@ isBack() { return this.back == 'true'; } - } + }; methods = { showInput: function () { this.inputShowed = true; diff --git a/src/images/icons/canvas.png b/src/images/icons/canvas.png new file mode 100644 index 0000000..7e0999b Binary files /dev/null and b/src/images/icons/canvas.png differ diff --git a/src/images/icons/customer_white.png b/src/images/icons/customer_white.png new file mode 100644 index 0000000..839daed Binary files /dev/null and b/src/images/icons/customer_white.png differ diff --git a/src/images/icons/vip_card.png b/src/images/icons/vip_card.png new file mode 100644 index 0000000..27774c9 Binary files /dev/null and b/src/images/icons/vip_card.png differ diff --git a/src/pages/coupon/customer_list.wpy b/src/pages/coupon/customer_list.wpy index 2c1d146..1bab129 100644 --- a/src/pages/coupon/customer_list.wpy +++ b/src/pages/coupon/customer_list.wpy @@ -70,8 +70,7 @@ couponId: this.couponId.couponId, customerId: customer.id }; - await Tips.confirm('确认发放该优惠券?'); - console.log(param); + await Tips.confirm('确定发放?'); await coupon.send(param); await Tips.success('发放成功'); Event.emit(Event.COUPON_USER_UPDATE); diff --git a/src/pages/coupon/edit.wpy b/src/pages/coupon/edit.wpy index f507250..33a4c69 100644 --- a/src/pages/coupon/edit.wpy +++ b/src/pages/coupon/edit.wpy @@ -1,6 +1,6 @@ @@ -30,23 +30,24 @@ def = { init: false, list: [ - ] - } + ], + isPageEmpty: false + }; data = {...this.def}; async onLoad () { - this.list = await goods.getInnerCategories(); - this.loaded(); + await this.update(); Event.listen(Event.CATEGORY_LIST_UPDATE, this.update.bind(this), this); }; async update () { this.list = await goods.getInnerCategories(); + this.isPageEmpty = this.list == null || this.list.length == 0; this.loaded(); } methods = { add() { this.$navigate('category_edit?mode=create'); } - } + }; events = {}; components = { Placeholder: Placeholder, diff --git a/src/pages/goods/edit.wpy b/src/pages/goods/edit.wpy index b3b1d0a..3da9f41 100644 --- a/src/pages/goods/edit.wpy +++ b/src/pages/goods/edit.wpy @@ -119,7 +119,7 @@ innerCategories: [], init: false, isInnerDisplay: 'false' - } + }; data = {...this.def}; async onLoad ({goodsId, mode}) { this.mode = mode; @@ -175,7 +175,7 @@ const stock = { sku: null, stock: sku.stock - } + }; data.goodsSkuInfo = null; data.stock = sku.stock; data.goodsStocks.push(stock); @@ -235,7 +235,7 @@ details() { const param = { details: JSON.stringify(this.details) - } + }; this.$navigate('detail', param); } diff --git a/src/pages/home/home.wpy b/src/pages/home/home.wpy index 10977c6..7a8aa87 100644 --- a/src/pages/home/home.wpy +++ b/src/pages/home/home.wpy @@ -128,10 +128,10 @@ shop: {}, init: false, show: false - } + }; data = {...this.def}; async onLoad () { - console.info('load') + console.info('load'); WxUtils.checkSDK(); this.shop = await shop.info(); this.show = true; @@ -163,7 +163,7 @@ clearInterval(interval); } async reload() { - Tips.setLoading() + Tips.setLoading(); // 数据展现 const [today, month, order] = await Promise.all([count.today(), count.month(), count.order()]); this.today = today; @@ -209,14 +209,18 @@ Event.emit(Event.ORDER_TAB_UPDATE, status); }, async scan() { - const {result} = await wepy.scanCode(); - if (result != null && result != '') { - this.$navigate(`/pages/coupon/scan?scan=${result}`); + const data = await wepy.scanCode(); + console.info(data); + if (data.result != null && data.result != '') { + this.$navigate(`/pages/coupon/scan?scan=${data.result}`); + } else if (data.path != null && data.path != '') { + const arr = data.path.split('='); + this.$navigate('/pages/vip/vip_scan?scene=' + arr[1]); } else { Tips.alert('扫描失败'); } } - } + }; config = { enablePullDownRefresh: true, navigationBarTitleText: ' ' diff --git a/src/pages/home/index.wpy b/src/pages/home/index.wpy index 1fb7d81..cbc17b1 100644 --- a/src/pages/home/index.wpy +++ b/src/pages/home/index.wpy @@ -51,7 +51,7 @@ def = { init: false }; - data = {...this.def} + data = {...this.def}; async onLoad () { try { const loginCode = auth.getConfig('login_code'); diff --git a/src/pages/order/detail.wpy b/src/pages/order/detail.wpy index 32d7d0f..7acec26 100644 --- a/src/pages/order/detail.wpy +++ b/src/pages/order/detail.wpy @@ -74,10 +74,14 @@ 运费 +¥{{order.postFee}} - + 优惠券 -¥{{order.couponPrice}} + + 积分抵扣 + -¥{{order.bonusPrice}} + 原价: diff --git a/src/pages/order/send.wpy b/src/pages/order/send.wpy index 5600945..63ba6c8 100644 --- a/src/pages/order/send.wpy +++ b/src/pages/order/send.wpy @@ -164,7 +164,7 @@ value.mailNo = null; } } - } + }; computed = { // 计算主面板是否显示 panelDisplay() { @@ -177,7 +177,7 @@ return '请选择'; } } - } + }; mixins = [input]; components = { Address: Address, diff --git a/src/pages/shop/edit.wpy b/src/pages/shop/edit.wpy index 7cc0c36..5744273 100644 --- a/src/pages/shop/edit.wpy +++ b/src/pages/shop/edit.wpy @@ -1,103 +1,112 @@