<template>
    <view class="content">
        <statusNav navBarTitle="处理工单"></statusNav>
        
        <container-subgroup-two>
        <view slot="content" style="margin: 0 -25rpx;">
      <view class="work-order-schedule">
          <view class="li">
              <view class="icon  icon-after">
                  1
              </view>
              <view class="text">
                  签到执行
              </view> 
          </view>
          <view class="li">
              <view class="icon  icon-after">
                  2
              </view>
              <view class="text">
                  填写维保单
              </view>
          </view>
          <view class="li">
              <view class="icon on">
                  3
              </view>
              <view class="text">
                  结算审核
              </view>
          </view>
      </view>
      
      <view class="clearing-form">
          <view class="title">
              结算方式
          </view>
          <view class="clearing-form-content">
              <view class="li" @click="clearingFormFun(index)" v-for="(item,index) in clearingForm">
                  <image class="icon" v-if="item.state" src="../../static/iocn/xuanz.png" mode=""></image>
                  <image class="icon" v-else src="../../static/iocn/xuan.png" mode=""></image>
                  {{item.title}}
              </view>
          </view>
      </view>
      
      
      <view class="work-order-from">
          <picker mode="date" :value="date" @change="serveDate">
              <view class="serve-date">
                  <view class="text">
                      请选择服务时间
                  </view>
                  <image class="icon" src="../../static/iocn/jt.png" mode=""></image>
              </view>
          </picker>
      
      
          <view class="total-cost">
              <view class="li">
                  <view class="text">
                      上门费
                  </view>
                  <view class="price">
                      ￥120.00
                  </view>
              </view>
      
              <view class="li">
                  <view class="text on">
                      税金
                  </view>
                  <view class="price">
                      ￥120.00
                  </view>
              </view>
              <view class="li">
                  <view class="text">
                      材料费
                  </view>
                  <view class="price">
                      ￥120.00
                  </view>
              </view>
              <view class="li">
                  <view class="text">
                      其他费用
                  </view>
                  <view class="price">
                      ￥120.00
                  </view>
              </view>
          </view>
      
          <view class="total-price">
              费用合计<text class="money">￥580.00</text>
          </view>
          <picker @change="bindPickerChange" :value="index" :range="array">
              <view class="serve-date">
                  <view class="text">
                      请选择付款方式
                  </view>
                  <image class="icon" src="../../static/iocn/jt.png" mode=""></image>
              </view>
          </picker>
      
          <view class="is-invoice">
              <view class="text">
                  是否开票
              </view>
              <view class="radio" @click="isInvoiceFun(true)">
      
                  <image v-if="isInvoice" src="../../static/iocn/xz.png" class="icon" mode=""></image>
                  <view v-else class="icon1">
      
                  </view>
      
      
                  <text>是</text>
      
              </view>
              <view class="radio" @click="isInvoiceFun(false)">
      
                  <image v-if="!isInvoice" src="../../static/iocn/xz.png" class="icon" mode=""></image>
      
                  <view v-else class="icon1">
                  </view>
                  <text>否</text>
      
              </view>
          </view>
          <view class="is-invoice">
              <view class="text">
                  是否收款
              </view>
              <view class="radio" @click="isMoneyFun(true)">
      
                  <image v-if="isMoney" src="../../static/iocn/xz.png" class="icon" mode=""></image>
                  <view v-else class="icon1">
      
                  </view>
      
      
                  <text>是</text>
      
              </view>
              <view class="radio" @click="isMoneyFun(false)">
      
                  <image v-if="!isMoney" src="../../static/iocn/xz.png" class="icon" mode=""></image>
      
                  <view v-else class="icon1">
                  </view>
                  <text>否</text>
      
              </view>
          </view>
      
      
          <view class="customerSignature">
              <view class="title">
                  客户签名
              </view>
              <view class='contents'>
      
                  <canvas class='firstCanvas' canvas-id="firstCanvas" @touchmove='move' @touchstart='start($event)'
                      @touchend='end' @touchcancel='cancel' @longtap='tap' disable-scroll='true' @error='error'>
                  </canvas>
      
                  <!-- <button @click='clearClick'>清除</button> -->
                  <!--          <button @click='saveClick'>保存图片</button> -->
      
      
              </view>
      
              <view class="text" v-if="isCanvas">
                  请在此签名
              </view>
          </view>
      
          <view class="money-receiving-code">
              <view class="title">
                  <image src="../../static/iocn/shoukuan.png" class="icon" mode=""></image>
      
                  <view class="text">
                      微信、支付宝等收款码
                  </view>
              </view>
              <image src="../../static/iocn/jt.png" mode="" class="img"></image>
      
          </view>
      
          <view class="address">
              <image class="icon" src="../../static/iocn/dizi.png" mode=""></image>
              <view class="text ">
                  湖南省株洲市荷塘区红旗中路456号(五矿二十三冶)
              </view>
          </view>
      
      
          <view class="remark">
              <view class="title">
                  备注内容
              </view>
      
              <textarea class="textarea" value="" placeholder="请输入备注内容" />
          </view>
      </view>
      
      
      
      
      
      
      <button class="submit-button" type="default">提交审核</button>
                
            </view>
               </container-subgroup-two>

    </view>
