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
| // 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',
| // })
| 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.data.success) {
| wx.navigateTo({
| url: '/pages/promiseresult/promiseresult',
| success: function (res) {
| // 通过 eventChannel 向被打开页面传送数据
| res.eventChannel.emit('acceptDataFromOpenerPage', {
| promise: {
| picPath: data.data[0],
| pdfPath: data.data[1],
| }
| })
| }
| })
| }
| },
| fail(res) {
| },
| complete(res) {
| console.log(res);
| wx.hideLoading({
| success: (res) => {
| wx.showToast({
| title: '生成完成',
| duration: 1500,
| icon: 'success',
| })
| },
| })
| }
| })
|
| }
| })
|
|