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="["+ProjectName+"]"+'和好友一起领5元红包'
  196. var desc="来自"+info.nickName+"的邀请"
  197. let joinUrl = window.location.href.split("#")[0]+"#/?friends=friends&id="+this.id+"&icode="+this.code+"&uid="+info.id;
  198. var _this = this;
  199. jweixin.ready(function() {
  200. console.log("readyreadyreadyreadyready")
  201. jweixin.updateAppMessageShareData({
  202. title: title,
  203. desc:desc ,
  204. link: joinUrl,
  205. imgUrl: img,
  206. success: function() {
  207. console.log("updateAppMessageShareData")
  208. // 设置成功
  209. _this.$emit("wxShare",null);
  210. }
  211. })
  212. jweixin.updateTimelineShareData({
  213. title: title,
  214. desc:desc ,
  215. link: joinUrl,
  216. imgUrl: img,
  217. success: function() {
  218. console.log("updateTimelineShareData")
  219. // 设置成功
  220. _this.$emit("wxShare",null);
  221. }
  222. })
  223. });
  224. }
  225. }
  226. }
  227. </script>
  228. <style>
  229. page{
  230. }
  231. </style>
  232. <style lang="scss" scoped>
  233. @import "@/_theme.scss";
  234. .all{
  235. @include themeify{
  236. font-size: themed('font-size1');
  237. }
  238. }
  239. .InviteFriends{
  240. background-image: linear-gradient(0deg, #a2e9c9 , #01b963);
  241. }
  242. .InviteFriends-head{
  243. display: flex;
  244. flex-direction: column;
  245. align-items: center;
  246. padding-top: 36px;
  247. .textImg{
  248. margin:20px 0 10px;
  249. }
  250. }
  251. .InviteFriends-main{
  252. padding: 0 32px;
  253. }
  254. .InviteFriends-coupons{
  255. background-color: #fff;
  256. border-radius: 20px;
  257. padding: 20px;
  258. h4{
  259. @include themeify{
  260. font-size: themed('font-size3');
  261. }
  262. /* font-size: 15px;*/
  263. font-weight: normal;
  264. text-align: center;
  265. }
  266. .coupons-price{
  267. display: flex;
  268. justify-content: center;
  269. align-items: flex-end;
  270. margin: 16px 0;
  271. h2{
  272. @include themeify{
  273. font-size: themed('font-size17');
  274. line-height:themed('font-size17')
  275. }
  276. /*
  277. font-size: 44px;
  278. line-height: 44px;*/
  279. color:#FF9600;
  280. }
  281. span{
  282. @include themeify{
  283. font-size: themed('font-size4');
  284. }
  285. /* font-size: 18px;*/
  286. margin-left: 2px;
  287. }
  288. }
  289. .coupons-line{
  290. height: 1px;
  291. border-bottom: 1px dashed #cacaca;
  292. position: relative;
  293. &:before{
  294. content: '';
  295. position: absolute;
  296. height: 15px;
  297. width: 15px;
  298. background-color:#2dc67f ;
  299. border-radius: 50%;
  300. left:-27px;
  301. top:-7px;
  302. }
  303. &:after{
  304. content: '';
  305. position: absolute;
  306. height: 15px;
  307. width: 15px;
  308. background-color:#2dc67f ;
  309. border-radius: 50%;
  310. right:-27px;
  311. top:-7px;
  312. }
  313. }
  314. .coupons-btn{
  315. background-color: #FF9600;
  316. margin-top: 20px;
  317. height: 50px;
  318. text-align: center;
  319. line-height: 50px;
  320. border-radius: 25px;
  321. @include themeify{
  322. font-size: themed('font-size5');
  323. }
  324. /* font-size: 20px;*/
  325. color:#fff;
  326. span{
  327. margin-left: 8px;
  328. }
  329. }
  330. }
  331. .InviteFriends-title{
  332. color:#fff;
  333. margin: 40px 0 24px;
  334. @include themeify{
  335. font-size: themed('font-size4');
  336. }
  337. /* font-size: 18px;*/
  338. }
  339. .InviteFriends-info{
  340. background-color: #fff;
  341. border-radius: 20px;
  342. padding: 20px;
  343. .InviteFriends-info-row{
  344. display: flex;
  345. align-items: center;
  346. margin-bottom: 20px;
  347. &:last-child{
  348. margin-bottom: 0;
  349. }
  350. p{
  351. margin-left: 12px;
  352. @include themeify{
  353. font-size: themed('font-size3');
  354. }
  355. /* font-size: 16px;*/
  356. }
  357. }
  358. }
  359. .InviteFriends-tips{
  360. padding-left:30px;
  361. margin-top: -16px;
  362. span{
  363. float: left;
  364. color:#FF1C1C;
  365. }
  366. p{
  367. color:#999;
  368. }
  369. }
  370. .reward-head{
  371. background-color: #00B962;
  372. border-radius: 16px 16px 0 0;
  373. height: 75px;
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. padding: 0 20px;
  378. margin: 0 4px;
  379. p{
  380. color:#fff;
  381. /* font-size: 17px;*/
  382. @include themeify{
  383. font-size: themed('font-size4');
  384. }
  385. }
  386. .reward-head-price{
  387. color:#fff;
  388. display: flex;
  389. align-items: flex-end;
  390. h2{
  391. @include themeify{
  392. font-size: themed('font-size13');
  393. line-height: themed('font-size13');
  394. }
  395. /* font-size: 36px;
  396. line-height: 36px;*/
  397. margin-right: 2px;
  398. }
  399. }
  400. }
  401. .reward-main{
  402. background-color: #fff;
  403. border-radius: 16px;
  404. padding: 24px;
  405. margin-top: -4px;
  406. .reward-info{
  407. display: flex;
  408. justify-content: space-between;
  409. .reward-info-item{
  410. width: 122px;
  411. height: 122px;
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. border:1px solid #CBE1D7 ;
  416. justify-content: center;
  417. border-radius: 12px;
  418. }
  419. p{
  420. @include themeify{
  421. font-size: themed('font-size3');
  422. }
  423. /* font-size: 16px;*/
  424. color:#666;
  425. margin-bottom: 10px;
  426. }
  427. .reward-info-price{
  428. display: flex;
  429. align-items: flex-end;
  430. h2{
  431. @include themeify{
  432. font-size: themed('font-size17');
  433. line-height: themed('font-size17');
  434. }
  435. /*
  436. font-size: 44px;
  437. line-height: 44px;*/
  438. margin-right: 2px;
  439. color:#00B962;
  440. }
  441. }
  442. .reward-info-item2{
  443. background-color:#E6EEEA;
  444. border: none;
  445. .reward-info-price h2{
  446. color:#333;
  447. }
  448. }
  449. }
  450. .reward-btn{
  451. height: 40px;
  452. width: 120px;
  453. border-radius: 20px;
  454. background-color: #00B962 ;
  455. /* line-height: 40px;*/
  456. color:#fff;
  457. text-align: center;
  458. @include themeify{
  459. font-size: themed('font-size4');
  460. line-height: themed('font-size15');
  461. }
  462. /* font-size: 18px;*/
  463. margin: 20px auto;
  464. }
  465. }
  466. .reward-list{
  467. //border-top: 1px dashed #cacaca;
  468. padding-top: 20px;
  469. .reward-list-title{
  470. @include themeify{
  471. font-size: themed('font-size4');
  472. }
  473. /* font-size: 18px;*/
  474. margin-bottom: 20px;
  475. }
  476. .rewardList-item{
  477. display: flex;
  478. justify-content: space-between;
  479. align-items: center;
  480. margin-top: 12px;
  481. span{
  482. margin-left: 12px;
  483. /* font-size: 16px;*/
  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: 20px 0 64px;
  497. }
  498. </style>