const app = getApp(); Page({ data: { information: '', //个人信息 optioninfo:'', //择偶信息 houselunbo:'', //轮播图 // uploadImages: '', //轮播图放大 adopticon:'', //认证信息 headurl: [], //个人头像 uploadImages: [], //相册放大图集 albumimg: '', // 相册 albumimgurl: '',// 相册url }, // 相册点击放大 enlarge: function (e) { var that = this; // console.log(that.data.uploadImages) wx.previewImage({ urls: that.data.uploadImages, current: e.currentTarget.dataset.src }) }, onShow: function (options) { var that = this; // 个人相册 let albumimg_url = 'my/images/albumchange'; let albumimg_data = { }; app.postRequest(albumimg_url, albumimg_data, function (res) { // console.log(res.data.url); if (res.code == 201) { // 对象转数组 var itemList = res.data; //声明一个空的数组 var items = []; //遍历数据 for (let i in itemList) { //push到空数组里 items.push( itemList[i].img); } that.setData({ albumimg: res.data, uploadImages: items, }) } }) // 个人信息 let information_url = 'my/personaldata/personal'; let information_data = { }; app.postRequest(information_url, information_data, function (res) { if (res.code == 201) { // console.log(res.data); that.setData({ information: res.data }) } }) // 择偶信息 let optioninfo_url = 'my/personaloption/optioninfo'; let optioninfo_data = { }; app.postRequest(optioninfo_url, optioninfo_data, function (res) { // console.log(res.data); if (res.code == 201) { that.setData({ optioninfo: res.data, optioninfocode:res, }) } }) // 轮播图片 // let img_url = 'my/images/albumchange'; // let img_data = { // }; // app.postRequest(img_url, img_data, function (res) { // if (res.code == 201) { // // console.log(res.data); // that.setData({ // houselunbo: res.data // }) // // 对象转数组 // var itemList = res.data; // //声明一个空的数组 // var items = []; // //遍历数据 // for (let i in itemList) { // //push到空数组里 // items.push(itemList[i].img); // } // // console.log(items); // //传输数据到页面 // that.setData({ // uploadImages: items, // }) // } // }) // 认证信息 let adopticon_url = 'my/authentication/adopticon'; let adopticon_data = { }; app.postRequest(adopticon_url, adopticon_data, function (res) { console.log(res.data); // console.log(res); if (res.code == 201) { that.setData({ adopticon: res.data, adopticoncode: res, }) } }) // 个人头像 let headurl_url = 'my/images/headurl'; let headurl_data = { }; app.postRequest(headurl_url, headurl_data, function (res) { if (res.code == 201) { // console.log(res.data); that.setData({ headurl: res.data }) } }) }, // 上传图片 chooseImageTap: function (e) { var _this = this; wx.showActionSheet({ itemList: ['预览头像', '上传头像'], success(res) { // console.log(res.tapIndex) if (res.tapIndex == 0) { //预览所选图片 // console.log(that.data.uploadImages); // console.log(e.currentTarget.dataset.src); wx.previewImage({ urls: [e.currentTarget.dataset.src], current: e.currentTarget.dataset.src }) } if (res.tapIndex == 1) { wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { let tempFilesSize = res.tempFiles[0].size; if (tempFilesSize > 1024 * 1024 * 3) { wx.showModal({ title: '提示', content: '图片不得超过3MB', showCancel: false, }) return; } var Headportrait = res.tempFilePaths[0]; // console.log(res.tempFilePaths[0]); //上传图片 wx.uploadFile({ url: app.globalData.url + 'my/images/headimg', filePath: Headportrait, name: 'photo', formData: { key: wx.getStorageSync('access_key'), token: wx.getStorageSync('access_token') }, success: function (res) { var data = JSON.parse(res.data); console.log(data); if (data.code == 201) { var _qrcode = '上传成功' getApp().Tips(_qrcode); _this.onShow(); return; } var _qrcode2 = data.msg; getApp().Tips(_qrcode2); }, fail: function (d) { } }) } }) } }, fail(res) { console.log(res.errMsg) } }) }, })