123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- /**
- * 购物车模型,目前服务有多种类型,所以通过增加一个购物车对象来缓存用户所选的服务
- */
- define(['base', '$', 'native', 'product'], function (base, $, native, product) {
- var Cart = function () {
- if (typeof Cart.instance === 'object') {
- return Cart.instance;
- }
- Cart.instance = this;
- this.storagePrefix = 'cart_';//存储前缀
- this.products = this.getCache('products', null, {
- 1: {//洗澡-钟点工
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 2: {//剃光-除螨杀菌
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 3: {//美容-深度清洁
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 4: { // 洁牙-住家保姆
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 5: { // spa-日常清洁
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 6: { //训犬-育儿嫂
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 7: { //断尾-月子套餐
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 8: { // 碳酸浴-金牌月嫂
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- },
- 9: {//驱虫-催乳服务
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: '',
- couponName: '',
- couponId: '',
- couponVal: '',
- couponList: []
- }
- });
- this.petInfo = this.getCache('petInfo', null, {
- petID: '',
- productID: '',
- petName: '',
- petWeight: '',
- petPrice: ''
- });
- };
- Cart.prototype = new base();
- //预检
- Cart.prototype.precheck = function (type, callback) {
- var productID = this.products[type]['productID'];
- var productParam = [{product_id: productID, count: 1}];//产品参数
- api.precheck({
- products: JSON.stringify(productParam)//产品
- }, function (res) {
- if (typeof(callback) == 'function') {
- callback(res);
- }
- })
- };
- return new Cart();
- })
|