</template>

<script>
    import statusNav from '../../components/status-nav.vue';
    import footTabOne from "../../components/foot-tabs/foot-tab-one.vue"
      import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
    var content = null;
    var touchs = [];
    var canvasw = 0;
    var canvash = 0;
    //获取系统信息
    uni.getSystemInfo({
        success: function(res) {
            canvasw = res.windowWidth;
            canvash = canvasw * 9 / 16;
        },
    })
    export default {
        components: {
            footTabOne,
            statusNav,
           containerSubgroupTwo
        },
        data() {
            return {
                signImage: '',
                date: "",
                clearingForm: [{
                        title: '单次付费',
                        state: true,
                    },

                    {
                        title: '质保免费',
                        state: false,
                    },
                    {
                        title: '验收扫尾',
                        state: false,
                    },
                    {
                        title: '包年签单',
                        state: false,
                    },


                ],
                isCanvas: true,
                array: ['微信', '支付宝', '现金', '类型'],
                isInvoice: true,
                isMoney: true,
            }
        },
        onLoad: function(options) {
            //获得Canvas的上下文
            content = uni.createCanvasContext('firstCanvas')
            //设置线的颜色
            content.setStrokeStyle("#000")
            //设置线的宽度
            content.setLineWidth(5)
            //设置线两端端点样式更加圆润
            content.setLineCap('round')
            //设置两条线连接处更加圆润
            content.setLineJoin('round')
        },
        methods: {
            clearingFormFun(index) {
                for (var i = 0; i < this.clearingForm.length; i++) {
                    this.clearingForm[i].state = false
                }
                this.clearingForm[index].state = true
            },
            serveDate(data) {
                console.log(data)
            },
            isInvoiceFun(is) {
                this.isInvoice = is
            },

            isMoneyFun(is) {
                this.isMoney = is
            },

            // 画布
            // 画布的触摸移动开始手势响应
            start: function(e) {
                this.isCanvas = false
                let point = {
                    x: e.touches[0].x,
                    y: e.touches[0].y,
                }

                touchs.push(point);

            },
            // 画布的触摸移动手势响应
            move: function(e) {
                let point = {
                    x: e.touches[0].x,
                    y: e.touches[0].y
                }
                touchs.push(point)
                if (touchs.length >= 2) {
                    this.draw(touchs)
                }
            },

            // 画布的触摸移动结束手势响应
            end: function(e) {
                console.log("触摸结束" + e)
                //清空轨迹数组
                for (let i = 0; i < touchs.length; i++) {
                    touchs.pop()
                }

            },

            // 画布的触摸取消响应
            cancel: function(e) {
                console.log("触摸取消" + e)
            },

            // 画布的长按手势响应
            tap: function(e) {
                console.log("长按手势" + e)
            },

            error: function(e) {
                console.log("画布触摸错误" + e)
            },

            //绘制
            draw: function(touchs) {
                let point1 = touchs[0]
                let point2 = touchs[1]
                touchs.shift()
                content.moveTo(point1.x, point1.y)
                content.lineTo(point2.x, point2.y)
                content.stroke()
                content.draw(true)
            },
            //清除操作
            clearClick: function() {
                //清除画布
                content.clearRect(0, 0, canvasw, canvash)
                content.draw(true)
            },
            //保存图片
            saveClick: function() {
                var that = this
                uni.canvasToTempFilePath({
                    canvasId: 'firstCanvas',

                    success: function(res) {
                        //打印图片路径
                        console.log(res.tempFilePath)
                        //设置保存的图片
                        that.signImage = res.tempFilePath
                    }
                })

            }



        }
    }
