InviteFriends.vue 13 KB

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