コード例 #1
0
ファイル: cart.js プロジェクト: nalajn/m.hichao.com
    	$('.removebtn').on('tap',function(){
            console.log('sadadad')
    		var _this = $(this),
    			cartId = _this.parents('.item').attr('data-cartId'),
    			goodsId = _this.parents('.item').attr('data-goodsId'),
    			soureId = _this.parents('.item').attr('data-soureId'),
    			base64_data = base64_encode.encoder('{"cartId":'+cartId+'}'),
    			token = self.settings.token,
                app_uid = self.settings.app_uid,
                method = self.settings.doRemoveOneMethod;
            if(confirm("确定要删除该商品吗?")){
        		$.ajax({
    	            type: 'post',
    	            url: url,
    	            data: {
    	                source: source,
    	                version: version,
    	                method: method,
    	                token: token,
    	                app_uid: app_uid,
    	                data: base64_data,
                    	sign: md5(source+version+method+token+app_uid+base64_data+key)
    	            },
    	            dataType: 'json',
    	            success: function(result){
    	                if (result.response.msg === "success") {
    	                	
                            if(_this.parents('.shop').find('.item').length == 1){
                                _this.parents('.shop').remove();
                            }else{
                               _this.parents('.item').remove(); 
                            }

                            // $('.dialog').text('删除成功!').css('display','block');
                            // setTimeout(function(){
                            //     $('.dialog').css('display','none');
                            // },3000);

                            self.totalPrice();

                            $('.item').each(function(){
                                self.changeRadioBtn($(this));
                            });

                            if($('.item').length == 0){
                                $('.nothing').removeClass('hide');
                                $('.shop,.total').remove();
                            }

    	                } else {
    	                    alert("接口错误");
    	                }
    	            },
    	            error: function(xhr, type){
    	                console.log("请求失败");
    	            }
    	        })
            }
    	})
コード例 #2
0
ファイル: cart.js プロジェクト: nalajn/m.hichao.com
 cartAdd: function(item) {
     var self = this,
         url = '/hichao/interface.php',
         data = '',
         sourceId = item.attr('data-soureid'),
         productId = item.attr('data-productId'),
         from = item.attr('data-from') || '',
         goodsNumber = item.find('.goodsnum .num').text();
     data += '{"sourceId":"' + sourceId + '","productId":"' + productId + '","from":' + from + ',"goodsNumber":"' + goodsNumber + '","type":"update"}';
             
     var base64_data = base64_encode.encoder(data),
         source = self.settings.source,
         version = self.settings.version,
         method = 'goods.cart.add',
         token = self.settings.token,
         app_uid = self.settings.app_uid,
         key = self.settings.key;
     $.ajax({
         type: 'post',
         url: url,
         data: {
             source: source,
             version: version,
             method: method,
             token: token,
             app_uid: app_uid,
             data: base64_data,
             sign: md5(source + version + method + token + app_uid + base64_data + key)
         },
         dataType: 'json',
         success: function(result) {
             window.console.log(result);
             if (result.response.msg === "success") {
                 // Common.setDialog('已添加到购物车');
             } else {
                 Common.setDialog(result.response.msg);
             }
         },
         error: function() {
             console.log("请求失败");
         }
     })
 },
コード例 #3
0
ファイル: cart.js プロジェクト: nalajn/m.hichao.com
 	$('.clean').on('tap',function(){
 		var _this = $(this),
 			cartId = _this.parents('.item').attr('data-cartId'),
 			goodsId = _this.parents('.item').attr('data-goodsId'),
 			soureId = _this.parents('.item').attr('data-soureId'),
 			base64_data = base64_encode.encoder('{"cart_id":cartId,"source_id":soureId,"goodsId":goodsId}'),
             token = self.settings.token,
             app_uid = self.settings.app_uid,
             method = self.settings.cleanCartMethod;
         if(confirm("确定要清空购物车吗?")){
     		$.ajax({
 	            type: 'post',
 	            url: url,
 	            data: {
 	                source: source,
 	                version: version,
 	                method: method,
 	                token: self.settings.token,
 	                app_uid: self.settings.app_uid,
 	                sign:md5(source+version+method+token+app_uid+key)
 	            },
 	            dataType: 'json',
 	            success: function(result){
 	                console.log(result);
 	                if (result.response.msg === "success") {
 	                    // alert('清空购物车成功')
                         Common.setDialog("清空购物车成功");
 	                    $('.nothing').removeClassnothing('hide');
 	                    $('.shop,.total').remove();
 	                } else {
 	                    alert("接口错误");
 	                }
 	            },
 	            error: function(xhr, type){
 	                console.log("请求失败");
 	            }
 	        })
         }
 	})
