personaldata.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. const app = getApp();
  2. Page({
  3. data: {
  4. information: '', //个人信息
  5. optioninfo:'', //择偶信息
  6. houselunbo:'', //轮播图
  7. // uploadImages: '', //轮播图放大
  8. adopticon:'', //认证信息
  9. headurl: [], //个人头像
  10. photo: '', //头像
  11. // 上传的案例图片集合
  12. uploadImages: [],
  13. // 设置上传案例图片的最大数目
  14. maxImages: 1,
  15. // 案例图片数目是否达到了最大数目
  16. isMaxImagesNum: false,
  17. uploadimg: true,
  18. },
  19. onShow: function (options) {
  20. var that = this;
  21. // 个人信息
  22. let information_url = 'my/personaldata/personal';
  23. let information_data = {
  24. };
  25. app.postRequest(information_url, information_data, function (res) {
  26. if (res.code == 201) {
  27. // console.log(res.data);
  28. that.setData({
  29. information: res.data
  30. })
  31. }
  32. })
  33. // 择偶信息
  34. let optioninfo_url = 'my/personaloption/optioninfo';
  35. let optioninfo_data = {
  36. };
  37. app.postRequest(optioninfo_url, optioninfo_data, function (res) {
  38. // console.log(res.data);
  39. if (res.code == 201) {
  40. that.setData({
  41. optioninfo: res.data,
  42. optioninfocode:res,
  43. })
  44. }
  45. })
  46. // 轮播图片
  47. // let img_url = 'my/images/albumchange';
  48. // let img_data = {
  49. // };
  50. // app.postRequest(img_url, img_data, function (res) {
  51. // if (res.code == 201) {
  52. // // console.log(res.data);
  53. // that.setData({
  54. // houselunbo: res.data
  55. // })
  56. // // 对象转数组
  57. // var itemList = res.data;
  58. // //声明一个空的数组
  59. // var items = [];
  60. // //遍历数据
  61. // for (let i in itemList) {
  62. // //push到空数组里
  63. // items.push(itemList[i].img);
  64. // }
  65. // // console.log(items);
  66. // //传输数据到页面
  67. // that.setData({
  68. // uploadImages: items,
  69. // })
  70. // }
  71. // })
  72. // 认证信息
  73. let adopticon_url = 'my/authentication/adopticon';
  74. let adopticon_data = {
  75. };
  76. app.postRequest(adopticon_url, adopticon_data, function (res) {
  77. // console.log(res.data);
  78. // console.log(res);
  79. if (res.code == 201) {
  80. that.setData({
  81. adopticon: res.data,
  82. adopticoncode: res,
  83. })
  84. }
  85. })
  86. // 个人头像
  87. let headurl_url = 'my/images/headurl';
  88. let headurl_data = {
  89. };
  90. app.postRequest(headurl_url, headurl_data, function (res) {
  91. if (res.code == 201) {
  92. // console.log(res.data);
  93. that.setData({
  94. headurl: res.data
  95. })
  96. }
  97. })
  98. },
  99. // enlarge:function(e){
  100. // var that = this;
  101. // wx.previewImage({
  102. // urls: that.data.uploadImages,
  103. // current: e.currentTarget.dataset.src
  104. // })
  105. // }
  106. // 上传图片
  107. chooseImageTap: function (e) {
  108. var _this = this;
  109. wx.chooseImage({
  110. count: 1,
  111. sizeType: ['original', 'compressed'],
  112. sourceType: ['album', 'camera'],
  113. success(res) {
  114. // console.log(res.tempFilePaths[0]);
  115. // tempFilePath可以作为img标签的src属性显示图片
  116. _this.setData({
  117. uploadImages: res.tempFilePaths,
  118. isMaxImagesNum: true,
  119. uploadimg: false,
  120. photo: res.tempFilePaths[0],
  121. });
  122. //上传图片
  123. wx.uploadFile({
  124. url: app.globalData.url + 'my/images/headimg',
  125. filePath: res.tempFilePaths[0],
  126. name: 'photo',
  127. formData: {
  128. key: wx.getStorageSync('access_key'),
  129. token: wx.getStorageSync('access_token')
  130. },
  131. success: function (res) {
  132. var data = JSON.parse(res.data);
  133. if (data.code == 201) {
  134. var _qrcode = '上传成功'
  135. getApp().Tips(_qrcode);
  136. _this.onShow();
  137. return;
  138. }
  139. var _qrcode2 = '上传失败'
  140. getApp().Tips(_qrcode2);
  141. }, fail: function (d) {
  142. }
  143. })
  144. }
  145. })
  146. },
  147. })