InviteFriends.vue 13 KB

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