orderbox.js 18.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
// pages/orderbox/orderbox.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    order: 1,
    ordersid: 1,
    ordertype: '',
    page: 1,
    orderlist: [],
    xizaicode: false,
    video: [],
    pic: [],
    money: "",
    type: 1,
    yu: true,
    wei: false,
    myinfo: '',
    order_id: '',
    xiaquan: false,
    cancelorder: false,
    ids: [],
    xieyi: false,
    jump: '',
    hexizaicode: false,
    kai: 1,
    name: '',
    use: '',
    shouwrap: false,
    pic_id: '',
    video_id: '',
    downloadid: '',
    tel: '',
    quxiao: false,
    quxiaoid: [],
    shouwrapall: false,
    showyou:false,
    email:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      jump: options.jump
    })
    this.getmyorder()
  },

  // 使用人
  username(e) {
    this.setData({
      name: e.detail.value
    })
  },
  // 用途
  use(e) {
    this.setData({
      use: e.detail.value
    })
  },

  // 联系方式
  lianxiphone(e) {
    this.setData({
      tel: e.detail.value
    })
  },

  // 邮箱
  email(e){
    this.setData({
      email:e.detail.value
    })
  },

  hideshou() {
    this.setData({
      shouwrap: false
    })
  },

  // 选择发票类型
  xuanfapiao(e) {
    console.log(999);
    console.log(e)
    let kai = e.currentTarget.dataset.kai
    this.setData({
      kai: kai
    })


  },
  hidecancel() {
    this.setData({
      cancelorder: false
    })
  },
  // 选择总的合并下载
  selxia() {
    this.setData({
      xiaquan: !this.data.xiaquan
    })

    let neworderlist = this.data.orderlist;
    let newvideo = [];
    let newpic = [];
    let newids = this.data.ids;

    if (this.data.xiaquan == true) {
      for (var obj of neworderlist) {
        obj.sel = true;
        newids.push(obj.id)
        if (obj.video_id != null) {
          for (var pp of obj.video_id) {
            newvideo.push(pp)
          }

        }
        if (obj.pic_id != null) {
          for (var pp of obj.pic_id) {
            newpic.push(pp)
          }

        }
      }
    } else {
      for (var obj of neworderlist) {
        obj.sel = false;

      }

      newvideo = [];
      newpic = [];
      newids = []


    }




    this.setData({
      orderlist: neworderlist,
      pic: newpic,
      video: newvideo,
      ids: newids

    })

    console.log(this.data.pic);
    console.log(this.data.video);
    console.log(this.data.ids)
  },

  // 合并下载地址
  hexiazaiaddress() {
    console.log(this.data.video, this.data.pic)
    if (this.data.video.length == 0 && this.data.pic.length == 0) {
      wx.showToast({
        title: '请选择要合并的图片或视频',
        icon: "none"
      })
    } else {
      this.setData({
        hexizaicode: true
      })
    }

  },

  // 选择单个合并下载
  xuanzehe(e) {
    console.log(e)
    let id = e.currentTarget.dataset.orderid;
    console.log(id)
    let neworderlist = this.data.orderlist;
    let newpic = this.data.pic;
    let newvideo = this.data.video;
    let newids = this.data.ids;

    for (var obj of neworderlist) {
      if (obj.id == id) {
        obj.sel = !obj.sel;
        if (obj.sel == true) {
          newids.push(id)
          if (obj.video_id != null) {
            for (var pp of obj.video_id) {
              newvideo.push(pp)
            }
          }

          if (obj.pic_id != null) {
            for (var pp of obj.pic_id) {
              newpic.push(pp)
            }
          }
        } else if (obj.sel == false) {
          for (var i = 0; i < newids.length; i++) {
            if (newids[i] == obj.id) {
              newids.splice(i, 1)
            }

          }
        }
      }
    }

    if (newids.length == this.data.orderlist.length) {
      this.setData({
        xiaquan: true
      })
    } else {
      this.setData({
        xiaquan: false
      })
    }

    this.setData({
      pic: newpic,
      video: newvideo,
      orderlist: neworderlist,
      ids: newids
    })

    console.log(this.data.ids)
  },

  //获取我的订单
  getmyorder() {
    console.log(9999)
    let that = this;
    let url = 'user/myorder';
    let param = {
      type: that.data.ordertype,
      page: that.data.page,
      pageNum: 10


    }
    app.post(url, param, 'post').then((res) => {
      console.log(res);

      for (var obj of res) {
        obj.sel = false
      }
      that.setData({
        orderlist: that.data.orderlist.concat(res)
      })
    }).catch((err) => {

    })

  },
  ordersel(e) {


    this.setData({
      order: e.currentTarget.dataset.id,
      ordersid: e.currentTarget.dataset.id,
      orderlist: [],
      page: 1
    })
    if (e.currentTarget.dataset.id == 1) {
      this.setData({
        type: 0,
        ordertype: ''
      })
    } else if (e.currentTarget.dataset.id == 2) {
      this.setData({
        type: 1,
        ordertype: 1
      })
    } else if (e.currentTarget.dataset.id == 3) {
      this.setData({
        type: 2,
        xiaquan: false,
        ordertype: 2

      })
    }

    this.getmyorder()

  },
  hideyou(){
    console.log(999)
    this.setData({
      showyou:false
    })
  },

  xiazaiaddress(e) {
    let video = e.currentTarget.dataset.video;
    let pic = e.currentTarget.dataset.pic;


    console.log(video);
    this.setData({
      video: video,
      pic: pic,
      xizaicode: true
    })
  },

  copy(e) {
    console.log(e)

    console.log(e.currentTarget.dataset.url)
    wx.setClipboardData({
      data: '链接:' + e.currentTarget.dataset.url + '提取码:' + e.currentTarget.dataset.code,
      success: function(res) {
        wx.getClipboardData({
          success: function(res) {
            wx.showToast({
              title: '复制成功',
              icon: 'none'
            })
          }
        })
      }
    })
  },
  // 隐藏下载地址
  hidexiazai() {
    this.setData({
      xizaicode: false
    })
  },
  // 隐藏合并下载地址
  hidehexiazai() {
    this.setData({
      hexizaicode: false
    })
  },
  hidetixian() {
    this.setData({
      tixian: false
    })
  },
  // 余额支付和微信支付
  yuzhi() {
    this.setData({
      yu: !this.data.yu,
      wei: false
    })

    if (this.data.yu == true) {
      this.setData({
        type: 1
      })
    } else {
      this.setData({
        type: 0
      })
    }
  },

  weizhi() {
    this.setData({
      wei: !this.data.wei,
      yu: false
    })

    if (this.data.wei == true) {
      this.setData({
        type: 2
      })
    } else {
      this.setData({
        type: 0
      })
    }
  },

  xuanxie() {
    this.setData({
      xieyi: !this.data.xieyi
    })
  },
  zhifu(e) {
    this.setData({
      tixian: true
    })

    console.log(e)
    let orderid = e.currentTarget.dataset.orderid
    this.setData({
      order_id: orderid
    })

  },

  zhifuque() {
    let that = this;

    console.log(that.data.type);
    console.log(this.data.xieyi)

    if (this.data.type == 0) {
      wx.showToast({
        title: '请选择支付方式',
        icon: 'none'
      })

      return false
    }

    if (this.data.xieyi == false) {
      wx.showToast({
        title: '请勾选服务协议',
        icon: 'none'
      })

      return false
    }


    let url = 'pay/picpay';
    let param = {
      order_id: that.data.order_id,
      type: that.data.type
    }
    app.post(url, param, 'post').then((res) => {
      console.log(res);

      that.setData({
        orderlist: [],
        page: 1,
        type: ''
      })
      wx.showToast({
        title: res,
        icon: 'none'
      })

      setTimeout(function() {
        that.setData({
          tixian: false
        })

        that.getmyorder()
        // wx.navigateTo({
        //   url: '/pages/orderbox/orderbox',
        // })
      }, 1500)



    }).catch((err) => {
      console.log('9999', err);
      console.log(err.msg.msg)
      wx.showToast({
        title: err.msg.msg,
        icon: 'none'
      })

    })


  },

  delorder(e) {
    let orderid = e.currentTarget.dataset.id;
    let newids = []
    newids.push(orderid)
    this.setData({
      cancelorder: true,
      ids: newids

    })

  },
  cancelorder() {
    this.setData({
      cancelorder: false
    })
  },

  suredel() {
    let that = this;

    console.log(that.data.ids)
    let ids = JSON.stringify(that.data.ids)
    wx.navigateTo({
      url: '/pages/kaifapiao/kaifapiao?ids=' + ids,
    })
    // if (that.data.ids.length == 0) {
    //   wx.showToast({
    //     title: '请选择要删除的订单',
    //     icon: 'none'
    //   })
    // } else {

    //   let url = 'user/delorder';
    //   let param = {
    //     ids: that.data.ids.join(",")
    //   }
    //   app.post(url, param, 'post').then((res) => {
    //     console.log(res);
    //     wx.showToast({
    //       title: '删除订单成功',
    //       icon: 'none'
    //     })

    //     setTimeout(function() {
    //       that.setData({
    //         orderlist: [],
    //         page: 1,
    //         cancelorder: false,
    //         ids: []
    //       })
    //       that.getmyorder()
    //     }, 1500)
    //   }).catch((err) => {

    //   })
    // }



  },

  // 删除订单
  shanorder(e) {
    let newquxiaoid = [];
    newquxiaoid.push(e.currentTarget.dataset.id)
    this.setData({
      quxiao: true,
      quxiaoid: newquxiaoid
    })
  },
  cancelquxiao() {
    this.setData({
      quxiao: false
    })
  },

  surequxiao() {
    let that = this;
    let url = 'user/delorder';
    let param = {
      ids: that.data.quxiaoid.join(",")
    }
    app.post(url, param, 'post').then((res) => {
      console.log(res);
      wx.showToast({
        title: '取消订单成功',
        icon: 'none'
      })

      setTimeout(function() {
        that.setData({
          orderlist: [],
          page: 1,
          quxiao: false,
          quxiaoid: []
        })
        that.getmyorder()
      }, 1500)
    }).catch((err) => {

    })

  },
  // 全部选择删除订单
  shanchu() {

    if (this.data.ids.length == 0) {
      wx.showToast({
        title: '请选择申请开票的视频或图片',
        icon: 'none'
      })
    } else {
      this.setData({
        cancelorder: true
      })
    }

  },
  ti() {


  },
  download(e) {
    console.log(e)
    let that = this;
    let id = e.currentTarget.dataset.id;
    let downarr = [];
    downarr.push(id)
    // let pic = e.currentTarget.dataset.pic;
    // let video = e.currentTarget.dataset.video;
    // console.log(pic);
    // console.log(video)


    // console.log(id);
    // console.log(pic);
    // console.log(video);
    // if (pic == null) {
    //   console.log()
    //   that.setData({
    //     video_id: video[0].info.id
    //   })


    // }


    // if (video == null) {
    //   console.log(pic)
    //   that.setData({
    //     pic_id: pic[0].id
    //   })

    // };

    console.log(that.data.pic_id)

    that.setData({
      downloadid: downarr,
      shouwrap: true
    })

  },

  surexia() {
    let that = this;
  
    if (that.data.name == '') {
      wx.showToast({
        title: '请输入使用人',
        icon: "none"
      })

      return false
    }

    if (that.data.use == '') {
      wx.showToast({
        title: '请输入用途',
        icon: "none"
      })

      return false
    }

    if (that.data.tel == '') {
      wx.showToast({
        title: '请输入联系方式',
        icon: "none"
      })

      return false
    }

    if (that.data.email == '') {
      wx.showToast({
        title: '请输入邮箱',
        icon: "none"
      })

      return false
    }

    if (that.data.email != '') {
      // var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");//邮箱//邮箱
      // let reg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
      //  var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/;

      var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
      if (!reg.test(that.data.email)) {
        wx.showToast({
          title: '请输入正确的邮箱格式',
          icon: "none"
        })
        return false;
      }

      

      
     

      

     
    }

    var url = 'user/show';
    var params = {
      order_id: that.data.downloadid.join(","),
      name: that.data.name,
      use: that.data.use,
      tel: that.data.tel,
      email:that.data.email

    }

    console.log('00999',params)
    app.post(url, params).then((res) => {
      console.log(res);
      wx.showToast({
        title: '授权书已发送到您的邮箱',
        icon:'none'
      })
      wx.downloadFile({

        url: res,

        success: function(res) {

          var filePath = res.tempFilePath;

          console.log(res)

          //页面显示加载动画

          wx.openDocument({

            filePath: filePath,

            success: function(res) {

              //  that.setData({

              //     loadingHidden: true

              //   })

              console.log('打开文档成功')

            }

          })

        }

      })


    }).catch((err) => {
      console.log(err)
      wx.showToast({
        title: '您已发送过邮件',
        icon: 'none'
      })
    })


  },
  hideshouall() {
    this.setData({
      shouwrapall: false
    })
  },

  // 全部下载
  downloadall(){
    let neworderlist=this.data.orderlist;
    // let arr=[];

    // for(var obj of neworderlist){
    //     arr.push(obj.id)
    // }

    // this.downloadid=arr;
    if (this.data.ids.length==0){
      wx.showToast({
        title: '请选择合并的视频或图片',
        icon:"none"
      })

      return false
    }

     this.setData({
       shouwrapall:true
     })
  },

  surexiaquan() {
    let that = this;
    console.log(that.data.tel)
    if (that.data.name == '') {
      wx.showToast({
        title: '请输入使用人',
        icon: "none"
      })

      return false
    }

    if (that.data.use == '') {
      wx.showToast({
        title: '请输入用途',
        icon: "none"
      })

      return false
    }

    if (that.data.tel == '') {
      wx.showToast({
        title: '请输入联系方式',
        icon: "none"
      })

      return false
    }

    if (that.data.email == '') {
      wx.showToast({
        title: '请输入邮箱',
        icon: "none"
      })

      return false
    }

    if (that.data.email != '') {
      wx.showToast({
        title: '请输入邮箱',
        icon: "none"
      })

      return false
    }

    if (that.data.email != '') {
      // var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");//邮箱//邮箱
      var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
      if (!reg.test(that.data.email)) {
        wx.showToast({
          title: '请输入正确的邮箱格式',
          icon: "none"
        })
        return false;
      }



    }


    var url = 'user/show';
    var params = {
      order_id: that.data.ids.join(","),
      name: that.data.name,
      use: that.data.use,
      tel: that.data.tel

    }
    app.post(url, params).then((res) => {
      console.log(res);
      wx.showToast({
        title: '授权书已发送到您的邮箱',
        icon:'none'
      })
      wx.downloadFile({

        url: res,

        success: function(res) {

          var filePath = res.tempFilePath;

          console.log(res)

          //页面显示加载动画

          wx.openDocument({

            filePath: filePath,

            success: function(res) {

              //  that.setData({

              //     loadingHidden: true

              //   })

              console.log('打开文档成功')

            }

          })

        }

      })


    }).catch((err) => {
      console.log(err)
      wx.showToast({
        title: err.msg,
        icon: 'none'
      })
    })

  },
  // 合并复制
  hecopy() {
    let bigvideo = [];
    let newvideo = this.data.video;
    let newpic = this.data.pic;
    if (newvideo.length != 0) {
      for (var i = 0; i < newvideo.length; i++) {
        bigvideo.push(newvideo[i])
      }
    }
    if (newpic.length != 0) {
      for (var i = 0; i < newpic.length; i++) {
        bigvideo.push(newpic[i])
      }
    }
    let data = ''
    console.log(bigvideo)

    for (var i = 0; i < bigvideo.length; i++) {
      if (bigvideo[i].info != undefined) {
        if (bigvideo[i].info.attr == 1) {
          data = data + bigvideo[i].info.title + '链接:' + bigvideo[i].info.two_url + '提取码:' + bigvideo[i].info.two_code
        } else if (bigvideo[i].info.attr == 2) {
          data = data + bigvideo[i].info.title + '链接:' + bigvideo[i].info.four_url + '提取码:' + bigvideo[i].info.four_code
        } else if (bigvideo[i].info.attr == 3) {
          data = data + bigvideo[i].info.title + '链接:' + bigvideo[i].info.eight_url + '提取码:' + bigvideo[i].info.eight_code
        }

      } else {
        data = data + bigvideo[i].title + '链接:' + bigvideo[i].url + '提取码:' + bigvideo[i].code
      }

    }


    wx.setClipboardData({
      data: data,
      success: function(res) {
        wx.getClipboardData({
          success: function(res) {
            wx.showToast({
              title: '复制成功',
              icon: 'none'
            })
          }
        })
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.setData({
      cancelorder: false,
      ids: [],
      xiaquan: false,
      video: [],
      pic: []
    })
    let neworderlist = this.data.orderlist;
    for (var obj of neworderlist) {

      obj.sel = false
    }
    this.setData({
      orderlist: neworderlist
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

    if (this.data.jump == 1) {
      wx.navigateTo({
       
        url: '/pages/homepage/homepage',
      })
    }

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    let newpage = this.data.page;
    newpage++;
    this.setData({
      page: newpage
    })

    this.getmyorder()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})