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
| // 开卡选择虚拟卡
| const {
| get,
| post
| } = require('../../api/request.js');
| Page({
|
| /**
| * 页面的初始数据
| */
| data: {
| intakeId: 0,
|
| allCardPoints: [] // 所有虚拟卡
| },
| openValva(event) {
| const {
| item
| } = event.currentTarget.dataset; // 获取当前点击的 item
| if (item.inUse === 0) {
| // 在页面加载时显示加载动画
| wx.showLoading({
| title: '正在开泵请稍候...', // 加载提示文字
| mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false
| });
| this.postOpenValva(item.vcId);
| }
| },
| //开泵通信
| postOpenValva(vcId) {
| const app = getApp();
| const data = {
| intakeId: this.data.intakeId, //取水口ID
| vcId: vcId, //虚拟卡ID
| operator: app.globalData.operator //操作员
| };
| post({
| url: "8087/wx/valve/open_wx",
| data: data
| }).then(response => {
|
| // 处理成功响应
| console.log('请求成功:', response);
| // 加载完成后隐藏加载动画
| wx.hideLoading();
| //完成后回到首页
| wx.reLaunch({
| url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写
| });
|
| }).catch(error => {
| // 加载完成后隐藏加载动画
| wx.hideLoading();
| // 处理错误响应
| console.error('请求失败:', error);
| if (error.code === "1002") {
| wx.showToast({
| title: '开泵失败',
| icon: 'error',
| duration: 3000 // 提示的持续时间,单位毫秒
| })
| }
| });
| },
| /**
| * 生命周期函数--监听页面加载
| */
| onLoad(options) {
| const {
| intakeId
| } = options;
| this.setData({
| intakeId
| })
| console.log('intakeId:' + this.data.intakeId);
| this.getCardList();
| },
|
| /**
| * 生命周期函数--监听页面初次渲染完成
| */
| onReady() {
|
| },
|
| /**
| * 生命周期函数--监听页面显示
| */
| onShow() {
|
| },
|
| /**
| * 生命周期函数--监听页面隐藏
| */
| onHide() {
|
| },
|
| /**
| * 生命周期函数--监听页面卸载
| */
| onUnload() {
|
| },
|
| /**
| * 页面相关事件处理函数--监听用户下拉动作
| */
| onPullDownRefresh() {
|
| },
|
| /**
| * 页面上拉触底事件的处理函数
| */
| onReachBottom() {
|
| },
|
| /**
| * 用户点击右上角分享
| */
| onShareAppMessage() {
|
| },
| //获取虚拟卡列表
| getCardList() {
| get({
| url: '8084/sell/virtual_card/get',
| data: {
| clientId: getApp().globalData.sessionId
| }
| })
| .then((data) => {
| if (data.success && data.code === "0001") {
| this.setData({
| allCardPoints: data.content
| });
| } else {
| wx.showToast({
| title: data.msg,
| })
| }
| console.log('Failed to add item:');
| })
| .catch((error) => {
|
|
| console.error('Failed to add item:', error);
| });
| }
| })
|
|