index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. const util = require("../../../utils/util.js");
  2. const app = getApp();
  3. Page({
  4. data: {
  5. shareImage: '',
  6. info:{},
  7. userInfo:app.globalData.userInfo,
  8. invitePrice: util.config.invitePrice
  9. },
  10. onLoad() {
  11. let that = this;
  12. util.ajax({
  13. func:"user/poster/mine"
  14. },function(res){
  15. if(res.code == 0){
  16. res.data.avatar_bak = res.data.avatar;
  17. if (!util.isEmpty(res.data.avatar)) {
  18. wx.downloadFile({
  19. url: util.config.apiServer + "file.do?url=" + res.data.avatar, // 仅为示例,并非真实的资源
  20. success(ret) {
  21. if (ret.statusCode === 200) {
  22. res.data.avatar = ret.tempFilePath;
  23. }
  24. that.setData({ info: res.data });
  25. that.cateQroce();
  26. }
  27. });
  28. }else{
  29. res.data.avatar = "/images/default_logo.jpg";
  30. that.setData({ info: res.data });
  31. that.cateQroce();
  32. }
  33. }
  34. });
  35. },
  36. cateQroce() {
  37. let that = this;
  38. if (util.isEmpty(that.data.info.qrcode)) {
  39. util.ajax({
  40. func: "user/qrcode/personal"
  41. }, function (res) {
  42. if (res.code == 0) {
  43. that.info.qrcode = res.data;
  44. app.globalData.userInfo.qrcode = res.data;
  45. wx.setStorageSync("WXuserInfo", app.globalData.userInfo);
  46. that.setData({ info: that.info });
  47. } else
  48. util.showTips(res.reason);
  49. });
  50. }
  51. },
  52. cetaInvite(){
  53. let that = this, views = [];
  54. wx.showLoading({
  55. title: '海报生成中'
  56. });
  57. views.push({
  58. type: 'image',
  59. url: '/pages/account/images/bill_01.jpg',
  60. top: 0,
  61. left: 0,
  62. width: 750,
  63. height: 1332
  64. },
  65. {
  66. type: 'image',
  67. url: that.data.info.avatar,
  68. borderRadius: 65,
  69. top: 130,
  70. left: 80,
  71. width: 139,
  72. height: 139
  73. },
  74. {
  75. type: 'image',
  76. url: that.data.info.qrcode,
  77. top: 1017,
  78. left: 75,
  79. width: 210,
  80. height: 210
  81. },
  82. {
  83. type: 'text',
  84. content: that.data.info.nickname,
  85. fontSize: 32,
  86. color: '#231815',
  87. textAlign: 'left',
  88. top: that.data.info.roleType == 'organ' && that.data.userInfo.roleTypeDisable == 0 ? 140 : 160,
  89. left: 240
  90. },
  91. {
  92. type: 'text',
  93. content: "送你" + that.data.invitePrice +"元新人现金券,购买活动更划算!" ,
  94. fontSize: 24,
  95. color: '#3E3A39',
  96. textAlign: 'left',
  97. top: that.data.info.roleType == 'organ' && that.data.userInfo.roleTypeDisable == 0 ? 240 : 210,
  98. left: 240
  99. },
  100. {
  101. type: 'text',
  102. content: " " + that.data.info.commentContent,
  103. MaxLineNumber:4,
  104. lineHeight: 40,
  105. breakWord:true,
  106. fontSize: 28,
  107. width: 580,
  108. color: '#727171',
  109. textAlign: 'justify',
  110. top: 685,
  111. left: 70
  112. },
  113. {
  114. type: 'text',
  115. content: that.data.info.commentSource,
  116. fontSize: 28,
  117. color: '#727171',
  118. textAlign: 'right',
  119. top: 895,
  120. left: 610
  121. },
  122. {
  123. type: 'text',
  124. content: util.config.invitePrice,
  125. fontSize: 130,
  126. lineHeight:"90rpx",
  127. color: '#77410C',
  128. textAlign: 'center',
  129. top: 350,
  130. left: 390
  131. });
  132. if (that.data.info.roleType == 'organ' && that.data.userInfo.roleTypeDisable == 0){
  133. views.push({
  134. type: 'image',
  135. url: 'https://img.bbztx.com/image_test/upload/thumbs/20221031/logo/1667196301923043173.png',
  136. top: 185,
  137. left: 240,
  138. width: 215,
  139. height: 38
  140. });
  141. }
  142. this.setData({
  143. painting: {
  144. width: 750,
  145. height: 1332,
  146. clear: true,
  147. views: views
  148. }
  149. });
  150. },
  151. eventGetImage(event) {
  152. const { tempFilePath, errMsg } = event.detail
  153. if (errMsg === 'canvasdrawer:ok') {
  154. wx.saveImageToPhotosAlbum({
  155. filePath: tempFilePath,
  156. success(res) {
  157. wx.showToast({
  158. title: '保存图片成功',
  159. icon: 'success',
  160. duration: 2000
  161. })
  162. }
  163. });
  164. wx.hideLoading();
  165. }
  166. },
  167. onShareAppMessage() {
  168. let that = this;
  169. console.log('/pages/account/invite/share_invite?code=' + that.data.info.code + '&avatar=' + that.data.info.avatar_bak+'&roleType='+that.data.info.roleType+'&qrcode='+ that.data.info.qrcode + '&nickname=' + encodeURIComponent(that.data.info.nickname) + '&commentContent=' + encodeURIComponent(that.data.info.commentContent) +'&commentSource='+ encodeURIComponent(that.data.info.commentSource))
  170. return {
  171. title: that.data.info.nickname +'邀你注册,立享'+ util.config.invitePrice+'元现金红包',
  172. path: '/pages/account/invite/share_invite?code=' + that.data.info.code + '&avatar=' + that.data.info.avatar_bak+'&roleType='+that.data.info.roleType+'&qrcode='+ that.data.info.qrcode + '&nickname=' + encodeURIComponent(that.data.info.nickname) + '&commentContent=' + encodeURIComponent(that.data.info.commentContent) +'&commentSource='+ encodeURIComponent(that.data.info.commentSource),
  173. imageUrl: 'https://img.bbztx.com/image_test/upload/thumbs/20221031/logo/1667196654103093436.jpg'
  174. }
  175. }
  176. })