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