InviteFriends.vue 12 KB

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