invitationCode.vue 11 KB

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