invitationCode.vue 11 KB

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