Skip to content

Commit

Permalink
Merge pull request #33 from coolhwm/dev
Browse files Browse the repository at this point in the history
会员卡管理、会员核销、会员积分、优惠券发放
  • Loading branch information
coolhwm committed Nov 21, 2017
2 parents e3b8c69 + 0c1c7b6 commit 0f0a617
Show file tree
Hide file tree
Showing 50 changed files with 2,148 additions and 220 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
### 营销管理
- [x] 卡券展示;
- [x] 制券;
- [x] 会员卡管理;
- [x] 编辑/删除;
- [x] 卡券核销;
- [x] 发放卡券;
Expand Down Expand Up @@ -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
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
}
}
5 changes: 3 additions & 2 deletions src/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ 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;
}
/**
* 短信验证码
*/
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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/coupon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '已失效'
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/api/customer_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
Expand Down
57 changes: 57 additions & 0 deletions src/api/member.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions src/api/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/api/shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -93,23 +93,23 @@ export default class shop extends base {
/**
* 创建
*/
static createReduce(reduce) {
static createReduce (reduce) {
const url = `${this.baseUrl}/reduce_rule`;
return this.post(url, reduce);
}

/**
* 删除
*/
static removeReduce(id) {
static removeReduce (id) {
const url = `${this.baseUrl}/reduce_rule/${id}`;
return this.delete(url);
}

/**
* 更新
*/
static updateReduce(reduce) {
static updateReduce (reduce) {
const url = `${this.baseUrl}/reduce_rule`;
return this.put(url, reduce);
}
Expand Down
27 changes: 27 additions & 0 deletions src/api/vip_card.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
12 changes: 11 additions & 1 deletion src/app.wpy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<style lang="scss">
@import "./styles/base";
@import "./styles/zent";
@import "./styles/weui.wxss";
@import "./styles/weui-extend";
</style>

Expand Down Expand Up @@ -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'
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
37 changes: 33 additions & 4 deletions src/components/customer/coupon_item.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,53 @@
<view class="info-box column">
<view>
<view>
<view class="small label primary" wx:if="{{coupon.supportType == 0}}">通用</view>
<view class="small label primary" wx:if="{{coupon.supportType == 1}}">线上</view>
<view class="small label primary" wx:if="{{coupon.supportType == 2}}">线下</view>
<text class="sm">{{coupon.name}}</text>
</view>
<text class="muted xs">{{coupon.beginTime}}-{{coupon.dueTime}}</text>
</view>

<!--分隔符-->
<view class="btn-box row-end">
<text class="muted xs">领取时间:{{coupon.acceptTime}}</text>
<text class="muted xs" style="margin-left: 20rpx">状态:{{coupon.status}}</text>
<block wx:if="{{selectAction != '0'}}">
<view class="zan-btn zan-btn--small zan-btn--primary" @tap="sendCoupon({{}})">发放</view>
</block>
<block wx:else>
<text class="muted xs">领取时间:{{coupon.acceptTime}}</text>
<text class="muted xs" style="margin-left: 20rpx">状态:{{coupon.status}}</text>
</block>
</view>
</view>
</view>
</template>

<script>
import wepy from 'wepy';
import Tips from '../../utils/Tips';

export default class CouponItem extends wepy.component {
props = {
coupon: {},
action: {
default: true
},
selectAction: {
default: true
}
};
data = {};
methods = {};
methods = {
async sendCoupon() {
await Tips.confirm('确定给该用户发放优惠券?');

// 发射事件
this.$emit('select', this.coupon.id);
}
};

onLoad() {

}
}
</script>
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/components/notice/item.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<view class="notice-box column">
<view class="row">
<view class="small label primary mr10" wx:if="{{notice.isHome == 1}}">首页</view>
<text>{{notice.content}}</text>
<text class="notice-content">{{notice.content}}</text>
</view>
<view class="btn-box row-end">
<view class="zan-btn zan-btn--small" @tap="delete({{notice.id}})" >删除</view>
Expand Down Expand Up @@ -31,7 +31,7 @@
const param = {
mode: 'edit',
noticeId
}
};
this.$root.$navigate('edit', param)
}
}
Expand All @@ -52,5 +52,8 @@
padding-top: 20rpx;
border-top: $border-dot;
}
.notice-content {
flex: 1;
}
}
</style>
Loading

0 comments on commit 0f0a617

Please sign in to comment.