Skip to content

Commit

Permalink
Merge pull request #7 from coolhwm/dev
Browse files Browse the repository at this point in the history
线下核销、自助核销、优惠活动
  • Loading branch information
coolhwm authored Oct 9, 2017
2 parents 298050f + 2d97883 commit cfdbda6
Show file tree
Hide file tree
Showing 27 changed files with 1,575 additions and 18 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
- [x] 订单列表
- [x] 订单详情
- [x] 订单评价
- [ ] 订单退款
- [x] 订单退款

### 优惠券
- [x] 我的优惠券
- [x] 领取优惠券
- [x] 使用优惠券
- [x] 扫码核销
- [x] 自助核销
- [x] 活动页面

### 我的
- [x] 基本信息
Expand All @@ -39,6 +42,7 @@
- 2017/09/08:外卖功能基本完成;
- 2017/09/21:完成商品详情;
- 2017/09/25:完成满减优惠、订单评价;
- 2017/10/09:增加扫码核销、活动页面、订单退款;

## License
MIT
22 changes: 20 additions & 2 deletions src/api/coupon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class CouponService extends base {
const ownList = [];
// 卡券分类
coupons.forEach(coupon => {
const isOwn = own.some(item => item.couponId == coupon.id);
const isOwn = own ? own.some(item => item.couponId == coupon.id) : false;
if (isOwn) {
coupon.own = true;
ownList.push(coupon);
Expand Down Expand Up @@ -84,6 +84,14 @@ export default class CouponService extends base {
return this.delete(url);
}

/**
* 使用卡券
*/
static async use(id) {
const url = `${this.baseUrl}/coupons/use/${id}`;
return await this.put(url);
}

/**
* 获取可用的卡券信息
*/
Expand All @@ -95,6 +103,14 @@ export default class CouponService extends base {
});
}

/**
* 获取活动中的卡券
*/
static campaign(visit) {
const url = `${this.baseUrl}/coupons/campaign`;
return this.post(url, visit);
}

static _processPickItem (coupon) {
coupon.beginTime = this._convertTimestapeToDay(coupon.beginTime);
coupon.dueTime = this._convertTimestapeToDay(coupon.dueTime);
Expand All @@ -106,12 +122,14 @@ export default class CouponService extends base {
*/
static _processCouponItem (data) {
const root = data;
if (data.coupon == null) {
return null;
}
const coupon = data.coupon;

coupon.status = root.status;
coupon.id = root.id;
coupon.couponId = root.couponId;
coupon.usedTime = coupon.usedTime;
coupon.acceptTime = root.acceptTime;
coupon.usedTime = root.usedTime;
coupon.beginTime = this._convertTimestapeToDay(coupon.beginTime);
Expand Down
8 changes: 5 additions & 3 deletions src/app.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ export default class extends wepy.app {
'pages/order/trade',
'pages/order/refund_edit',
'pages/order/refund_detail',
'pages/coupon/active',
'pages/coupon/pick',
'pages/coupon/list',
'pages/coupon/detail',
'pages/order/list',
'pages/address/list',
'pages/address/search',
Expand All @@ -99,10 +101,10 @@ export default class extends wepy.app {
},
scene: '',
shopType: '2',
shopName: '连江什么鬼炸鸡汉堡',
app_code: 'eemTgbKrhqiYKMFowcBCQ1Zr7G13bWUT',
// baseUrl: 'http://192.168.31.124:9999/v2/customer',
shopName: '卜菲力牛排杯',
app_code: 'xxfTgbKrhqiYKMFowcBCQ1Zr7G13bWUT',
// baseUrl: 'https://api.leshare.shop/v2/customer'
// baseUrl: 'http://192.168.31.124:9999/v2/customer',
baseUrl: 'http://106.14.195.68:9999/v2/customer'
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/components/common/slider_panel.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!--滑动面板-->
<view class="slider-panel-box {{display == 'true' ? 'slider-panel-show' : '' }} " style="min-height: {{minHeight}}">
<!--面板标题-->
<view class="header-box">
<view class="header-box" wx:if="{{header == 'true'}}">
<!--标题槽位-->
<view class="title-box">
<slot name="title"></slot>
Expand Down Expand Up @@ -41,6 +41,9 @@
backgroundColor: {
default: '#F8F8F8'
},
header: {
default: 'true'
},
minHeight: {
default: 0
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/coupons/item.wpy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view class="coupon-item-container {{coupon.status == 'NEVER_USED' ? '' : 'coupon-item-disable'}}" @tap="select({{coupon}})" @longtap="delete({{coupon}})">
<view class="coupon-item-container {{coupon.status == 'NEVER_USED' ? '' : 'coupon-item-disable'}}" @tap.stop="select({{coupon}})" @longtap="delete({{coupon}})">
<!--左侧区域-->
<view class="coupon-main-container">
<view class="coupon-value-container">
Expand Down Expand Up @@ -51,7 +51,7 @@
this.$emit('select', coupon);
},
delete(coupon) {
this.$emit('delete', coupon);
// this.$emit('delete', coupon);
}
};
events = {};
Expand Down
17 changes: 17 additions & 0 deletions src/components/wux/qrcode/qr.js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var QRCode = require('./lib/QRCode');
var ErrorCorrectLevel = require('./lib/ErrorCorrectLevel');

var qrcode = function(data, opt) {
opt = opt || {};
var qr = new QRCode(opt.typeNumber || -1,
opt.errorCorrectLevel || ErrorCorrectLevel.H);
qr.addData(data);
qr.make();

return qr;
};

qrcode.ErrorCorrectLevel = ErrorCorrectLevel;

module.exports = qrcode;

23 changes: 23 additions & 0 deletions src/components/wux/qrcode/qr.js/lib/8BitByte.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var mode = require('./mode');

function QR8bitByte(data) {
this.mode = mode.MODE_8BIT_BYTE;
this.data = data;
}

QR8bitByte.prototype = {

getLength : function(buffer) {
return this.data.length;
},

write : function(buffer) {
for (var i = 0; i < this.data.length; i++) {
// not JIS ...
buffer.put(this.data.charCodeAt(i), 8);
}
}
};

module.exports = QR8bitByte;

38 changes: 38 additions & 0 deletions src/components/wux/qrcode/qr.js/lib/BitBuffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function QRBitBuffer() {
this.buffer = new Array();
this.length = 0;
}

QRBitBuffer.prototype = {

get : function(index) {
var bufIndex = Math.floor(index / 8);
return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
},

put : function(num, length) {
for (var i = 0; i < length; i++) {
this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
}
},

getLengthInBits : function() {
return this.length;
},

putBit : function(bit) {

var bufIndex = Math.floor(this.length / 8);
if (this.buffer.length <= bufIndex) {
this.buffer.push(0);
}

if (bit) {
this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
}

this.length++;
}
};

module.exports = QRBitBuffer;
7 changes: 7 additions & 0 deletions src/components/wux/qrcode/qr.js/lib/ErrorCorrectLevel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
L : 1,
M : 0,
Q : 3,
H : 2
};

7 changes: 7 additions & 0 deletions src/components/wux/qrcode/qr.js/lib/LICENSE-qrcode
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2009 Kazuhiko Arase <kazuhiko.arase@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67 changes: 67 additions & 0 deletions src/components/wux/qrcode/qr.js/lib/Polynomial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
var math = require('./math');

function QRPolynomial(num, shift) {

if (num.length == undefined) {
throw new Error(num.length + "/" + shift);
}

var offset = 0;

while (offset < num.length && num[offset] == 0) {
offset++;
}

this.num = new Array(num.length - offset + shift);
for (var i = 0; i < num.length - offset; i++) {
this.num[i] = num[i + offset];
}
}

QRPolynomial.prototype = {

get : function(index) {
return this.num[index];
},

getLength : function() {
return this.num.length;
},

multiply : function(e) {

var num = new Array(this.getLength() + e.getLength() - 1);

for (var i = 0; i < this.getLength(); i++) {
for (var j = 0; j < e.getLength(); j++) {
num[i + j] ^= math.gexp(math.glog(this.get(i) ) + math.glog(e.get(j) ) );
}
}

return new QRPolynomial(num, 0);
},

mod : function(e) {

if (this.getLength() - e.getLength() < 0) {
return this;
}

var ratio = math.glog(this.get(0) ) - math.glog(e.get(0) );

var num = new Array(this.getLength() );

for (var i = 0; i < this.getLength(); i++) {
num[i] = this.get(i);
}

for (var i = 0; i < e.getLength(); i++) {
num[i] ^= math.gexp(math.glog(e.get(i) ) + ratio);
}

// recursive call
return new QRPolynomial(num, 0).mod(e);
}
};

module.exports = QRPolynomial;
Loading

0 comments on commit cfdbda6

Please sign in to comment.