コード例 #4
0
ファイル: receive_msg.js プロジェクト: nalajn/m.hichao.com
    saveAddress: function(){
        var self = this,
            operate,
            type = self.settings.type;
        if (type == 'edit') {
            operate = 'update';
        } else {
            operate = 'insert';
        }

        var url,
            order_type = window.localStorage.getItem("is_overseas_order"),
            address_id = $('.address-detail').attr('data-id'),
            consignee = $.trim($('.consignee').val()),
            mobile = $.trim($('.mobile').val()),
            province = self.settings.provinceId,
            city = self.settings.cityId,
            district = self.settings.districtId,
            address = $.trim($('.address-detail').val()),
            id_number = $.trim($('.id_number').val()),
            zipcode = '100000',
            is_default = 0,  //0 非默认地址  1 默认地址
            base64_data = base64_encode.encoder('{"address_id":"' + address_id + '","consignee":"' + consignee + '","mobile":"' + mobile + '","address":"' + address + '","id_number":"' + id_number + '","zipcode":"' + zipcode + '","is_default":"' + is_default + '","province":"' + province + '","city":"' + city + '","district":"' + district + '","operate":"' + operate + '"}'),
            source = VER_CONFIG.source,
            version = VER_CONFIG.version,
            token = self.settings.token,
            app_uid = self.settings.app_uid,
            method = 'user.update.address',
            key = VER_CONFIG.key,
            source_id = self.settings.source_id,
            business_id = self.settings.business_id,
            main_image = self.settings.main_image,
            tab_index = self.settings.tab_index,
            sort = self.settings.sort,
            url = self.settings.interfaceUrl;
        var $parm = {token: token, app_uid: app_uid,source_id: source_id,business_id: business_id,main_image: main_image,tab_index: tab_index,sort:sort};
        if (!consignee) {
            $('.verif').removeClass('hide').html('请填写收货人姓名');
        }else if(consignee.length > 16){
            $('.verif').removeClass('hide').html('姓名过长,无法保存');
        }else if (order_type == 1 && !id_number) {
            $('.verif').removeClass('hide').html('请填写正确的身份证号');
        }else if (!mobile || !BASE.regexp.isMobile($('.mobile').val())){
            $('.verif').removeClass('hide').text('请输入正确的手机号');
        }else if (!address || !$('.address').val()) {
            $('.verif').removeClass('hide').html('请填写地址信息');
        }
        else {

            $.ajax({
                type: 'post',
                url: url,
                data: {
                    source: source,
                    version: version,
                    method: method,
                    token: token,
                    app_uid: app_uid,
                    data: base64_data,
                    sign: md5(source + version + method + token + app_uid + base64_data + key)
                },
                dataType: 'json',
                success: function (result) {
                    if (result.response.msg === "success") {
                        // alert('保存成功!')
                        Common.setDialog('保存成功!');
                         window.location.href = '/app/templates/my_address.html?from='+self.settings.from+'&'+ $.param($parm)+ '&good_data=' + self.settings.localGoodData;
                    } else {
                        alert(result.response.msg);
                    }
                },
                error: function () {
                    console.log("请求失败");
                }
            })
        }
    }
コード例 #5
0
ファイル: cart.js プロジェクト: nalajn/m.hichao.com
    getCoupon: function(item,promote_ids,promote_type){
        var self = this,
            url = self.settings.getDataUrl,
            token = self.settings.token,
            app_uid = self.settings.app_uid,
            base64_data = base64_encode.encoder('{"promote_ids":"' + promote_ids + '","promote_type":"'+promote_type+'","mxyc_token":"'+token+'"}') || '',
            source = VER_CONFIG.source,
            version = VER_CONFIG.version,
            key = VER_CONFIG.key,
            method = 'goods.promote.coupon',
            par = self.settings.par;
        if(token){
            $.ajax({
                type: 'get',
                url: url,
                data: {
                    source: source,
                    version: version,
                    method: method,
                    token: token,
                    app_uid: app_uid,
                    data: base64_data,
                    sign: md5(source + version + method + token + app_uid + base64_data + key)
                },
                dataType: 'json',
                success: function(result) {
                    console.log(result);
                    if (result.response.msg === "success") {
                        self.initCouponBox();

                        $('.get_coupon .msg').removeClass('hide').text('领取成功');
                        setTimeout(function(){
                            $('.get_coupon .msg').addClass('hide');
                        },2000);

                        item.find('.btn').removeClass('to_get')
                            .addClass('finish').text('已领取')
                            .parent('.tag').attr('data-promote_is_received','1');

                        $('.promotes .tag').each(function(){
                            if(promote_ids.indexOf($(this).attr('data-promote_id')) >= 0){
                                $(this).attr('data-promote_is_received','1');
                            }
                        })

                        //一键领取后 按钮置灰
                        if($('.coupon_box .tag').length == $('.coupon_box .finish').length){
                            $('.coupon_box .ascertain').addClass('gray');
                        }

                        //Common.setDialog('优惠券领取成功,请到我的优惠券查看');
                        
                    } else if(result.response.code == '1') {
                        Common.setDialog(result.response.msg);
                    }
                },
                error: function(xhr, type) {
                    console.log("请求失败");
                }
            })
        }else {
            window.location.href = '/app/templates/login.html?from=good_detail&' + $.param(par);
        }
    },