浏览代码

Merge branch 'test'

DengTao 8 年之前
父节点
当前提交
cb1d5d692e

+ 92 - 0
www/js/o2o/jq-signature.min.js

@@ -0,0 +1,92 @@
+/*! jq-signature.min.js, v1.0.0, minified 2015-05-25 */
+!function (a, b, c) {
+    var w;
+    // w=$('windows').width();
+
+    w=$(window).width();
+    var h;
+    h=$(window).height();
+    h=h-(h*0.05);
+
+    // h=$('windows').height();
+    "use strict";
+    function d(a, b) {
+        this.element = a, this.$element = c(this.element), this.canvas = !1, this.$canvas = !1, this.ctx = !1, this.drawing = !1, this.currentPos = {
+            x: 0,
+            y: 0
+        }, this.lastPos = this.currentPos, this._data = this.$element.data(), this.settings = c.extend({}, f, b, this._data), this.init()
+    }
+
+    a.requestAnimFrame = function (b) {
+        return a.requestAnimationFrame || a.webkitRequestAnimationFrame || a.mozRequestAnimationFrame || a.oRequestAnimationFrame || a.msRequestAnimaitonFrame || function (b) {
+                a.setTimeout(b, 1e3 / 60)
+            }
+    }();
+    var e = "jqSignature", f = {
+        lineColor: "#222222",
+        lineWidth: 1,
+        border: "1 dashed #AAAAAA",
+        background: "#FFFFFF",
+        width: w,
+        height: h,
+        autoFit: !1
+    }, g = "<canvas></canvas>";
+    d.prototype = {
+        init: function () {
+            this.$canvas = c(g).appendTo(this.$element), this.$canvas.attr({
+                width: this.settings.width,
+                height: this.settings.height
+            }), this.$canvas.css({
+                boxSizing: "border-box",
+                width: this.settings.width + "",
+                height: this.settings.height + "",
+                border: this.settings.border,
+                background: this.settings.background,
+                cursor: "crosshair"
+            }), this.settings.autoFit === !0 && this._resizeCanvas(), this.canvas = this.$canvas[0], this._resetCanvas(), this.$canvas.on("mousedown touchstart", c.proxy(function (a) {
+                this.drawing = !0, this.lastPos = this.currentPos = this._getPosition(a)
+            }, this)), this.$canvas.on("mousemove touchmove", c.proxy(function (a) {
+                this.currentPos = this._getPosition(a)
+            }, this)), this.$canvas.on("mouseup touchend", c.proxy(function (a) {
+                this.drawing = !1;
+                var b = c.Event("jq.signature.changed");
+                this.$element.trigger(b)
+            }, this)), c(b).on("touchstart touchmove touchend", c.proxy(function (a) {
+                a.target === this.canvas && a.preventDefault()
+            }, this));
+            var d = this;
+            !function e() {
+                a.requestAnimFrame(e), d._renderCanvas()
+            }()
+        }, clearCanvas: function () {
+            this.canvas.width = this.canvas.width, this._resetCanvas()
+        }, getDataURL: function () {
+            return this.canvas.toDataURL()
+        }, _getPosition: function (a) {
+            var b, c, d;
+            return d = this.canvas.getBoundingClientRect(), a = a.originalEvent, -1 !== a.type.indexOf("touch") ? (b = a.touches[0].clientX - d.left, c = a.touches[0].clientY - d.top) : (b = a.clientX - d.left, c = a.clientY - d.top), {
+                x: b,
+                y: c
+            }
+        }, _renderCanvas: function () {
+            this.drawing && (this.ctx.moveTo(this.lastPos.x, this.lastPos.y), this.ctx.lineTo(this.currentPos.x, this.currentPos.y), this.ctx.stroke(), this.lastPos = this.currentPos)
+        }, _resetCanvas: function () {
+            this.ctx = this.canvas.getContext("2d"), this.ctx.strokeStyle = this.settings.lineColor, this.ctx.lineWidth = this.settings.lineWidth
+        }, _resizeCanvas: function () {
+            var a = this.$element.outerWidth();
+            this.$canvas.attr("width", a), this.$canvas.css("width", a + "")
+        }
+    }, c.fn[e] = function (a) {
+        var b = arguments;
+        if (void 0 === a || "object" == typeof a)return this.each(function () {
+            c.data(this, "plugin_" + e) || c.data(this, "plugin_" + e, new d(this, a))
+        });
+        if ("string" == typeof a && "_" !== a[0] && "init" !== a) {
+            var f;
+            return this.each(function () {
+                var g = c.data(this, "plugin_" + e);
+                g instanceof d && "function" == typeof g[a] && (f = g[a].apply(g, Array.prototype.slice.call(b, 1))), "destroy" === a && c.data(this, "plugin_" + e, null)
+            }), void 0 !== f ? f : this
+        }
+    }
+}(window, document, jQuery);

