InviteFriends.vue 15 KB

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