riku
2026-03-05 9465dc404f7e7cd56100e4859ee0946a3fef7b09
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
// pages/promisefile/promisefile.js
const { promise } = require('../../../data/promise');
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;
      },
    );
 
    let st = app.globalData.userInfo.extension2;
    let t = promise[st];
    this.setData({
      promiseText: promise[st],
    });
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // this.selectComponent('#sign-dialog').init()
  },
 
  startSign() {
    var that = this;
 
    wx.navigateTo({
      url: '/pages/mPromise/promisesign/promisesign',
      events: {
        onSignSuccess: function (imgPath) {
          console.log('signover:' + imgPath);
          that.signOver(imgPath);
        },
      },
    });
 
    // wx.getStorage({
    //   key: 'signPath',
    //   success: (result) => {
    //     console.log(result.data);
    //     that.signOver(result.data)
    //   },
    //   fail: (res) => {
    //     console.log(res);
    //     wx.navigateTo({
    //       url: '/pages/promisesign/promisesign',
    //       events: {
    //         onSignSuccess: function (imgPath) {
    //           console.log('signover:' + imgPath);
    //           that.signOver(imgPath)
    //         }
    //       },
    //     })
    //   },
    //   complete: (res) => {},
    // })
  },
 
  signOver(imgPath) {
    let path = 'imgFiles[0]';
    this.setData({
      [path]: imgPath,
    });
  },
 
  onSubmit: function () {
    // wx.setStorage({
    //   key: "promise",
    //   data: true,
    // })
    // wx.navigateTo({
    //   url: '/pages/promiseresult/promiseresult',
    // })
    wx.showLoading({
      title: '承诺书生成中',
      mask: true,
      success: res => {},
      fail: res => {},
      complete: res => {},
    });
    // setTimeout(() => {
    //   wx.hideLoading()
    // }, 20000);
 
    let signPic = this.data.imgFiles[0];
 
    promiseservice.createCommitment(
      app.globalData.accessToken.userId,
      this.commitmentVo,
      signPic,
      {
        success(data) {
          if (data.success) {
            wx.navigateTo({
              url: '/pages/mPromise/promiseresult/promiseresult',
              success: function (res) {
                console.log(res);
                // 通过 eventChannel 向被打开页面传送数据
                res.eventChannel.emit('acceptDataFromOpenerPage', {
                  promise: {
                    picPath: data.data[0],
                    pdfPath: data.data[1],
                  },
                });
              },
            });
          }
        },
        fail(res) {},
        complete(res) {
          console.log(res);
          wx.hideLoading({});
        },
      },
    );
  },
});