+ 1 - 7
www/protected/controllers/ROrderController.php

@@ -736,13 +736,7 @@ class ROrderController extends AdminController{
     }
 
     public function actionDelOrder(){
-       $delOrder =  array('58250fc29f5160ca048b524a',
-           '5825090c9f5160bd048b51e4',
-           '582508ed9f5160c6048b502c',
-           '582508d29f5160b6048b5163',
-           '5825084e9f5160b6048b515d',
-           '5824d8469f5160b2048b4fb1',
-           '582492eb9f5160c4048b4f36');
+       $delOrder =  array('5826a4c89f5160d1048b52bf');
            $total = 0;
         foreach($delOrder as $value){
             $order = ROrder::model()->get(new MongoId($value));

+ 2 - 0
www/protected/modules/o2o/controllers/MyOrderController.php

@@ -140,6 +140,8 @@ class MyOrderController extends CController {
         $success = $order_obj->save();
         O2oApp::response($success, '保存失败,请重试', []);
     }
+
+
     /**
      * 用户签字保洁师确认完成
      */

+ 1 - 1
www/protected/modules/o2o/controllers/OrderController.php

@@ -66,7 +66,7 @@ class  OrderController extends O2oBaseController{
             if ($rows) {
                 foreach ($rows as $orders) {
                     //判断订单是否达到111单
-                    if ($total >= 200) {
+                    if ($total >= 111) {
                         CommonFn::requestAjax(false, '今天的双11订单已经抢购光了');
 
                     }

+ 211 - 147
www/protected/modules/o2o/views/myOrder/info.php

@@ -1,4 +1,5 @@
 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=B349f0b32ef6e78b2e678f45cb9fddaf"></script>
+<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/o2o/jq-signature.min.js"></script>
 <div>
     <div id="header">
         <div class="am-g">
@@ -82,185 +83,248 @@
             </div>
             <div class="am-g am-hide" id="come_container">
                 <div class="am-u-sm-12">
-                    <button class="am-btn am-btn-block am-btn-success" id="confirm_come">确认上门</button>
+                    <button class="am-btn am-btn-block am-btn-primary" id="confirm_come">确认上门</button>
                 </div>
             </div>
             <div class="am-g am-hide" id="has_come_container">
                 <div class="am-u-sm-12">
-                    <button class="am-btn am-btn-block am-btn-primary am-disabled">已上门</button>
+                    <button class="am-btn am-btn-block am-btn-primary">已上门</button>
                 </div>
             </div>
+            <div class="am-g am-hide" id="has_come_success">
+                <div class="am-u-sm-12">
+                    <button class="am-btn am-btn-block am-btn-primary am-disabled">已完成</button>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="container" id="pics" style="position: fixed;width: 100%;background: #ffff00;top:0;display: none;">
+    <div class="row">
+        <div class="col-xs-12">
+            <div class="js-signature"></div>
         </div>
+        <p style="margin: 0">
+            <button id="clearBtn" class="btn btn-default" onclick="clearCanvas();">清除</button>
+            &nbsp;
+            <button id="saveBtn" class="btn btn-default" onclick="saveSignature();" disabled>保存</button>
+        </p>
     </div>
 </div>
 <script type="text/javascript">
-document.title = '我的订单-详情';
-var order = <?php echo json_encode($order); ?>;
-var user = <?php echo json_encode($user); ?>;
-var showMap = false;
-
-var w_height = $(window).height();
-var map_height = w_height * 0.6;
-$('#map_container').css({height: map_height + 'px'});
-
-var v_order = new Vue({
-    el: '#info',
-    data: {
-        info: []
-    }
-});
+    $(document).on('ready', function () {
+        if ($('.js-signature').length) {
+            $('.js-signature').jqSignature();
+        }
+    });
+    $('.js-signature').eq(0).on('jq.signature.changed', function () {
+        $('#saveBtn').attr('disabled', false);
+    });
 
-$(function() {
-    getOrderInfo(order, user);
+</script>
 
-    // 显示地图
-    $('#showMap').click(function() {
-        address = v_order.info.address;
-        position = address.position;
-        if (!position) {
-            $.valert('定位信息未记录');
-            return false;
+<script type="text/javascript">
+    $('#pics').height($(window).height());//设置底层div高度
+    $("canvas").width($(window).width());//设置手写板宽度
+    $("canvas").height($(window).height() - ($('#saveBtn').height()));//设置手写板高度
+    var url;
+    document.title = '我的订单-详情';
+    var order = <?php echo json_encode($order); ?>;
+    var user = <?php echo json_encode($user); ?>;
+    var showMap = false;
+    var w_height = $(window).height();
+    var map_height = w_height * 0.6;
+    $('#map_container').css({height: map_height + 'px'});
+    var v_order = new Vue({
+        el: '#info',
+        data: {
+            info: []
         }
+    });
+    $(function () {
+        getOrderInfo(order, user);
+        // 显示地图
+        $('#showMap').click(function () {
+            address = v_order.info.address;
+            position = address.position;
+            if (!position) {
+                $.valert('定位信息未记录');
+                return false;
+            }
 
-        $('#map_box').show();
+            $('#map_box').show();
 
-        map = new BMap.Map('map_container');
-        point = new BMap.Point(position[0], position[1]);
-        marker = new BMap.Marker(point);
-        map.addOverlay(marker);
-        map.centerAndZoom(point, 15);
+            map = new BMap.Map('map_container');
+            point = new BMap.Point(position[0], position[1]);
+            marker = new BMap.Marker(point);
+            map.addOverlay(marker);
+            map.centerAndZoom(point, 15);
 
-        windowOpts = {
-            width: 200,
-            height: 100,
-            title: address.area
-        }
-        infoWindow = new BMap.InfoWindow(address.detail, windowOpts);
-        marker.addEventListener("click", function() {
-            map.openInfoWindow(infoWindow,point);
-        });
+            windowOpts = {
+                width: 200,
+                height: 100,
+                title: address.area
+            }
+            infoWindow = new BMap.InfoWindow(address.detail, windowOpts);
+            marker.addEventListener("click", function () {
+                map.openInfoWindow(infoWindow, point);
+            });
 
-    });
+        });
+        // 隐藏地图
+        $('#hideMap').click(function () {
+            $('#map_box').hide();
+        });
+        // 确认出发
+        $('#confirm_set_out').click(function () {
+            $.vloading('open');
+            $.post(
+                '/index.php?r=o2o/myOrder/techSetout',
+                {
+                    order: order,
+                    user: user
+                },
+                function (res) {
+                    $.vloading('close');
+                    var data = $.parseJSON(res);
+                    if (data.success) {
+                        $('#setout_container').addClass('am-hide');
+                        $('#come_container').removeClass('am-hide');
+                        $('#has_come_container').addClass('am-hide');
+                    } else {
+                        $.valert(data.msg);
+                    }
+                }
+            );
+        });
+        // 确认上门
+        $('#confirm_come').click(function () {
+            $('#pics').css('display', 'block');
+            $('.js-signature').eq(0).on('jq.signature.changed', function () {
+                $('#saveBtn').attr('disabled', false);
+            });
+            /*$.vloading('open');
+            $.post(
+                '/index.php?r=o2o/myOrder/techCome',
+                {
+                    order: order,
+                    user: user
+                },
+                function (res) {
+                    $.vloading('close');
+                    var data = $.parseJSON(res);
+                    if (data.success) {
+                        $('#setout_container').addClass('am-hide');
+                        $('#come_container').addClass('am-hide');
+                        $('#has_come_container').addClass('am-hide');
+//                        $('#has_come_success').removeClass('am-hide');
+                    } else {
+                        $.valert(data.msg);
+                    }
+                }
+            );*/
+        });
+        //已完成
+        $('#has_come_container').click(function () {
+            /*调出手写板*/
 
-    // 隐藏地图
-    $('#hideMap').click(function() {
-        $('#map_box').hide();
+        });
     });
-
-    // 确认出发
-    $('#confirm_set_out').click(function () {
-        $.vloading('open');
-        $.post(
-            '/index.php?r=o2o/myOrder/techSetout',
-            {
-                order: order,
-                user: user
-            },
-            function (res) {
-                $.vloading('close');
-                var data = $.parseJSON(res);
-                if (data.success) {
-                    $('#setout_container').addClass('am-hide');
-                    $('#come_container').removeClass('am-hide');
-                    $('#has_come_container').addClass('am-hide');
-                } else {
-                    $.valert(data.msg);
-                }
+    function putb64() {
+        var pic = url.replace("data:image/png;base64,", "");//需要提交的base64
+        var uri = "http://up.qiniu.com/putb64/-1";//提交地址
+        var xhr = new XMLHttpRequest();
+        xhr.onreadystatechange = function () {
+            if (xhr.readyState == 4) {
+                $.post(
+                    '/index.php?r=o2o/myOrder/techComplete',
+                    {
+                        order: order,
+                        user: user,
+                        o2oImage: xhr.responseText
+                    },
+                    function (res) {
+                        $.vloading('close');
+                        var data = $.parseJSON(res);
+                        if (data.success) {
+                            $('#setout_container').addClass('am-hide');
+                            $('#come_container').addClass('am-hide');
+                            $('#has_come_container').addClass('am-hide');
+                            $('#has_come_success').removeClass('am-hide');
+                        } else {
+                            $.valert(data.msg);
+                        }
+                    }
+                );
             }
-        );
-    });
+        }
+        xhr.open("POST", uri, true);
+        xhr.setRequestHeader("Content-Type", "application/octet-stream");
+        xhr.setRequestHeader("Authorization", "UpToken Kn8GNMFOLKTNMUaKZ6r1wnjsgTk4ideQifK3umUr:a-HCK5r5iPL8Bisb-mQLI21oZJM=:eyJzY29wZSI6ImF2YXRhcnMiLCJkZWFkbGluZSI6MTQ3NDQ1MTg0OTAwMDAwMDAwMH0=");
+        xhr.send(pic);
+    }
+    function saveSignature() {
+        $('#signature').empty();
+        url = $('.js-signature').eq(0).jqSignature('getDataURL');
+        if (url != undefined) {
+            $('#pics').css('display', 'none');
+            console.log(url);
+            //七牛上传照片
+            putb64();
+        }
+    }
+    function clearCanvas() {
+        $('.js-signature').eq(0).jqSignature('clearCanvas');
+        $('#saveBtn').attr('disabled', true);
+    }
+    function getOrderInfo(order, user) {
+        if (order.length == 0 || user.length == 0) {
+            $.valert('订单信息未录入');
+            return false;
+        }
 
-    // 确认上门
-    $('#confirm_come').click(function () {
         $.vloading('open');
         $.post(
-            '/index.php?r=o2o/myOrder/techCome',
+            '/index.php?r=o2o/o2oApp/getOrderInfo',
             {
-                order: order,
+                id: order,
                 user: user
             },
             function (res) {
                 $.vloading('close');
                 var data = $.parseJSON(res);
-                if (data.success) {
-                    $('#setout_container').addClass('am-hide');
-                    $('#come_container').addClass('am-hide');
-                    $('#has_come_container').removeClass('am-hide');
-                } else {
+                if (data.success == false) {
                     $.valert(data.msg);
-                }
-            }
-        );
-    });
-    //已完成
-   /* $('#success_come').click(function () {
-        $.vloading('open');
-        //签字页面 签字 上传七牛 获得一个链接
-        $.post(
-          '/index.php?r=o2o/myOrder/techCome',
-          {
-              order: order,
-              user: user,
-              o2oImage : ''
-          },
-          function (res) {
-              $.vloading('close');
-              var data = $.parseJSON(res);
-              if (data.success) {
-                  $('#setout_container').addClass('am-hide');
-                  $('#come_container').addClass('am-hide');
-                  $('#has_come_container').removeClass('am-hide');
-              } else {
-                  $.valert(data.msg);
-              }
-          }
-        );
-    });*/
-});
-
-function getOrderInfo(order, user) {
-    if (order.length == 0 || user.length == 0) {
-        $.valert('订单信息未录入');
-        return false;
-    }
-
-    $.vloading('open');
-    $.post(
-        '/index.php?r=o2o/o2oApp/getOrderInfo',
-        {
-            id: order,
-            user: user
-        },
-        function(res) {
-            $.vloading('close');
-            var data = $.parseJSON(res);
-            if (data.success == false) {
-                $.valert(data.msg);
-            } else {
-                var content = data.content;
-                v_order.info = content;
-                for(var j in content.technicians) {
-                    if (content.technicians[j]['technician_id'] == user) {
-                        console.log(content.status);
-                        if (content.status != 4 && content.status != 5 && $.inArray(content.status, [1, 2, 3]) != -1) {
-                            $('#setout_container').removeClass('am-hide');
-                            $('#come_container').addClass('am-hide');
-                            $('#has_come_container').addClass('am-hide');
-                        } else if (content.status == 4) {
-                            $('#setout_container').addClass('am-hide');
-                            $('#come_container').removeClass('am-hide');
-                            $('#has_come_container').addClass('am-hide');
-                        } else if (content.status == 5) {
-                            $('#setout_container').addClass('am-hide');
-                            $('#come_container').addClass('am-hide');
-                            $('#has_come_container').removeClass('am-hide');
+                } else {
+                    var content = data.content;
+                    v_order.info = content;
+                    for (var j in content.technicians) {
+                        if (content.technicians[j]['technician_id'] == user) {
+                            console.log(content.status);
+                            if (content.status != 4 && content.status != 5 && content.status != 6 && $.inArray(content.status, [1, 2, 3]) != -1) {
+                                $('#setout_container').removeClass('am-hide');
+                                $('#come_container').addClass('am-hide');
+                                $('#has_come_container').addClass('am-hide');
+                            } else if (content.status == 4) {
+                                $('#setout_container').addClass('am-hide');
+                                $('#come_container').removeClass('am-hide');
+                                $('#has_come_container').addClass('am-hide');
+                            } else if (content.status == 5) {
+                                $('#setout_container').addClass('am-hide');
+                                $('#come_container').addClass('am-hide');
+                                $('#has_come_container').removeClass('am-hide');
+                            } else if (content.status == 6) {
+                                $('#setout_container').addClass('am-hide');
+                                $('#come_container').addClass('am-hide');
+                                $('#has_come_container').addClass('am-hide');
+                                $('#has_come_success').removeClass('am-hide');
+                            }
+                            break;
                         }
-                        break;
                     }
+                    $('#info_content').show();
                 }
-                $('#info_content').show();
             }
-        }
-    );
-}
+        );
+    }
 </script>