</script>

<style>


    .submit-button {
        width: 686rpx;
        border-radius: 50rpx;
        height: 90rpx;
        background-color: #02A2ea;
        line-height: 90rpx;
        color: #FFFFFF;
        margin-top: 60rpx;
        text-align: center;
        font-size: 30rpx;
    }

    .work-order-schedule {
        display: flex;
        padding: 22rpx 29rpx;
        margin-top: 10rpx;
        background-color: #FFFFFF;
        justify-content: space-between;
    }

    .work-order-schedule .icon {
        width: 38rpx;
        height: 38rpx;
        color: #FFFFFF;
        margin: auto;
        position: relative;
        font-size: 24rpx;
        margin-bottom: 10rpx;
        text-align: center;
        line-height: 38rpx;
        background-color: #999999;
        border-radius: 50%;

    }

    .work-order-schedule .on {
        background-color: #5391F3
    }

    .work-order-schedule .text {
        font-size: 24rpx;
        color: #333333;
    }

    .work-order-schedule .icon-after::after {
        content: "";
        width: 265rpx;
        height: 2rpx;
        background-color: #999999;
        position: absolute;
        top: 19rpx;
        left: 38rpx;
    }

    .clearing-form-content {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 0 30rpx;
        background-color: #FFFFFF;
        padding-top: 28rpx;
    }

    .clearing-form-content .li .icon {
        width: 32rpx;
        height: 32rpx;
        margin-right: 18rpx;
    }

    .clearing-form-content .li {
        width: 26%;
        display: flex;
        align-items: center;
        margin-bottom: 33rpx;
        font-size: 28rpx;
    }

    .clearing-form .title {

        font-size: 28rpx;
        color: #4d4b4b;
        padding: 20rpx 30rpx;
        font-size: 28rpx;
        color: #333333;
    }

    .serve-date {
        width: 100%;
        height: 80rpx;
        background-color: #FFFFFF;
        display: flex;
        justify-content: space-between;
        padding: 0 20rpx;
        box-sizing: border-box;
        align-items: center;
        margin-top: 14rpx;
    }

    .serve-date .text {
        font-size: 28rpx;
        color: #999999;
    }

    .serve-date .icon {
        font-size: 28rpx;
        color: #999999;
        width: 22rpx;
        height: 12rpx;
    }

    .work-order-from {
        padding: 0 13rpx;
    }

    .total-cost {
        margin-top: 14rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .total-cost .li {
        width: 355rpx;
        height: 80rpx;
        padding: 0 14rpx;
        background-color: #FFFFFF;
        line-height: 80rpx;
        display: flex;
        justify-content: space-between;
        border-radius: 8rpx;
        margin-bottom: 14rpx;
        box-sizing: border-box;
    }

    .total-cost .li .text {
        color: #999999;
        font-size: 26rpx;
    }

    .total-cost .li .on {
        letter-spacing: 45rpx;
    }

    .total-cost .li .price {
        color: #333333;
        font-size: 26rpx;
    }

    .total-price {
        width: 100%;
        height: 80rpx;
        background-color: #fff;
        font-size: 30rpx;
        line-height: 80rpx;
        text-align: center;
        color: #333333;
    }

    .total-price .money {
        color: #e52e2e;
        font-weight: bold;
    }

    .is-invoice {
        width: 100%;
        height: 80rpx;
        background-color: #fff;
        display: flex;
        align-items: center;
        padding: 0 20rpx;
        margin-top: 13rpx;
        box-sizing: border-box;
    }

    .is-invoice .text {
        font-size: 26rpx;
        margin-right: 60rpx
    }

    .is-invoice .radio .icon {
        width: 26rpx;
        height: 26rpx;
        background-color: #00A2E9;
        border-radius: 50%;

        margin-right: 20rpx;
    }

    .is-invoice .radio .icon1 {
        width: 26rpx;
        height: 26rpx;
        border-radius: 50%;
        box-sizing: border-box;
        margin-right: 20rpx;
        border: solid 2rpx #eeeeee;
    }

    .is-invoice .radio {
        display: flex;
        font-size: 26rpx;
        align-items: center;
        margin-right: 40rpx;
    }

    .customerSignature .title {
        font-size: 30rpx;
        font-weight: bold;
        margin-bottom: 20rpx;
    }

    .customerSignature {
        margin-top: 13rpx;
        padding: 24rpx 13rpx;
        background-color: #FFFFFF;
        position: relative;
    }

    content {
        width: 100%;
    }

    .customerSignature .text {
        position: absolute;
        top: 50%;
        width: 100%;
        text-align: center;
        color: #cccccc;
    }

    .firstCanvas {
        background-color: #FFFFFF;
        width: 100%;
        height: 250rpx;
    }

    .contents image {
        width: 100%;
        height: 200px;
        background-color: orange;
    }

    .firstCanvas {
        border: 2rpx dashed #cccccc;
        border-radius: 10rpx;
    }

    .money-receiving-code {
        width: 100%;
        height: 80rpx;
        display: flex;
        padding: 0rpx 13rpx;
        align-items: center;
        margin-top: 13rpx;
        box-sizing: border-box;
        background-color: #FFFFFF;
        justify-content: space-between;
    }

    .money-receiving-code .title {
        display: flex;
        align-items: center;

    }

    .money-receiving-code .title .icon {
        width: 22rpx;
        height: 22rpx;
        margin-right: 30rpx;
    }

    .money-receiving-code .title .text {
        font-size: 26rpx;
        color: #333333;
    }

    .money-receiving-code .img {
        width: 22rpx;
        height: 12rpx;
        transform: rotateZ(-90deg);
    }

    .address {
        width: 100%;
        height: 80rpx;
        background-color: #FFFFFF;
        display: flex;
        align-items: center;
        margin-top: 13rpx;
        box-sizing: border-box;
        padding: 0rpx 13rpx;
    }

    .address .icon {
        width: 24rpx;
        height: 32rpx;
        margin-right: 30rpx;
    }

    .address .text {
        font-size: 26rpx;
        color: #5d5c5c;
    }

    .remark {
        width: 100%;
        margin-top: 13rpx;
        background-color: #FFFFFF;
        padding: 20rpx 14rpx;
        height: 360rpx;
        box-sizing: border-box;
    }

    .remark .title {
        margin-bottom: 30rpx;
        font-size: 28rpx;
        font-weight: bold;
    }

    .remark .textarea {

        width: 100%;
        box-sizing: border-box;
        background-color: #f5f5f5;
        height: 193rpx;
        border-radius: 10rpx;
        padding: 23rpx;
    }
</style>
