riku
2022-08-05 45b2c022e27dda53ee4e5266fbdbdf1ac3aa4c65
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
// pages/promisefile/promisefile.js
const promiseservice = require("../../service/promiseservice")
const app = getApp()
 
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    imgFiles: []
  },
 
  commitmentVo: {
    city: '',
    district: '',
    department: '',
    socialCode: '',
    number: '',
    juridicalPerson: '',
    idNo: '',
    type1: false,
    type2: false,
    type3: false,
    type4: false,
    year: '',
    month: '',
    day: ''
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var date = new Date()
    var year = date.getFullYear()
    var mon = date.getMonth() + 1
    var day = date.getDate()
    this.setData({
      date: `${year}年${mon}月${day}日`
    })
 
    this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) {
      that.commitmentVo = data
    })
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // this.selectComponent('#sign-dialog').init()
  },
 
  startSign() {
    var that = this
    wx.navigateTo({
      url: '/pages/promisesign/promisesign',
      events: {
        onSignSuccess: function (imgPath) {
          console.log('signover:' + imgPath);
          that.signOver(imgPath)
        }
      },
    })
  },
 
  signOver(imgPath) {
    let path = "imgFiles[0]"
    this.setData({
      [path]: imgPath
    })
  },
 
  onSubmit: function () {
    wx.setStorage({
      key: "promise",
      data: true,
    })
    // wx.navigateTo({
    //   url: '/pages/promiseresult/promiseresult',
    // })
 
    let signPic = this.data.imgFiles[0]
 
    promiseservice.createCommitment(app.globalData.accessToken.userId, this.commitmentVo, signPic, {
      success(data) {
        console.log(data);
      },
      fail(res) {
        console.log(res);
      },
      complete(res) {
        console.log(res);
      }
    })
 
  }
})