159 lines
3.4 KiB
JavaScript
159 lines
3.4 KiB
JavaScript
// pages/mine/mine.js
|
||
const App = getApp();
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
qrinfo:""
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad: function (options) {
|
||
this.qrinfoManage();
|
||
this.setData({
|
||
navH: App.globalData.navHeight,
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow: function () {
|
||
this.qrinfoManage();
|
||
console.log("show");
|
||
console.log(this.data.qrinfo);
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage: function () {
|
||
|
||
},
|
||
qrinfoManage: function() {
|
||
var qrinfoCache = wx.getStorageSync("qrinfo");
|
||
var array =[];
|
||
for (let i = 0; i < qrinfoCache.length;i++){
|
||
array.push(qrinfoCache[i]);
|
||
}
|
||
this.setData({
|
||
qrinfo: array,
|
||
})
|
||
console.log(this.data.qrinfo);
|
||
},
|
||
|
||
show: function(e){
|
||
var id = e.currentTarget.id;
|
||
let createInfo = { //将id和名字存起来下一个界面生成二维码用。
|
||
'id': this.data.qrinfo[id]['id'],
|
||
'username': this.data.qrinfo[id]['username'],
|
||
'aState': this.data.qrinfo[id]['alpay']!="",
|
||
'wState': this.data.qrinfo[id]['wxpay']!="",
|
||
'qState': this.data.qrinfo[id]['qqpay']!="",
|
||
}
|
||
wx.setStorageSync('createInfo', createInfo);
|
||
wx.redirectTo({
|
||
url: '../show/show'
|
||
})
|
||
},
|
||
|
||
|
||
confirm: function (e) {
|
||
let id = e.currentTarget.id;
|
||
var that = this;
|
||
wx.showModal({
|
||
title: '提示',
|
||
content: '删除后不可恢复,是否删除?',
|
||
cancelText: '再看看',
|
||
confirmText: '确认删除',
|
||
success(res) {
|
||
if (res.confirm) {
|
||
id=that.data.qrinfo[id]['id']
|
||
that.del(id);
|
||
} else if (res.cancel) {
|
||
console.log('用户点击取消')
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
|
||
del: function(id) {
|
||
var that=this;
|
||
var openId=wx.getStorageSync("openId");
|
||
wx.request({
|
||
url: 'https://powerrain.cn/qrcode/api/del.php',
|
||
data: {
|
||
id:id
|
||
},
|
||
success: function (res) {
|
||
console.log(res.data);
|
||
if(res.data==1){
|
||
wx.request({
|
||
url: 'https://powerrain.cn/qrcode/api/wxselect.php',
|
||
data: {
|
||
openId: openId
|
||
},
|
||
success: function (infoRes) { //如果该id未合并过二维码,此处为[](空数组)
|
||
console.log(infoRes);
|
||
if (infoRes.data.length != 0) {
|
||
wx.setStorageSync('qrinfo', infoRes.data);
|
||
that.qrinfoManage();
|
||
//将已经存在的二维码存放起来,然后下一个界面做成卡片。
|
||
} else {
|
||
wx.setStorageSync('qrinfo', "");
|
||
that.qrinfoManage();
|
||
}
|
||
}
|
||
})
|
||
}else{
|
||
wx.showModal({
|
||
showCancel: false,
|
||
title: '警告',
|
||
content: '删除失败',
|
||
confirmText: "知道了",
|
||
})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
}) |