InviteFriends.vue 15 KB

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