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 ="http://oss.xiaoxinda.com/charging/chargingconfigure/2022/6/6/ec228c56-487a-4ae1-ac6f-37284060fbba/hongbao.jpg"
  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. var _this=this
  269. jweixin.ready(function() {
  270. //("readyreadyreadyreadyready")
  271. jweixin.updateAppMessageShareData({
  272. title: title,
  273. desc:desc ,
  274. link: joinUrl,
  275. imgUrl: img,
  276. success: function() {
  277. //("updateAppMessageShareData")
  278. // 设置成功
  279. _this.$emit("wxShare",null);
  280. }
  281. })
  282. jweixin.updateTimelineShareData({
  283. title: title,
  284. desc:desc ,
  285. link: joinUrl,
  286. imgUrl: img,
  287. success: function() {
  288. //("updateTimelineShareData")
  289. // 设置成功
  290. _this.$emit("wxShare",null);
  291. }
  292. })
  293. });
  294. }
  295. }
  296. }
  297. </script>
  298. <style>
  299. page{
  300. }
  301. </style>
  302. <style lang="scss" scoped>
  303. @import "@/_theme.scss";
  304. .all{
  305. @include themeify{
  306. font-size: themed('font-size1');
  307. }
  308. }
  309. .InviteFriends{
  310. background-image: linear-gradient(0deg, #a2e9c9 , #01b963);
  311. }
  312. .InviteFriends-head{
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. padding-top: 36px;
  317. .textImg{
  318. margin:20px 0 10px;
  319. }
  320. }
  321. .opacityClass{
  322. opacity: 0.2;
  323. }
  324. .InviteFriends-main{
  325. padding: 0 32px;
  326. }
  327. .InviteFriends-coupons{
  328. background-color: #fff;
  329. border-radius: 20px;
  330. padding: 20px;
  331. h4{
  332. @include themeify{
  333. font-size: themed('font-size3');
  334. }
  335. /* font-size: 15px;*/
  336. font-weight: normal;
  337. text-align: center;
  338. }
  339. .coupons-price{
  340. display: flex;
  341. justify-content: center;
  342. align-items: flex-end;
  343. margin: 16px 0;
  344. h2{
  345. @include themeify{
  346. font-size: themed('font-size17');
  347. line-height:themed('font-size17')
  348. }
  349. /*
  350. font-size: 44px;
  351. line-height: 44px;*/
  352. color:#FF9600;
  353. }
  354. span{
  355. @include themeify{
  356. font-size: themed('font-size4');
  357. }
  358. /* font-size: 18px;*/
  359. margin-left: 2px;
  360. }
  361. }
  362. .coupons-line{
  363. height: 1px;
  364. border-bottom: 1px dashed #cacaca;
  365. position: relative;
  366. &:before{
  367. content: '';
  368. position: absolute;
  369. height: 15px;
  370. width: 15px;
  371. background-color:#2dc67f ;
  372. border-radius: 50%;
  373. left:-27px;
  374. top:-7px;
  375. }
  376. &:after{
  377. content: '';
  378. position: absolute;
  379. height: 15px;
  380. width: 15px;
  381. background-color:#2dc67f ;
  382. border-radius: 50%;
  383. right:-27px;
  384. top:-7px;
  385. }
  386. }
  387. .coupons-btn{
  388. background-color: #FF9600;
  389. margin-top: 20px;
  390. height: 50px;
  391. text-align: center;
  392. line-height: 50px;
  393. border-radius: 25px;
  394. @include themeify{
  395. font-size: themed('font-size5');
  396. }
  397. /* font-size: 20px;*/
  398. color:#fff;
  399. span{
  400. margin-left: 8px;
  401. }
  402. }
  403. }
  404. .InviteFriends-title{
  405. color:#fff;
  406. margin: 40px 0 24px;
  407. @include themeify{
  408. font-size: themed('font-size4');
  409. }
  410. /* font-size: 18px;*/
  411. }
  412. .InviteFriends-info{
  413. background-color: #fff;
  414. border-radius: 20px;
  415. padding: 20px;
  416. .InviteFriends-info-row{
  417. display: flex;
  418. align-items: center;
  419. margin-bottom: 20px;
  420. &:last-child{
  421. margin-bottom: 0;
  422. }
  423. p{
  424. margin-left: 12px;
  425. @include themeify{
  426. font-size: themed('font-size3');
  427. }
  428. /* font-size: 16px;*/
  429. }
  430. }
  431. }
  432. .InviteFriends-tips{
  433. padding-left:30px;
  434. margin-top: -16px;
  435. span{
  436. float: left;
  437. color:#FF1C1C;
  438. }
  439. p{
  440. color:#999;
  441. }
  442. }
  443. .reward-head{
  444. background-color: #00B962;
  445. border-radius: 16px 16px 0 0;
  446. height: 75px;
  447. display: flex;
  448. justify-content: space-between;
  449. align-items: center;
  450. padding: 0 20px;
  451. margin: 0 4px;
  452. p{
  453. color:#fff;
  454. /* font-size: 17px;*/
  455. @include themeify{
  456. font-size: themed('font-size4');
  457. }
  458. }
  459. .reward-head-price{
  460. color:#fff;
  461. display: flex;
  462. align-items: flex-end;
  463. h2{
  464. @include themeify{
  465. font-size: themed('font-size13');
  466. line-height: themed('font-size13');
  467. }
  468. /* font-size: 36px;
  469. line-height: 36px;*/
  470. margin-right: 2px;
  471. }
  472. }
  473. }
  474. .reward-main{
  475. background-color: #fff;
  476. border-radius: 16px;
  477. padding: 24px;
  478. margin-top: -4px;
  479. .reward-info{
  480. display: flex;
  481. justify-content: space-between;
  482. .reward-info-item{
  483. width: 122px;
  484. height: 122px;
  485. display: flex;
  486. flex-direction: column;
  487. align-items: center;
  488. border:1px solid #CBE1D7 ;
  489. justify-content: center;
  490. border-radius: 12px;
  491. }
  492. p{
  493. @include themeify{
  494. font-size: themed('font-size3');
  495. }
  496. /* font-size: 16px;*/
  497. color:#666;
  498. margin-bottom: 10px;
  499. }
  500. .reward-info-price{
  501. display: flex;
  502. align-items: flex-end;
  503. h2{
  504. @include themeify{
  505. font-size: themed('font-size17');
  506. line-height: themed('font-size17');
  507. }
  508. /*
  509. font-size: 44px;
  510. line-height: 44px;*/
  511. margin-right: 2px;
  512. color:#00B962;
  513. }
  514. }
  515. .reward-info-item2{
  516. background-color:#E6EEEA;
  517. border: none;
  518. .reward-info-price h2{
  519. color:#333;
  520. }
  521. }
  522. }
  523. .reward-btn{
  524. height: 40px;
  525. width: 120px;
  526. border-radius: 20px;
  527. background-color: #00B962 ;
  528. /* line-height: 40px;*/
  529. color:#fff;
  530. text-align: center;
  531. @include themeify{
  532. font-size: themed('font-size4');
  533. line-height: themed('font-size15');
  534. }
  535. /* font-size: 18px;*/
  536. margin: 20px auto;
  537. }
  538. }
  539. .reward-list{
  540. //border-top: 1px dashed #cacaca;
  541. padding-top: 20px;
  542. .reward-list-title{
  543. @include themeify{
  544. font-size: themed('font-size4');
  545. }
  546. /* font-size: 18px;*/
  547. margin-bottom: 20px;
  548. }
  549. .rewardList-item{
  550. display: flex;
  551. justify-content: space-between;
  552. align-items: center;
  553. margin-top: 12px;
  554. span{
  555. margin-left: 12px;
  556. /* font-size: 16px;*/
  557. @include themeify{
  558. font-size: themed('font-size3');
  559. }
  560. }
  561. p{
  562. color:#999;
  563. }
  564. }
  565. }
  566. .InviteFriends-foot{
  567. text-align: center;
  568. color:#2A9563;
  569. padding: 20px 0 64px;
  570. }
  571. </style>