invitationCode.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="page">
  3. <public-module></public-module>
  4. <view class="headers dis a-c j-start">
  5. <u-icon name="arrow-left" color="#333" size="38" @tap="back"></u-icon>
  6. <text style="margin: auto;">邀请码</text>
  7. </view>
  8. <view class="homeBackground"></view>
  9. <view class="p-2">
  10. <!-- 二维码 -->
  11. <view class="bgimg dis f-c ">
  12. <view class="header dis a-c mb-3">
  13. <image src="/static/image/my/wuxingb.png" mode=""></image>
  14. <view class="dis f-c ml-2">
  15. <text>{{userInfo.sysUser.userName}}</text>
  16. <text>{{userInfo.sysUser.deptName}}</text>
  17. </view>
  18. </view>
  19. <view class="dis f-c a-c ">
  20. <view class="panelcanvas " id="panelcanvas">
  21. <image :src="recommendImg" mode="widthFix" lazy-load></image>
  22. </view>
  23. <view class="operation mt-4 dis a-c ">
  24. <view class="dis f-c a-c" style="margin-right: 136rpx;" @click="saveImage">
  25. <image src="/static/share.png" mode=""></image>
  26. <text class="mt-1">保存图片</text>
  27. </view>
  28. <view class="dis f-c a-c" @click="shareLink(recommendUrl)">
  29. <image src="/static/save.png" mode=""></image>
  30. <text class="mt-1">链接分享</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 标签 -->
  36. <view class="tag mt-2 dis f-c ">
  37. <view class="dis a-c j-s">
  38. <text>我的身份:{{gradeText}}</text>
  39. <view class="entryPoint" v-show="supportUpgrade" @click="upgrade">去升级</view>
  40. </view>
  41. <text class="mt-1">再邀请6个工作室,即可升级成为管理人,赚取更多收益</text>
  42. </view>
  43. <view class="tag mt-2 dis f-c a-start">
  44. <text>我的佣金权益:0.2%</text>
  45. <text class="mt-1">再邀请3-5个工作室,佣金可达0.5%</text>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. pathToBase64,
  53. base64ToPath
  54. } from '@/common/pdf.js'
  55. import QR from "@/common/wxqrcode.js"
  56. import {
  57. mapState,
  58. mapMutations
  59. } from "vuex"
  60. export default {
  61. data() {
  62. return {
  63. recommendImg: "", //邀请码
  64. recommendUrl: "", //链接
  65. posterUrl: "", //二维码截图
  66. grade: "", //等级
  67. supportUpgrade: false, //是否支持升级
  68. deptSource: "",
  69. }
  70. },
  71. onShow() {
  72. },
  73. computed: {
  74. ...mapState(['userInfo', "userCheckInfo"]),
  75. gradeText() {
  76. const gradeMap = {
  77. 1: '创始人',
  78. 2: '管理人',
  79. 3: '合伙人',
  80. 4: '工作室'
  81. }
  82. return gradeMap[this.userInfo.sysUser.grade] || ''
  83. }
  84. },
  85. onLoad(options) {
  86. if (options) {
  87. this.grade = options.grade;
  88. if (options.deptSource) this.deptSource = options.deptSource;
  89. }
  90. this.recommendCode();
  91. this.entryPoint();
  92. },
  93. methods: {
  94. //保存图片
  95. saveImage() {
  96. base64ToPath(this.posterUrl)
  97. .then(path => {
  98. uni.saveImageToPhotosAlbum({ //保存图片到系统相册。
  99. filePath: path, //图片文件路径
  100. success: function() {
  101. uni.showToast({
  102. title: '已保存到相册',
  103. icon: 'none',
  104. });
  105. },
  106. fail: function(e) {
  107. uni.showToast({
  108. title: '图片保存失败',
  109. icon: 'none',
  110. });
  111. }
  112. });
  113. })
  114. },
  115. //复制邀请链接
  116. shareLink(value) {
  117. uni.setClipboardData({
  118. data: value, //要被复制的内容
  119. success: () => { //复制成功的回调函数
  120. uni.showToast({ //提示
  121. icon: 'none',
  122. title: '邀请链接已复制成功'
  123. })
  124. }
  125. });
  126. },
  127. //获取升级标识
  128. async entryPoint() {
  129. let res = await this.$http.post('/partner/verifyUpgradeConditions', {
  130. grade: this.grade,
  131. });
  132. if (res.code == '200') {
  133. this.supportUpgrade = true;
  134. } else {
  135. this.supportUpgrade = false;
  136. }
  137. },
  138. //去升级
  139. async upgrade() {
  140. let res = await this.$http.post('/partner/submitLiftingRecord', {
  141. grade: this.grade,
  142. });
  143. if (res.code == '200') {
  144. uni.navigateTo({
  145. url: '/pages/institutional/applicationResult'
  146. })
  147. }
  148. },
  149. //邀请二维码生成
  150. recommendCode() {
  151. if (this.grade == 4) {
  152. this.recommendImg = QR.createQrCodeImg(this.$base.h5BaseUrl + "/#/pages/index/applypartner?grade=" +
  153. this
  154. .grade + '&userId=' + this.userInfo.sysUser.userId + '&deptSource=' + this.deptSource, {
  155. size: parseInt(300) //二维码大小
  156. })
  157. this.recommendUrl = this.$base.h5BaseUrl + "/#/pages/index/applypartner?grade=" +
  158. this
  159. .grade + '&userId=' + this.userInfo.sysUser.userId + '&deptSource=' + this.deptSource;
  160. } else {
  161. this.recommendImg = QR.createQrCodeImg(this.$base.h5BaseUrl + "/#/pages/index/applypartner?grade=" +
  162. this
  163. .grade + '&userId=' + this.userInfo.sysUser.userId, {
  164. size: parseInt(300) //二维码大小
  165. })
  166. this.recommendUrl = this.$base.h5BaseUrl + "/#/pages/index/applypartner?grade=" +
  167. this
  168. .grade + '&userId=' + this.userInfo.sysUser.userId
  169. }
  170. },
  171. back() {
  172. uni.navigateBack({
  173. delta: 1, // 返回的页面数,如果是1表示返回上一页
  174. success: function() {}
  175. });
  176. },
  177. //页面截图转路径
  178. receiveRenderData(val) {
  179. this.posterUrl = val.replace(/[\r\n]/g, ''); // 去除base64位中的空格
  180. // 将base64转化为临时地址
  181. // base64ToPath(imageStr).then(path => {
  182. // this.payImg = path;
  183. // }).catch(error => {
  184. // console.log(error);
  185. // });
  186. },
  187. showLoading() {
  188. uni.showLoading({
  189. title: '正在生成图片'
  190. });
  191. },
  192. hideLoading() {
  193. uni.hideLoading();
  194. this.loading = false;
  195. },
  196. }
  197. }
  198. </script>
  199. <script module="canvasImage" lang="renderjs">
  200. import html2canvas from 'html2canvas'
  201. export default {
  202. data() {
  203. return {
  204. }
  205. },
  206. mounted() {
  207. setTimeout(() => {
  208. this.canvasImage.generateImage()
  209. }, 1000);
  210. },
  211. methods: {
  212. generateImage() {
  213. setTimeout(() => {
  214. this.$ownerInstance.callMethod('showLoading')
  215. const dom = document.getElementById('panelcanvas') // 需要生成图片内容的 dom 节点
  216. html2canvas(dom, {
  217. width: dom.clientWidth, //dom 原始宽度
  218. height: dom.clientHeight,
  219. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  220. scrollX: 0,
  221. useCORS: true, //支持跨域
  222. // allowTaint: false,
  223. scale: 2, // 设置生成图片的像素比例,默认是1,如果生成的图片模糊的话可以开启该配置项
  224. }).then((canvas) => {
  225. // 生成成功
  226. this.$ownerInstance.callMethod('hideLoading')
  227. this.$ownerInstance.callMethod('receiveRenderData', canvas.toDataURL('image/png'))
  228. }).catch(err => {
  229. // 生成失败 弹出提示弹窗
  230. this.$ownerInstance.callMethod('_errAlert', `【生成图片失败,请重试】${err}`)
  231. })
  232. }, 300)
  233. }
  234. },
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. .headers {
  239. position: fixed;
  240. top: 0;
  241. left: 0;
  242. height: auto;
  243. width: 100%;
  244. z-index: 999999;
  245. padding: 30rpx;
  246. padding-top: 50px;
  247. text {
  248. font-size: 36rpx;
  249. font-weight: bold;
  250. color: #000;
  251. }
  252. .headers-activeTab {
  253. width: 80%;
  254. }
  255. .right {
  256. position: absolute;
  257. right: 30rpx;
  258. image {
  259. width: 28rpx;
  260. height: 28rpx;
  261. margin-right: 4rpx;
  262. }
  263. text {
  264. font-weight: 400;
  265. color: #000;
  266. font-size: 24rpx;
  267. }
  268. }
  269. }
  270. //头部背景
  271. .homeBackground {
  272. width: 100%;
  273. height: 176rpx;
  274. background: linear-gradient(180deg, #D1EFFE 0%, #FFFFFF 100%);
  275. }
  276. .bgimg {
  277. width: 100%;
  278. background-image: url("/static/bgimg.png");
  279. background-size: 100% 100%;
  280. padding: 40rpx;
  281. box-sizing: border-box;
  282. background-color: #FFFFFF;
  283. .header {
  284. image {
  285. width: 90rpx;
  286. height: 90rpx;
  287. }
  288. .ml-2 {
  289. text:first-child {
  290. font-size: 32rpx;
  291. color: #333;
  292. font-weight: bold;
  293. }
  294. text:last-child {
  295. font-size: 28rpx;
  296. color: #999;
  297. }
  298. }
  299. }
  300. .panelcanvas {
  301. position: relative;
  302. image {
  303. width: 340rpx;
  304. height: 340rpx;
  305. }
  306. }
  307. .operation {
  308. image {
  309. width: 88rpx;
  310. height: 88rpx;
  311. }
  312. text {
  313. font-size: 24rpx;
  314. color: #333;
  315. }
  316. }
  317. }
  318. .tag {
  319. background: #FFFFFF;
  320. border-radius: 10rpx 10rpx 10rpx 10rpx;
  321. padding: 30rpx;
  322. box-sizing: border-box;
  323. .entryPoint {
  324. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  325. border-radius: 4rpx 4rpx 4rpx 4rpx;
  326. padding: 1rpx 17rpx;
  327. box-sizing: border-box;
  328. font-size: 24rpx;
  329. color: #FFFFFF;
  330. }
  331. text:first-child {
  332. font-size: 30rpx;
  333. color: #333;
  334. font-weight: bold;
  335. }
  336. text:last-child {
  337. font-size: 24rpx;
  338. color: #666;
  339. }
  340. }
  341. </style>