personaldata.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. let tempFilesSize = res.tempFiles[0].size;
  115. if (tempFilesSize > 1024 * 1024 * 3) {
  116. wx.showModal({
  117. title: '提示',
  118. content: '图片不得超过3MB',
  119. showCancel: false,
  120. })
  121. return;
  122. }
  123. var Headportrait = res.tempFilePaths[0];
  124. console.log(res.tempFilePaths[0]);
  125. wx.showModal({
  126. title: '形象照',
  127. content: '您确认上传此图片为形象照吗?',
  128. success(res) {
  129. if (res.confirm) {
  130. // console.log('用户点击确定')
  131. // tempFilePath可以作为img标签的src属性显示图片
  132. _this.setData({
  133. uploadImages: Headportrait,
  134. isMaxImagesNum: true,
  135. uploadimg: false,
  136. photo: Headportrait,
  137. });
  138. //上传图片
  139. wx.uploadFile({
  140. url: app.globalData.url + 'my/images/headimg',
  141. filePath: Headportrait,
  142. name: 'photo',
  143. formData: {
  144. key: wx.getStorageSync('access_key'),
  145. token: wx.getStorageSync('access_token')
  146. },
  147. success: function (res) {
  148. var data = JSON.parse(res.data);
  149. console.log(data);
  150. if (data.code == 201) {
  151. var _qrcode = '上传成功'
  152. getApp().Tips(_qrcode);
  153. _this.onShow();
  154. return;
  155. }
  156. var _qrcode2 = data.msg;
  157. getApp().Tips(_qrcode2);
  158. }, fail: function (d) {
  159. }
  160. })
  161. } else if (res.cancel) {
  162. console.log('用户点击取消')
  163. }
  164. }
  165. })
  166. }
  167. })
  168. },
  169. })