-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from coolhwm/dev
堂食外卖、访客详情、客户详情、优惠券领取记录、优惠券投放
- Loading branch information
Showing
42 changed files
with
1,415 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import base from './base'; | ||
import Page from '../utils/Page'; | ||
|
||
export default class customerInfo extends base { | ||
/** | ||
* 获取客户地址 | ||
* @param customerId | ||
* @returns {Promise.<TResult>} | ||
*/ | ||
static async addressList(customerId) { | ||
const url = `${this.baseUrl}/customers/${customerId}/detail_info`; | ||
return this.get(url).then(data => { | ||
data.addressList.forEach(v => { | ||
if (v.sex == '1') { | ||
v.name += ' 先生'; | ||
} else { | ||
v.name += ' 女士'; | ||
} | ||
}); | ||
|
||
return data.addressList; | ||
}); | ||
} | ||
|
||
/** | ||
* 获取客户详细信息 | ||
*/ | ||
static async detailInfo(customerId) { | ||
const url = `${this.baseUrl}/customers/${customerId}/detail_info`; | ||
return this.get(url).then(data => { | ||
let price = data.countCustomerInfo.totalPrice; | ||
if (price > 1000 * 1000) { | ||
data.countCustomerInfo.totalPrice = (price / 1000).toFixed(2) + 'k'; | ||
} | ||
const lastTime = data.countCustomerInfo.lastOrderTime; | ||
data.countCustomerInfo.lastOrderTime = this._dealDate(lastTime); | ||
data.address = this._dealAddres(data.addressList); | ||
return data; | ||
}); | ||
} | ||
|
||
/** | ||
* 处理日期为 MM/DD | ||
* @param date | ||
* @returns {string} | ||
* @private | ||
*/ | ||
static _dealDate(date) { | ||
try { | ||
return date.substring(5, 10).replace('-', '/'); | ||
} catch (e) { | ||
return '-'; | ||
} | ||
} | ||
|
||
/** | ||
* 过滤地址为isDefault = 1,若无则为第一个 | ||
* @param addressList | ||
* @returns {*} | ||
* @private | ||
*/ | ||
static _dealAddres(addressList) { | ||
if (addressList && addressList.length > 0) { | ||
let address; | ||
let arr = addressList.filter(v => v.isDefault == '1'); | ||
if (arr.length > 0) { | ||
address = arr[0]; | ||
} else { | ||
address = addressList[0]; | ||
} | ||
|
||
return address; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.