DengTao 8 жил өмнө
parent
commit
9fe6bca980

+ 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);

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

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

+ 118 - 5
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,18 +83,52 @@
             </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>
+                <div class="am-u-sm-12" >
+                    <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;">
+    <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).on('ready', function () {
+        if ($('.js-signature').length) {
+            $('.js-signature').jqSignature();
+        }
+    });
+    $('.js-signature').eq(0).on('jq.signature.changed', function () {
+        $('#saveBtn').attr('disabled', false);
+    });
+
+</script>
+
 <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); ?>;
@@ -186,14 +221,29 @@ $(function() {
                     $('#setout_container').addClass('am-hide');
                     $('#come_container').addClass('am-hide');
                     $('#has_come_container').removeClass('am-hide');
+                    $('#has_come_success').addClass('am-hide');
                 } else {
                     $.valert(data.msg);
                 }
             }
         );
     });
+    //提上门
     //已完成
-   /* $('#success_come').click(function () {
+    $('#has_come_container').click(function () {
+
+        /*调出手写板*/
+        $('#pics').css('display','block');
+        $('.js-signature').eq(0).on('jq.signature.changed', function () {
+            $('#saveBtn').attr('disabled', false);
+        });
+
+        //$.vloading('open');
+
+
+
+    });
+  /*  $('#success_come').click(function () {
         $.vloading('open');
         //签字页面 签字 上传七牛 获得一个链接
         $.post(
@@ -218,6 +268,64 @@ $(function() {
     });*/
 });
 
+
+    function putb64(){
+
+
+
+        var pic = url.replace("data:image/png;base64,"," ");
+        var uri = "http://odulcd8g1.bkt.clouddn.com";
+        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", "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();
+
+
+    }
+
+    //return dataUrl;
+}
+function clearCanvas() {
+//    $('#signature').html('<p><em>Your signature will appear here when you click "Save Signature"</em></p>');
+    $('.js-signature').eq(0).jqSignature('clearCanvas');
+    $('#saveBtn').attr('disabled', true);
+}
 function getOrderInfo(order, user) {
     if (order.length == 0 || user.length == 0) {
         $.valert('订单信息未录入');
@@ -242,7 +350,7 @@ function getOrderInfo(order, user) {
                 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) {
+                        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');
@@ -254,6 +362,11 @@ function getOrderInfo(order, user) {
                             $('#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;
                     }