personaldata.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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() { //返回显示页面状态函数
  20. // this.onLoad()//再次加载,实现返回上一页页面刷新
  21. // //只执行获取地址的方法,来进行局部刷新
  22. // },
  23. onShow: function (options) {
  24. var that = this;
  25. getApp().showLoading(); //提示加载中
  26. // 个人信息
  27. let information_url = 'my/personaldata/personal';
  28. let information_data = {
  29. };
  30. app.postRequest(information_url, information_data, function (res) {
  31. if (res.code == 201) {
  32. // console.log(res.data);
  33. that.setData({
  34. information: res.data
  35. })
  36. }
  37. })
  38. // 择偶信息
  39. let optioninfo_url = 'my/personaloption/optioninfo';
  40. let optioninfo_data = {
  41. };
  42. app.postRequest(optioninfo_url, optioninfo_data, function (res) {
  43. // console.log(res.data);
  44. if (res.code == 201) {
  45. that.setData({
  46. optioninfo: res.data,
  47. optioninfocode:res,
  48. })
  49. }
  50. })
  51. // 轮播图片
  52. // let img_url = 'my/images/albumchange';
  53. // let img_data = {
  54. // };
  55. // app.postRequest(img_url, img_data, function (res) {
  56. // if (res.code == 201) {
  57. // // console.log(res.data);
  58. // that.setData({
  59. // houselunbo: res.data
  60. // })
  61. // // 对象转数组
  62. // var itemList = res.data;
  63. // //声明一个空的数组
  64. // var items = [];
  65. // //遍历数据
  66. // for (let i in itemList) {
  67. // //push到空数组里
  68. // items.push(itemList[i].img);
  69. // }
  70. // // console.log(items);
  71. // //传输数据到页面
  72. // that.setData({
  73. // uploadImages: items,
  74. // })
  75. // }
  76. // })
  77. // 认证信息
  78. let adopticon_url = 'my/authentication/adopticon';
  79. let adopticon_data = {
  80. };
  81. app.postRequest(adopticon_url, adopticon_data, function (res) {
  82. // console.log(res.data);
  83. // console.log(res);
  84. if (res.code == 201) {
  85. that.setData({
  86. adopticon: res.data,
  87. adopticoncode: res,
  88. })
  89. }
  90. })
  91. // 个人头像
  92. let headurl_url = 'my/images/headurl';
  93. let headurl_data = {
  94. };
  95. app.postRequest(headurl_url, headurl_data, function (res) {
  96. if (res.code == 201) {
  97. // console.log(res.data);
  98. that.setData({
  99. headurl: res.data
  100. })
  101. }
  102. })
  103. },
  104. // enlarge:function(e){
  105. // var that = this;
  106. // wx.previewImage({
  107. // urls: that.data.uploadImages,
  108. // current: e.currentTarget.dataset.src
  109. // })
  110. // }
  111. // 上传图片
  112. chooseImageTap: function (e) {
  113. var _this = this;
  114. wx.chooseImage({
  115. count: 1,
  116. sizeType: ['original', 'compressed'],
  117. sourceType: ['album', 'camera'],
  118. success(res) {
  119. // console.log(res.tempFilePaths[0]);
  120. // tempFilePath可以作为img标签的src属性显示图片
  121. _this.setData({
  122. uploadImages: res.tempFilePaths,
  123. isMaxImagesNum: true,
  124. uploadimg: false,
  125. photo: res.tempFilePaths[0],
  126. });
  127. //上传图片
  128. wx.uploadFile({
  129. url: app.globalData.url + 'my/images/headimg',
  130. filePath: res.tempFilePaths[0],
  131. name: 'photo',
  132. formData: {
  133. key: wx.getStorageSync('access_key'),
  134. token: wx.getStorageSync('access_token')
  135. },
  136. success: function (res) {
  137. var data = JSON.parse(res.data);
  138. if (data.code == 201) {
  139. var _qrcode = '上传成功'
  140. getApp().Tips(_qrcode);
  141. _this.onShow();
  142. return;
  143. }
  144. var _qrcode2 = '上传失败'
  145. getApp().Tips(_qrcode2);
  146. }, fail: function (d) {
  147. }
  148. })
  149. }
  150. })
  151. },
  152. })