InviteFriends.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <view class="all">
  3. <u-mask :show="show" @click="show = false">
  4. <u-image width="100%" height="1000rpx" :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: 40rpx ;" >
  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>{{availableAmount}}</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;">{{availableAmount}}</span>元服务费代金券</p>
  51. </view>
  52. <view class="InviteFriends-tips">
  53. <span>*</span><p>邀请成功,你和好友各得{{availableAmount}}元服务费代金券,一年有效;邀请更多人,你可领最高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: 30rpx;"
  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. availableAmount:2,
  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: 175,
  145. height: 175,
  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 = process.car.gzUrl;
  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. this.availableAmount=res.data.availableAmount
  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: 72rpx;
  323. .textImg{
  324. margin:40rpx 0 20rpx;
  325. }
  326. }
  327. .opacityClass{
  328. opacity: 0.2;
  329. }
  330. .InviteFriends-main{
  331. margin-top: 10rpx;
  332. padding: 0 58rpx;
  333. }
  334. .InviteFriends-coupons{
  335. background-color: #fff;
  336. border-radius: 40rpx;
  337. padding: 40rpx;
  338. .h4{
  339. color: rgba(16, 16, 16, 1);
  340. font-size: 32rpx;
  341. text-align: center;
  342. margin-bottom: 16rpx;
  343. }
  344. .coupons-price{
  345. display: flex;
  346. justify-content: center;
  347. align-items: flex-end;
  348. margin-bottom: 36rpx;
  349. h2{
  350. @include themeify{
  351. font-size: themed('font-size17');
  352. line-height:themed('font-size17')
  353. }
  354. color:#FF9600;
  355. }
  356. span{
  357. @include themeify{
  358. font-size: themed('font-size4');
  359. }
  360. margin-left: 4rpx;
  361. }
  362. }
  363. .coupons-line{
  364. height: 1px;
  365. border-bottom: 1px dashed #cacaca;
  366. position: relative;
  367. &:before{
  368. content: '';
  369. position: absolute;
  370. height: 30rpx;
  371. width: 30rpx;
  372. background-color:#2dc67f ;
  373. border-radius: 50%;
  374. left:-54rpx;
  375. top:-14rpx;
  376. }
  377. &:after{
  378. content: '';
  379. position: absolute;
  380. height: 30rpx;
  381. width: 30rpx;
  382. background-color:#2dc67f ;
  383. border-radius: 50%;
  384. right:-54rpx;
  385. top:-14rpx;
  386. }
  387. }
  388. .coupons-btn{
  389. background-color: #FF9600;
  390. margin-top: 40rpx;
  391. height: 100rpx;
  392. text-align: center;
  393. line-height: 100rpx;
  394. border-radius: 50rpx;
  395. font-size: 40rpx;
  396. color:#fff;
  397. span{
  398. margin-left: 32rpx;
  399. }
  400. }
  401. }
  402. .InviteFriends-title{
  403. color:#fff;
  404. margin: 80rpx 0 48rpx;
  405. @include themeify{
  406. font-size: themed('font-size4');
  407. }
  408. }
  409. .InviteFriends-info{
  410. background-color: #fff;
  411. border-radius: 40rpx;
  412. padding: 40rpx;
  413. .InviteFriends-info-row{
  414. display: flex;
  415. align-items: center;
  416. margin-bottom: 40rpx;
  417. &:last-child{
  418. margin-bottom: 0;
  419. }
  420. p{
  421. margin-left: 24rpx;
  422. @include themeify{
  423. font-size: themed('font-size3');
  424. }
  425. }
  426. }
  427. }
  428. .InviteFriends-tips{
  429. padding-left:60rpx;
  430. margin-top: -32rpx;
  431. span{
  432. float: left;
  433. color:#FF1C1C;
  434. }
  435. p{
  436. color:#999;
  437. }
  438. }
  439. .reward-head{
  440. background-color: #00B962;
  441. border-radius: 32rpx 32rpx 0 0;
  442. height: 140rpx;
  443. display: flex;
  444. justify-content: space-between;
  445. align-items: center;
  446. padding: 0 30rpx 0 40rpx;
  447. margin: 0 8rpx;
  448. p{
  449. color:#fff;
  450. /* ;*/
  451. font-size: 36rpx
  452. }
  453. .reward-head-price{
  454. color:#fff;
  455. display: flex;
  456. align-items: flex-end;
  457. h2{
  458. @include themeify{
  459. font-size: themed('font-size13');
  460. line-height: themed('font-size13');
  461. }
  462. margin-right: 4rpx;
  463. }
  464. }
  465. }
  466. .reward-main{
  467. background-color: #fff;
  468. border-radius: 32rpx;
  469. padding: 48rpx;
  470. margin-top: -8rpx;
  471. }
  472. .reward-list{
  473. .reward-list-title{
  474. font-size: 40rpx;
  475. margin-bottom: 40rpx;
  476. }
  477. .rewardList-item{
  478. display: flex;
  479. justify-content: space-between;
  480. align-items: center;
  481. margin-top: 24rpx;
  482. span{
  483. margin-left: 24rpx;
  484. @include themeify{
  485. font-size: themed('font-size3');
  486. }
  487. }
  488. p{
  489. color:#999;
  490. }
  491. }
  492. }
  493. .InviteFriends-foot{
  494. text-align: center;
  495. color:#2A9563;
  496. padding: 40rpx 0 128rpx;
  497. }
  498. .qrcode3{
  499. color: rgba(16, 16, 16, 1);
  500. font-size: 32rpx;
  501. margin-top: 24rpx;
  502. }
  503. </style>