201 lines
4.7 KiB
JavaScript
201 lines
4.7 KiB
JavaScript
// packageD/energy/cancellation/cancellation.js
|
|
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
rewardMoneyBtn: false,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options.id) {
|
|
this.setData({
|
|
id: options.id,
|
|
});
|
|
}
|
|
if (options.scene) {
|
|
let scene = decodeURIComponent(options.scene);
|
|
if (scene) {
|
|
var info_arr = [];
|
|
info_arr = scene.split(",");
|
|
for (let i = 0; i < info_arr.length; i++) {
|
|
let chil_arr = [];
|
|
chil_arr = info_arr[i].split("=");
|
|
console.log(chil_arr);
|
|
if (chil_arr[0] == "id") {
|
|
this.setData({
|
|
id: chil_arr[1],
|
|
});
|
|
}
|
|
if (chil_arr[0] == "mid") {
|
|
app._setMid(chil_arr[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.getData();
|
|
},
|
|
change(e) {
|
|
let val = e.detail.value;
|
|
console.log(val);
|
|
if (val == this.data.result.familyCard.id) {
|
|
try {
|
|
this.data.result.familyCard.checked = true;
|
|
this.data.result.onceCard.checked = false;
|
|
this.data.result.timeCard.checked = false;
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
} else if (val == this.data.result.onceCard.id) {
|
|
try {
|
|
this.data.result.familyCard.checked = false;
|
|
this.data.result.onceCard.checked = true;
|
|
this.data.result.timeCard.checked = false;
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
} else if (val == this.data.result.timeCard.id) {
|
|
try {
|
|
this.data.result.familyCard.checked = false;
|
|
this.data.result.onceCard.checked = false;
|
|
this.data.result.timeCard.checked = true;
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
} else {
|
|
try {
|
|
this.data.result.familyCard.checked = false;
|
|
this.data.result.onceCard.checked = false;
|
|
this.data.result.timeCard.checked = false;
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
|
|
for (let i = 0; i < this.data.result.familyMemberCard.length; i++) {
|
|
if (val == this.data.result.familyMemberCard[i].id) {
|
|
this.data.result.familyMemberCard[i].checked = true;
|
|
} else {
|
|
this.data.result.familyMemberCard[i].checked = false;
|
|
}
|
|
}
|
|
}
|
|
this.setData({
|
|
result: this.data.result,
|
|
select_un: val,
|
|
});
|
|
},
|
|
onClose() {
|
|
this.setData({
|
|
rewardMoneyBtn: false,
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
confirm() {
|
|
let json = {
|
|
device_id: this.data.id,
|
|
card_id: this.data.select_un,
|
|
};
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.energy-cabin.frontend.use-device.confirm-use"
|
|
);
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: function (resdata) {
|
|
var res = resdata.data;
|
|
if (res.result === 1) {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: "none",
|
|
});
|
|
that.getData();
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
duration: 1000,
|
|
icon: "none",
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
getData() {
|
|
let that = this;
|
|
let json = {
|
|
device_id: that.data.id,
|
|
};
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.energy-cabin.frontend.use-device.index"
|
|
);
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: function (resdata) {
|
|
var res = resdata.data;
|
|
if (res.result === 1) {
|
|
console.log(res);
|
|
that.setData({
|
|
result: res.data.memberCard,
|
|
});
|
|
if (!res.data.member_info) {
|
|
// wx.navigateTo({
|
|
// url: '/packageE/energy/powerAddMeb/powerAddMeb?dealer_uid=' + res.data.dealer_uid,
|
|
// })
|
|
}
|
|
} else {
|
|
if (res.data.status) {
|
|
wx.reLaunch({
|
|
url: "/packageG/index/index",
|
|
});
|
|
}
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
},
|
|
});
|
|
},
|
|
});
|