InviteFriends.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view class="all">
  3. <u-mask :show="show" @click="show = false">
  4. <u-image width="100%" height="500px" :mode="'widthFix'" src="/static/img/guide_point.png"></u-image>
  5. </u-mask>
  6. <ujp-navbar title="邀请好友"></ujp-navbar>
  7. <view class="InviteFriends" :class="{
  8. opacityClass:show
  9. }">
  10. <view class="InviteFriends-head">
  11. <u-image width="274rpx" height="60rpx" src="/static/img/logo3.png"></u-image>
  12. <u-image class="textImg" width="662rpx" height="59rpx" src="/static/img/text.png"></u-image>
  13. <u-image width="100%" height="320rpx" src="/static/img/handshake.png"></u-image>
  14. </view>
  15. <view class="InviteFriends-main">
  16. <view class="InviteFriends-coupons">
  17. <h4>每邀请1位好友注册,将获得1张服务费抵扣券</h4>
  18. <view class="coupons-price">
  19. <h2>5</h2><span>元</span>
  20. </view>
  21. <view class="coupons-line"></view>
  22. <view class="coupons-btn" @click="inviteFriendsBtn">
  23. <u-icon name="wechat-fill" custom-prefix="custom-icon" color="#fff" size="48"></u-icon>
  24. <span>分享至微信</span>
  25. </view>
  26. </view>
  27. <view class="InviteFriends-title">福利获取流程</view>
  28. <view class="InviteFriends-info">
  29. <view class="InviteFriends-info-row">
  30. <u-icon name="question-answer-fill" custom-prefix="custom-icon" color="#00B962" size="48"></u-icon>
  31. <p>1.发送链接给好友</p>
  32. </view>
  33. <view class="InviteFriends-info-row">
  34. <u-icon name="account-pin-circle-fill" custom-prefix="custom-icon" color="#00B962" size="48"></u-icon>
  35. <p>2.好友注册并登录51充电联盟</p>
  36. </view>
  37. <view class="InviteFriends-info-row">
  38. <u-icon name="gift-2-fill" custom-prefix="custom-icon" color="#00B962" size="48"></u-icon>
  39. <p>3.和好友一起领5元红包</p>
  40. </view>
  41. <view class="InviteFriends-tips">
  42. <span>*</span><p>邀请成功,你和好友各得5元红包,一年有效;邀请更多人,你可领最高500元红包</p>
  43. </view>
  44. </view>
  45. <view class="InviteFriends-title">我的奖励</view>
  46. <view class="InviteFriends-reward">
  47. <view class="reward-head">
  48. <p>成功邀请{{list?list.length:0}}人,已获得</p>
  49. <view class="reward-head-price">
  50. <h2>{{list?(list.length*5).toFixed(2):'0.00'}}</h2><span>元</span>
  51. </view>
  52. </view>
  53. <view class="reward-main">
  54. <view class="reward-list">
  55. <view class="reward-list-title">
  56. 成功邀请记录
  57. </view>
  58. <view class="rewardList">
  59. <view class="rewardList-item" v-for="(item,i) in list" :key="i" >
  60. <view class="u-flex">
  61. <u-avatar :src="item.headImg" size="72"></u-avatar>
  62. <span v-text="substrMbName(item.nickName)"></span>
  63. </view>
  64. <p v-text="item.createTime"></p>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="InviteFriends-title">我的二维码</view>
  71. <view class="InviteFriends-reward">
  72. <view class="reward-main" style="text-align:center;" >
  73. <img id="qrcode2" :src="qrCodeImg">
  74. </view>
  75. <img id="qrcode" style="display: none;">
  76. </view>
  77. <view class="InviteFriends-foot">
  78. *本活动最终解释权,归51充电联盟所有。
  79. </view>
  80. </view>
  81. </view>
  82. <u-modal v-model="show1" @confirm="gotoGz"
  83. cancel-text="暂不关注"
  84. confirm-text="前往关注"
  85. confirm-color="#53b56b"
  86. :show-cancel-button="true"
  87. ref="uModal2" :asyncClose="true"
  88. >
  89. <view style="padding: 15px;"
  90. >请关注<span style=" color: #53b56b;">{{projectName}}</span>公众号,以便第一时间收到充电结束消息提醒</view>
  91. </u-modal>
  92. </view>
  93. </template>
  94. <script>
  95. import jweixin from 'weixin-js-sdk'
  96. //var jweixin = require('jweixin-module')
  97. import {
  98. convertCanvasToImage,substrMb
  99. } from '@/utils'
  100. import * as API_WeiXin from '@/apis/weixin'
  101. import * as API from '@/apis/friends.js'
  102. import * as WxJsApi from '@/utils/wxJsApi.js'
  103. import * as API_weixin from '@/apis/weixin.js'
  104. import QRCode from 'qrcodejs2'
  105. export default {
  106. data() {
  107. return {
  108. elderMode:false,
  109. id:"",
  110. qrCodeImg:"",
  111. code:"",
  112. show:false,
  113. amount:0,
  114. uid:"",
  115. list:[],
  116. show1:false,
  117. show2:false,
  118. projectName:"",
  119. }
  120. },
  121. onLoad(op) {
  122. this.projectName=process.car.ProjectName;
  123. this.id=op.id
  124. this.code=op.icode
  125. this.uid=op.uid
  126. //
  127. this.get_wx_config();
  128. },
  129. onReady(){
  130. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  131. if(this.elderMode)
  132. this.theme('elder')
  133. else
  134. this.theme('standard')
  135. var info=this.carhelp.getPersonInfo();
  136. let joinUrl = window.location.href.split("#")[0]+"#/?friends=friends&id="+this.id+"&icode="+this.code+"&uid="+info.id;
  137. //this.joinUrl=joinUrl;
  138. let qrcode = new QRCode('qrcode', {
  139. width: 200,
  140. height: 200,
  141. text: joinUrl,
  142. correctLevel: QRCode.CorrectLevel.M,
  143. })
  144. var canvas = document.getElementsByTagName('canvas')[0];
  145. this.qrCodeImg = convertCanvasToImage(canvas);
  146. },
  147. onShow() {
  148. //pages/user/InviteFriends?id=2&icode=FX&uid=731b9765-3565-4b3c-918b-5d3ec3b505fb
  149. if(this.show2){
  150. }
  151. this.onShowmethods()
  152. this.checkSubscribe()
  153. },
  154. methods: {
  155. gotoGz(){
  156. this.carhelp.setGzDate()
  157. var url="https://mp.weixin.qq.com/s/mCHz1nNvg0xAICiBeIyKRQ";
  158. window.location.href=url
  159. },
  160. checkSubscribe(){
  161. API_weixin.checkSubscribe({
  162. openId: this.carhelp.getOpenId()
  163. }).then((res) => {
  164. if(res.data=="0"){
  165. this.show1=true
  166. }else{
  167. //this.init();
  168. this.show2=true;
  169. //this.carhelp.setGzDate()
  170. }
  171. //setGzDate
  172. }).catch(error => {
  173. uni.showToast({
  174. title: error
  175. })
  176. })
  177. },
  178. onShowmethods(){
  179. var info=this.carhelp.getPersonInfo();
  180. if(info){
  181. this.inviteCouponList();
  182. }else{
  183. window.location= window.location.href.split("#")[0]+'#';
  184. var url="/?friends=friends&id="+this.id+"&icode="+this.code+"&uid="+this.uid;
  185. uni.redirectTo({
  186. url:url
  187. })
  188. }
  189. },
  190. theme(type) {
  191. if(type == 'elder')
  192. {
  193. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  194. let data = {
  195. "font-size":'32rpx',
  196. };
  197. this.placeholderStyle = data;
  198. }
  199. else
  200. {
  201. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  202. let data = {
  203. "font-size":'28rpx'
  204. };
  205. this.placeholderStyle = data;
  206. }
  207. },
  208. substrMbName(name){
  209. return substrMb(name,0,4)+'***'
  210. },
  211. inviteCouponList(){
  212. uni.showLoading({
  213. title: "加载中",
  214. mask: true,
  215. })
  216. API.inviteCouponList().then((res) => {
  217. this.list = res.data.regUserList
  218. this.amount=res.data.amount
  219. uni.hideLoading()
  220. }).catch(error => {
  221. uni.showToast({
  222. title: error
  223. })
  224. })
  225. },
  226. inviteFriendsBtn(){
  227. this.show=true;
  228. },
  229. //获取微信jssdk配置信息
  230. get_wx_config() {
  231. //("get_wx_configget_wx_configget_wx_configget_wx_config")
  232. var _this=this
  233. API_WeiXin.getConfig().then(response => {
  234. var wxconfig = response.data.wxConfig;
  235. jweixin.config({
  236. debug: false, // 开启调试模式,
  237. appId: wxconfig.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  238. timestamp: wxconfig.timestamp, // 必填,生成签名的时间戳
  239. nonceStr: wxconfig.nonceStr, // 必填,生成签名的随机串
  240. signature: wxconfig.signature, // 必填,签名,见附录1
  241. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'], // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  242. });
  243. _this.wxShare()
  244. jweixin.error(function(res) {
  245. //('微信api配置出错');
  246. });
  247. }).catch(error => {
  248. //(error);
  249. })
  250. },
  251. //微信分享自定义
  252. wxShare() {
  253. var img = this.carhelp.getConfig().indexLogo
  254. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  255. // if (indexLogo) {
  256. // this.indexLogo = indexLogo;
  257. // }
  258. var info=this.carhelp.getPersonInfo()
  259. //var img=require("@/static/img/aboutus.png")
  260. ////(this.nowItem);
  261. var ProjectName=process.car.ProjectName;//info.nickName+
  262. var nickName=info.nickName?info.nickName:'好友';
  263. var title=nickName+"邀请你一起领取新能源车充电红包"
  264. //"["+ProjectName+"]"+'和好友一起领5元红包'
  265. var desc=ProjectName
  266. let joinUrl = window.location.href.split("#")[0]+"#/?friends=friends&id="+this.id+"&icode="+this.code+"&uid="+info.id;
  267. //this.joinUrl=joinUrl;
  268. jweixin.ready(function() {
  269. //("readyreadyreadyreadyready")
  270. jweixin.updateAppMessageShareData({
  271. title: title,
  272. desc:desc ,
  273. link: joinUrl,
  274. imgUrl: img,
  275. success: function() {
  276. //("updateAppMessageShareData")
  277. // 设置成功
  278. _this.$emit("wxShare",null);
  279. }
  280. })
  281. jweixin.updateTimelineShareData({
  282. title: title,
  283. desc:desc ,
  284. link: joinUrl,
  285. imgUrl: img,
  286. success: function() {
  287. //("updateTimelineShareData")
  288. // 设置成功
  289. _this.$emit("wxShare",null);
  290. }
  291. })
  292. });
  293. }
  294. }
  295. }
  296. </script>
  297. <style>
  298. page{
  299. }
  300. </style>
  301. <style lang="scss" scoped>
  302. @import "@/_theme.scss";
  303. .all{
  304. @include themeify{
  305. font-size: themed('font-size1');
  306. }
  307. }
  308. .InviteFriends{
  309. background-image: linear-gradient(0deg, #a2e9c9 , #01b963);
  310. }
  311. .InviteFriends-head{
  312. display: flex;
  313. flex-direction: column;
  314. align-items: center;
  315. padding-top: 36px;
  316. .textImg{
  317. margin:20px 0 10px;
  318. }
  319. }
  320. .opacityClass{
  321. opacity: 0.2;
  322. }
  323. .InviteFriends-main{
  324. padding: 0 32px;
  325. }
  326. .InviteFriends-coupons{
  327. background-color: #fff;
  328. border-radius: 20px;
  329. padding: 20px;
  330. h4{
  331. @include themeify{
  332. font-size: themed('font-size3');
  333. }
  334. /* font-size: 15px;*/
  335. font-weight: normal;
  336. text-align: center;
  337. }
  338. .coupons-price{
  339. display: flex;
  340. justify-content: center;
  341. align-items: flex-end;
  342. margin: 16px 0;
  343. h2{
  344. @include themeify{
  345. font-size: themed('font-size17');
  346. line-height:themed('font-size17')
  347. }
  348. /*
  349. font-size: 44px;
  350. line-height: 44px;*/
  351. color:#FF9600;
  352. }
  353. span{
  354. @include themeify{
  355. font-size: themed('font-size4');
  356. }
  357. /* font-size: 18px;*/
  358. margin-left: 2px;
  359. }
  360. }
  361. .coupons-line{
  362. height: 1px;
  363. border-bottom: 1px dashed #cacaca;
  364. position: relative;
  365. &:before{
  366. content: '';
  367. position: absolute;
  368. height: 15px;
  369. width: 15px;
  370. background-color:#2dc67f ;
  371. border-radius: 50%;
  372. left:-27px;
  373. top:-7px;
  374. }
  375. &:after{
  376. content: '';
  377. position: absolute;
  378. height: 15px;
  379. width: 15px;
  380. background-color:#2dc67f ;
  381. border-radius: 50%;
  382. right:-27px;
  383. top:-7px;
  384. }
  385. }
  386. .coupons-btn{
  387. background-color: #FF9600;
  388. margin-top: 20px;
  389. height: 50px;
  390. text-align: center;
  391. line-height: 50px;
  392. border-radius: 25px;
  393. @include themeify{
  394. font-size: themed('font-size5');
  395. }
  396. /* font-size: 20px;*/
  397. color:#fff;
  398. span{
  399. margin-left: 8px;
  400. }
  401. }
  402. }
  403. .InviteFriends-title{
  404. color:#fff;
  405. margin: 40px 0 24px;
  406. @include themeify{
  407. font-size: themed('font-size4');
  408. }
  409. /* font-size: 18px;*/
  410. }
  411. .InviteFriends-info{
  412. background-color: #fff;
  413. border-radius: 20px;
  414. padding: 20px;
  415. .InviteFriends-info-row{
  416. display: flex;
  417. align-items: center;
  418. margin-bottom: 20px;
  419. &:last-child{
  420. margin-bottom: 0;
  421. }
  422. p{
  423. margin-left: 12px;
  424. @include themeify{
  425. font-size: themed('font-size3');
  426. }
  427. /* font-size: 16px;*/
  428. }
  429. }
  430. }
  431. .InviteFriends-tips{
  432. padding-left:30px;
  433. margin-top: -16px;
  434. span{
  435. float: left;
  436. color:#FF1C1C;
  437. }
  438. p{
  439. color:#999;
  440. }
  441. }
  442. .reward-head{
  443. background-color: #00B962;
  444. border-radius: 16px 16px 0 0;
  445. height: 75px;
  446. display: flex;
  447. justify-content: space-between;
  448. align-items: center;
  449. padding: 0 20px;
  450. margin: 0 4px;
  451. p{
  452. color:#fff;
  453. /* font-size: 17px;*/
  454. @include themeify{
  455. font-size: themed('font-size4');
  456. }
  457. }
  458. .reward-head-price{
  459. color:#fff;
  460. display: flex;
  461. align-items: flex-end;
  462. h2{
  463. @include themeify{
  464. font-size: themed('font-size13');
  465. line-height: themed('font-size13');
  466. }
  467. /* font-size: 36px;
  468. line-height: 36px;*/
  469. margin-right: 2px;
  470. }
  471. }
  472. }
  473. .reward-main{
  474. background-color: #fff;
  475. border-radius: 16px;
  476. padding: 24px;
  477. margin-top: -4px;
  478. .reward-info{
  479. display: flex;
  480. justify-content: space-between;
  481. .reward-info-item{
  482. width: 122px;
  483. height: 122px;
  484. display: flex;
  485. flex-direction: column;
  486. align-items: center;
  487. border:1px solid #CBE1D7 ;
  488. justify-content: center;
  489. border-radius: 12px;
  490. }
  491. p{
  492. @include themeify{
  493. font-size: themed('font-size3');
  494. }
  495. /* font-size: 16px;*/
  496. color:#666;
  497. margin-bottom: 10px;
  498. }
  499. .reward-info-price{
  500. display: flex;
  501. align-items: flex-end;
  502. h2{
  503. @include themeify{
  504. font-size: themed('font-size17');
  505. line-height: themed('font-size17');
  506. }
  507. /*
  508. font-size: 44px;
  509. line-height: 44px;*/
  510. margin-right: 2px;
  511. color:#00B962;
  512. }
  513. }
  514. .reward-info-item2{
  515. background-color:#E6EEEA;
  516. border: none;
  517. .reward-info-price h2{
  518. color:#333;
  519. }
  520. }
  521. }
  522. .reward-btn{
  523. height: 40px;
  524. width: 120px;
  525. border-radius: 20px;
  526. background-color: #00B962 ;
  527. /* line-height: 40px;*/
  528. color:#fff;
  529. text-align: center;
  530. @include themeify{
  531. font-size: themed('font-size4');
  532. line-height: themed('font-size15');
  533. }
  534. /* font-size: 18px;*/
  535. margin: 20px auto;
  536. }
  537. }
  538. .reward-list{
  539. //border-top: 1px dashed #cacaca;
  540. padding-top: 20px;
  541. .reward-list-title{
  542. @include themeify{
  543. font-size: themed('font-size4');
  544. }
  545. /* font-size: 18px;*/
  546. margin-bottom: 20px;
  547. }
  548. .rewardList-item{
  549. display: flex;
  550. justify-content: space-between;
  551. align-items: center;
  552. margin-top: 12px;
  553. span{
  554. margin-left: 12px;
  555. /* font-size: 16px;*/
  556. @include themeify{
  557. font-size: themed('font-size3');
  558. }
  559. }
  560. p{
  561. color:#999;
  562. }
  563. }
  564. }
  565. .InviteFriends-foot{
  566. text-align: center;
  567. color:#2A9563;
  568. padding: 20px 0 64px;
  569. }
  570. </style>