user-rank.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>职级-个人中心-创业帮</title>
  6. <meta name="keywords" content="职级-个人中心-创业帮">
  7. <meta name="description" content="职级-个人中心-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephßone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="职级-个人中心-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. <style>#qrcode img{width:100%; }</style>
  17. </head>
  18. <body class="pb0 pt0" id="user_my_rank" style="padding-top:0;">
  19. <div id="rank" v-cloak>
  20. <van-nav-bar class="user_my_rank_title" title="我的职级" right-text="职级说明" v-if="toptitleisshow" @click-left="gomine" @click-right="goexplan" left-arrow>
  21. <template #left>
  22. <van-icon class="user_rank_back" name="arrow-left"> </van-icon>
  23. </template>
  24. </van-nav-bar>
  25. <div class="user_my_rank_topcard ovh">
  26. <div class="cardlabel ovh"><img src="./static/images/user-rank-back@2x.png" alt=""></div>
  27. <div class="container ovh">
  28. <div class="trophy"><span>K{{grade}}职级</span><img src="./static/images/main-rank-alltrophy@3x.png" alt=""></div>
  29. <div class="text">{{rankinfo}}</div>
  30. <div class="speed progress rel">
  31. <div class="grade">K{{grade}}</div>
  32. <van-progress color="linear-gradient(to right, #F5CD13, #FF9500)" :percentage="speedlength" :pivot-text="tradeamt"></van-progress>
  33. <div class="grade">K{{grade >= 9? grade:grade + 1}}</div>
  34. </div>
  35. <div class="textbottom cfff">本月当前交易{{tradeamt}},离升级还差{{exceedval}}的交易</div>
  36. </div>
  37. </div>
  38. <div class="user_my_rank_rights">
  39. <div class="rightstop"><img src="./static/images/product-icon2@3x.png" alt=""><span>我的权益</span></div>
  40. <van-grid class="rightgrid" :column-num="3">
  41. <van-grid-item icon="./static/images/user-rank-birthday@2x.png" text="生日礼遇" @click="group"></van-grid-item>
  42. <van-grid-item icon="./static/images/user-rank-onlybadge@2x.png" text="专属徽章" @click="visible"></van-grid-item>
  43. </van-grid>
  44. </div>
  45. <div class="user_my_rank_rights">
  46. <div class="rightstop"><img src="./static/images/product-icon2@3x.png" alt=""><span>升级攻略</span><span class="rightsright">完成以下任务,可快速提升交易</span></div>
  47. </div>
  48. <div class="user_my_rank_cell">
  49. <div class="box" v-for="item,index in cellList" :key="index"> <img :src="item.imgsrc" alt="">
  50. <div class="boxcenter">
  51. <div class="top">{{item.title}}</div>
  52. <div class="bottom"><span>{{item.main}}</span></div>
  53. </div>
  54. <div class="invite" @click="groupbtn(item.Url)">{{item.option}}</div>
  55. </div>
  56. </div>
  57. <div class="birthdaydialog" v-if="birthdayisshow">
  58. <div class="birthdaycard ovh">
  59. <div class="top"> <img src="./static/images/mine-rank-birthday.png" alt=""></div>
  60. <div class="bottom ovh">
  61. <div class="title">生日祝福</div>
  62. <div class="main">每年生日为你送上温暖祝福</div>
  63. <button @click="surebtn">知道了</button>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="morebirthdaydialog" v-if="morebirthdayisshow">
  68. <div class="birthdaycard ovh">
  69. <div class="bottom ovh"> <img src="./static/images/birthday-logo.png" alt="">
  70. <div class="title">生日快乐</div>
  71. <div class="main">创业帮为您送上温暖祝福</div>
  72. <button @click="learnblessing">查看祝福</button>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="user_rank_badge_allback" v-cloak v-if="badgeisshow">
  77. <div class="user_rank_badge_card ovh" ref="savecard">
  78. <div class="savecard">
  79. <div class="user_rank_badge_top"><span class="rightlogo"> <img src="./static/images/logo--@3x.png" alt=""></span><span class="closebtn" @click="closebadge" v-if="issaveimg"><img src="./static/images/close-wite@3x.png" alt=""></span></div>
  80. <div class="user_rank_badge_badgecontainer">
  81. <div class="trophy"><span>K{{grade}}职级</span><img src="./static/images/main-rank-alltrophy@3x.png" alt=""></div>
  82. <div class="text">您当前职级为K{{grade}}</div>
  83. </div>
  84. <div class="user_rank_badge_qrcode" id="qrcode"><img :src="rankcode" alt="" style="width:100%;"></div>
  85. <div class="user_rank_badge_namecode">{{username}}的推荐码:{{number}}</div>
  86. </div>
  87. <div class="user_rank_badge_bottombtn" v-if="issaveimg">
  88. <button class="savebtn" @click="saveimg">保存</button>
  89. <button class="share" @click="sharebtn"> 分享我的职级</button>
  90. </div>
  91. </div>
  92. </div>
  93. <van-overlay class="group" :show="congratulationsisshow" @click="congratulationsisshow = false">
  94. <div class="wrapper h100p">
  95. <div class="block"><img src="./static/images/user-rank-trophy@2x.png" alt="">
  96. <div class="foryou">恭喜你</div>
  97. <button class="f18 cfff" @click="gogroupup">立即查看</button>
  98. </div>
  99. </div>
  100. </van-overlay>
  101. <van-popup class="bgcf7f7f7" v-model="show" position="bottom" :style="{ height: '25%' }">
  102. <div class="sharepanel rel">
  103. <div class="f12 c999 tc">分享到</div>
  104. <van-grid class="grad" :column-num="2">
  105. <van-grid-item text="微信" @click="weixin">
  106. <template #icon>
  107. <svg class="icon" aria-hidden="true">
  108. <use xlink:href="#icon-weixin"> </use>
  109. </svg>
  110. </template>
  111. </van-grid-item>
  112. <van-grid-item text="微信朋友圈" @click="weixinfriend">
  113. <template #icon>
  114. <svg class="icon" aria-hidden="true">
  115. <use xlink:href="#icon-pengyouquan"></use>
  116. </svg>
  117. </template>
  118. </van-grid-item>
  119. </van-grid>
  120. <div class="tc mt16 cencal abs bgcfff f14 c333" @click="show = false">取消</div>
  121. </div>
  122. </van-popup>
  123. </div>
  124. <script src="./static/js/klm-vv.min.js"></script>
  125. <script src="./static/js/appfunc.min.js"></script>
  126. <script src="./static/js/klm-axios-config.js"></script>
  127. <script src="./static/js/publicfn.js"></script>
  128. <script src="./static/js/html2canvas.js"></script>
  129. <script src="./static/js/iconfont.js"></script>
  130. <script>
  131. // 在 #app 标签下渲染一个按钮组件
  132. let app = new Vue({
  133. el: '#rank',
  134. data() {
  135. return {
  136. toptitleisshow:false,
  137. //- 是否显示生日弹出层
  138. birthdayisshow:false,
  139. //- 是否显示生日详细弹出层
  140. morebirthdayisshow:false,
  141. //- 是否显示职级徽章
  142. badgeisshow:false,
  143. //- 等级进度
  144. speedlength:0,
  145. //- 徽章升级弹出层
  146. congratulationsisshow:false,
  147. //- 活动方式列表
  148. number:'H000122',
  149. cellList:[
  150. {imgsrc:'./static/images/user-rank-invited@2x.png',title:'邀请好友',main:'发展团队,交易不停,分润不止',option:'去邀请',Url:'invite-frend'},
  151. //- {imgsrc:'./static/images/user-rank-order@2x.png',title:'商城下单',main:'低成本创业,开通商户,奖励即刻到账',option:'去下单',Url:'mall'},
  152. //- {imgsrc:'./static/images/user-rank-joinpart@2x.png',title:'参加活动',main:'多种奖励享不停',option:'去参加',Url:'market-active'},
  153. //- {imgsrc:'./static/images/user-rank-camp@2x.png',title:'参加特训营',main:'支付大神的成长之路',option:'去参加',Url:'trainingCamp'}
  154. ],
  155. rankcode:'',
  156. grade:1,
  157. tradeamt:'0',
  158. exceedval:'',
  159. rankinfo:'',
  160. status:0,
  161. username:'',
  162. test:'',
  163. issaveimg:true,
  164. show:false,
  165. canvas:''
  166. }
  167. },
  168. mounted(){
  169. this.toptitleisshow = toptitleisshow;
  170. this.getuserrankinfo();
  171. this.getmainrankinfo();
  172. },
  173. updated(){
  174. //- 解决标题不居中的问题
  175. if(this.status <= 1) {
  176. const str = document.querySelector(".van-progress__portion").style.width;
  177. document.querySelector(".van-progress__pivot").style.left = Number(str.substring(0,str.length - 2)) - 30 + 'px';
  178. //- console.log(Number(str.substring(0,str.length - 2)) - 30 + 'px');
  179. this.$forceUpdate();
  180. this.status++;
  181. }
  182. },
  183. methods: {
  184. //- 显示徽章
  185. visible(){
  186. this.badgeisshow = true;
  187. },
  188. //- 获取用户职级信息
  189. async getuserrankinfo(){
  190. PublicLib.ShowLoading({Message:''});
  191. PublicLib.HideLoading();
  192. const Id = PublicLib.getCookieInfo('userId');
  193. const res = await getRequest('api/v1/users/mylevelbadge',JSON.stringify({Id}));
  194. if(res.status !== '1') return tips('获取用户信息失败,请重试!');
  195. this.username = res.data.RealName;
  196. this.rankcode = res.data.ReferenceQrCode;
  197. this.number = res.data.MakerCode;
  198. PublicLib.CachePicture({picUrl:res.data.ReferenceQrCode});
  199. },
  200. async getmainrankinfo(){
  201. const Id = PublicLib.getCookieInfo('userId');
  202. const res = await getRequest('api/v1/userrank/mylevelinfo',JSON.stringify({UserId:Id}));
  203. if(res.status !== '1') return tips('获取用户信息失败,请重试!');
  204. this.grade = res.data.Rank;
  205. this.tradeamt = String(res.data.TradeAmt);
  206. this.speedlength = res.data.Percent;
  207. this.exceedval = res.data.ExceedVal;
  208. this.rankinfo = res.data.TextNote;
  209. },
  210. //- 图片生成
  211. // 生成快照
  212. convertToImage(container){
  213. // 设置放大倍数
  214. const scale = window.devicePixelRatio / 2;
  215. // 传入节点原始宽高
  216. const width = container.offsetWidth;
  217. const height = container.offsetHeight;
  218. const canvas = document.createElement('canvas');
  219. // 设定 canvas 元素属性宽高为 DOM 节点宽高 * 像素比
  220. canvas.width = width * scale;
  221. canvas.height = height * scale;
  222. // 设定 canvas css宽高为 DOM 节点宽高
  223. canvas.style.width = `${width}px`;
  224. canvas.style.height = `${height}px`;
  225. // 获取画笔
  226. const context = canvas.getContext('2d');
  227. // 将所有绘制内容放大像素比倍
  228. context.scale(scale, scale);
  229. var rect = container.getBoundingClientRect(); //获取元素相对于视察的偏移量
  230. context.translate(-rect.left, -rect.top); //设置context位置,值为相对于视窗的偏移量负值,让图片复位
  231. // html2canvas配置项
  232. //- console.log(11)
  233. const ops = {
  234. scale,
  235. canvas,
  236. width,
  237. height,
  238. logging: false,
  239. useCORS: true,
  240. allowTaint: false,
  241. dpi:300,
  242. };
  243. return html2canvas(container, ops).then(canvas => {
  244. // 返回图片的二进制数据
  245. return canvas.toDataURL("image/png");
  246. });
  247. },
  248. async saveimg(){
  249. // 调用函数,取到截图的二进制数据,对图片进行处理(保存本地、展示等)
  250. this.issaveimg = false;
  251. this.$nextTick(async()=>{
  252. const imgBlobData = await this.convertToImage(this.$refs.savecard);
  253. this.issaveimg = true;
  254. //- this.test = imgBlobData;
  255. //- console.log(imgBlobData);
  256. PublicLib.SaveToSd({PicPath:imgBlobDatas});
  257. });
  258. },
  259. sharebtn(){
  260. this.show = true;
  261. // 调用函数,取到截图的二进制数据,对图片进行处理(保存本地、展示等)
  262. this.issaveimg = false;
  263. this.$nextTick(async()=>{
  264. this.issaveimg = true;
  265. this.canvas = await this.convertToImage(this.$refs.savecard);
  266. //- console.log(canvas);
  267. });
  268. },
  269. weixin(){
  270. PublicLib.ShareAppMessageImage({PicturePath:this.canvas});
  271. },
  272. weixinfriend(){
  273. PublicLib.ShareTimelineImage({PicturePath:this.canvas});
  274. },
  275. //- 关闭徽章
  276. closebadge(){
  277. this.badgeisshow = false;
  278. },
  279. //- 跳转说明
  280. goexplan(){
  281. PublicLib.Goto({Url:'user-rank-explan'});
  282. },
  283. //- 升级展示
  284. gogroupup(){
  285. PublicLib.Goto({Url:'user-rank-groupup'});
  286. },
  287. //- 生日弹窗展开
  288. group(){
  289. this.birthdayisshow = true;
  290. },
  291. //- 生日弹窗关闭
  292. surebtn(){
  293. this.birthdayisshow = false;
  294. },
  295. //- 返回我的界面
  296. gomine(){
  297. PublicLib.GoBack({Level:1});
  298. },
  299. // 生日详情
  300. birthdaybtn(){
  301. this.morebirthdayisshow = true;
  302. },
  303. //- 查看祝福
  304. learnblessing(){
  305. PublicLib.Goto({Url:'user-rank-blessing'});
  306. },
  307. groupbtn(Url){
  308. PublicLib.Goto({Url});
  309. }
  310. }
  311. });
  312. </script>
  313. </body>
  314. </html>