InviteFriends.vue 12 KB

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