invitationCode.vue 11 KB

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