index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <template>
  2. <view class="content container">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view class="h110"></view>
  5. <!-- #endif -->
  6. <view class="bg"></view>
  7. <view class="cont-box">
  8. <view class="user-cont" @click="navTo('/pages/user/userInfo')">
  9. <view class="user-box" v-if="user!=null">
  10. <view class="left">
  11. <u-avatar :src="user.avatar" size="50"></u-avatar>
  12. <!-- <image class="img" :src="user.avatar" mode="aspectFill"></image> -->
  13. <view class="user" >
  14. <view class="username">{{user.nickName}}</view>
  15. <view class="account">{{user.email}}</view>
  16. </view>
  17. </view>
  18. <view class="right" >
  19. <image :src="imgPath+'/app/images/right_arrow.png'"></image>
  20. </view>
  21. </view>
  22. <view class="justify-between align-center">
  23. <view class="company" v-if="user!=null">
  24. <!-- <image :src="imgPath+'/app/images/icon_comp.png'"></image> -->
  25. <view class="base-color-6">公司:</view>
  26. <view class="name">{{user.companyName||'暂无数据'}}</view>
  27. </view>
  28. <view class="company" v-if="user!=null">
  29. <view class="base-color-6">部门:</view>
  30. <view class="name">{{user.dept.deptName||'无'}}</view>
  31. </view>
  32. </view>
  33. <view class="justify-between align-center">
  34. <view class="company" v-if="user!=null">
  35. <view class="base-color-6">岗位:</view>
  36. <view class="name">{{user.postname||'无'}}</view>
  37. </view>
  38. <view class="company" v-if="user!=null">
  39. <view class="base-color-6">角色:</view>
  40. <view class="name">{{user.rolesname||'无'}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="bgf radius15 p30 justify-between align-center mb40" v-if="balance" >
  45. <view class="fs24">红包剩余金额</view>
  46. <view class="fs40 bold">{{balance.toFixed(2)}}</view>
  47. </view>
  48. <view class="menu-box" style="margin-top: -20rpx;" >
  49. <view class="title-box">
  50. <image class="icon" :src="imgPath+'/app/manergevip/chang.png'"></image>
  51. <view class="title">常用功能</view>
  52. </view>
  53. <view class="line"></view>
  54. <view class="menus" v-if="user!=null">
  55. <view class="menu-item" @click="navTo('/pages_manage/manageIndex')">
  56. <image :src="imgPath+'/app/images/menu_info.png'"></image>
  57. <view class="m-name">销售管理</view>
  58. </view>
  59. <view class="menu-item" @click="navTo('/pages/user/users/users')" v-if="user.userType=='00'">
  60. <image :src="imgPath+'/app/manergevip/qudao.png'"></image>
  61. <view class="m-name">审核销售</view>
  62. </view>
  63. <view class="menu-item" @click="handleShare" v-if="user.userType=='00'">
  64. <image :src="imgPath+'/app/manergevip/share-manage.png'" ></image>
  65. <view class="m-name">邀请销售</view>
  66. </view>
  67. <view class="menu-item" @click="navTo('/pages/courseManage/manage/lableSetup')">
  68. <image :src="imgPath+'/app/images/changeLable.png'"></image>
  69. <view class="m-name">标签设置</view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="menu-box">
  74. <view class="title-box">
  75. <image class="icon" :src="imgPath+'/app/manergevip/qita.png'"></image>
  76. <view class="title">其它工具</view>
  77. </view>
  78. <view class="line"></view>
  79. <view class="menus">
  80. <view class="menu-item" @click="navTo('/pages/user/about')">
  81. <image :src="imgPath+'/app/manergevip/about.png'"></image>
  82. <view class="m-name">关于我们</view>
  83. </view>
  84. <view class="menu-item" @click="navTo('/pages/user/editUser')">
  85. <image :src="imgPath+'/app/manergevip/setup.png'"></image>
  86. <view class="m-name">设置</view>
  87. </view>
  88. <!-- <view class="menu-item" @click="navTo('/pages_course/exportlist/exportlist')">
  89. <u-icon name="attach" color="#2979ff" size="28"></u-icon>
  90. <view class="m-name">导出列表</view>
  91. </view> -->
  92. </view>
  93. </view>
  94. <view class="btn-box" >
  95. <view class="sub-btn" @click="showLogout()">退出登录</view>
  96. </view>
  97. </view>
  98. <!-- 分享弹窗 -->
  99. <u-popup :show="showShare" :closeOnClickOverlay="true" :round='20' @close="closeShare" @open="openShare">
  100. <view class="sharePop x-ac">
  101. <!--#ifdef MP-WEIXIN-->
  102. <view class="sharePop-item y-f" @click="shareimg">
  103. <image :src="imgPath+'/app/images/card_icon.png'" mode="aspectFill"
  104. style="width: 80rpx; height: 80rpx;margin-top: 20rpx;"></image>
  105. <view style="font-weight: bold;margin-bottom: 4px;">生成卡片</view>
  106. <view style="font-size: 12px;color: #888;">指导分享轻松转发</view>
  107. <button open-type="share" class="share">分享课程</button>
  108. </view>
  109. <!--#endif-->
  110. <!-- <view class="sharePop-item y-f" @click="buildimg">
  111. <image :src="imgPath+'/app/images/poster_icon.png'" mode="aspectFill"></image>
  112. <view style="font-weight: bold;margin-bottom: 4px;">生成海报</view>
  113. <view style="font-size: 12px;color: #888;">保存海报美观宣传</view>
  114. </view> -->
  115. <!--#ifdef H5-->
  116. <view class="sharePop-item y-f" @click="shareSale">
  117. <image :src="imgPath+'/app/images/link_icon.png'" mode="aspectFill"></image>
  118. <view style="font-weight: bold;margin-bottom: 4px;">复制链接</view>
  119. <view style="font-size: 12px;color: #888;">生成链接一键复制</view>
  120. </view>
  121. <!--#endif-->
  122. </view>
  123. </u-popup>
  124. <!-- 长按保存海报 -->
  125. <u-popup :show="setImg" @close="closeimg" :round="12">
  126. <view class="w100 h500">
  127. <image :src="codeLink.url" class="codeimg w660" mode="widthFix"></image>
  128. </view>
  129. <view class="justify-around mtb40">
  130. <view class="column justify-center align-center" @click="downimg">
  131. <image :src="imgPath+'/app/image/downicon.png'" class="w80 h80"></image>
  132. <view class="mt10">长按图片保存</view>
  133. </view>
  134. </view>
  135. </u-popup>
  136. <!-- 设置链接有效时长弹窗 -->
  137. <!-- <u-modal :show="setTimeShow" content='content' class="model" @confirm="confirmTime">
  138. <view class="setTimebox">
  139. <view class="timetip">不传默认以系统参数为准</view>
  140. <view class="x-f">
  141. <text style="margin-right: 20px;">链接有效时长(分钟)</text>
  142. <u-input fontSize="14px" placeholder="链接有效时长" border="none" v-model="time" maxlength="5"></u-input>
  143. </view>
  144. </view>
  145. </u-modal> -->
  146. <!-- 卡片分享引导 -->
  147. <u-overlay :show="showzhidao" @click="showzhidao = false" style="z-index: 9999;">
  148. <view class="point-box">
  149. <view class="imgshe" >
  150. <image :src="imgPath+'/app/image/point.png'" class="w300 h300"></image>
  151. </view>
  152. <view class="column colorf fs32 xu-box fs40
  153. align-center justify-center">
  154. <view class="justify-center">点击右上角
  155. <image :src="imgPath+'/app/image/wxmore.png'"
  156. class="w50 h50 mlr10"></image>
  157. </view>
  158. <view class="mt20">选择 “转发给朋友”</view>
  159. <view style="color: #cbcbcb;" class="fs28 mt40">点击任意位置关闭弹窗</view>
  160. </view>
  161. </view>
  162. </u-overlay>
  163. <u-modal :show="show" title="提示" :showCancelButton="true" @cancel="hideLogout()" @confirm="logout()" content='确认退出吗?'></u-modal>
  164. </view>
  165. </template>
  166. <script>
  167. import { getCompanyUser } from '@/api/user.js'
  168. import {
  169. sharecourselink,
  170. buildCode,
  171. getSDK,
  172. becomeVipuser,
  173. becomeVipuserImg
  174. } from '@/api/courseManage'
  175. import wx from 'weixin-js-sdk'
  176. export default {
  177. data() {
  178. return {
  179. show:false,
  180. user:null,
  181. showShare:false,
  182. copyLinks:'',
  183. setTimeShow:false,
  184. time:'',
  185. setImg:false,
  186. codeLink:'',
  187. showzhidao:false,
  188. imgs:this.$store.state.imgpath+'/app/image/logoshare.png',
  189. balance:0
  190. }
  191. },
  192. onShow() {
  193. console.log(this.imgs)
  194. this.getCompanyUsers()
  195. },
  196. onShareAppMessage() {
  197. return {
  198. title: this.$store.state.logoname+'小程序的'+this.user.nickName+'邀请您成为销售', // 分享卡片标题
  199. path: '/pages_course/course/becomeSale?id='+this.user.companyId+'&companyUserId='+this.user.userId, // 目标页面路径
  200. // 携带参数:将当前页面的数据拼接到路径中
  201. imageUrl: this.imgs, // 分享卡片封面图(可选)
  202. success: (res) => {
  203. console.log("分享成功", res);
  204. },
  205. fail: (err) => {
  206. console.log("分享失败", err);
  207. },
  208. }
  209. },
  210. computed: {
  211. imgPath() {
  212. return this.$store.state.imgpath
  213. }
  214. },
  215. mounted() {
  216. },
  217. methods: {
  218. shareSale(){
  219. const fullUrl = location.href;
  220. const Path = fullUrl.split('/#')[0] || '';
  221. setTimeout(() => {
  222. uni.setClipboardData({
  223. data: Path+'/#/pages_course/course/becomeSale?id='+this.user.companyId,
  224. success: () => {
  225. uni.showToast({
  226. title: '邀请链接已复制',
  227. icon: 'none',
  228. duration: 2000
  229. });
  230. // this.setTimeShow = !this.setTimeShow
  231. this.showShare = false
  232. // console.log(res)
  233. },
  234. fail: () => {
  235. uni.showToast({
  236. title: '复制失败',
  237. icon: 'none'
  238. });
  239. }
  240. });
  241. }, 100)
  242. },
  243. // 获取jssdk
  244. getjssdklist() {
  245. const param = {
  246. url: window.location.href.split('#')[0] // 注意去除 hash
  247. }
  248. getSDK(param).then(res => {
  249. wx.config({
  250. debug: false,
  251. appId: res.data.appId, // 必填,公众号的唯一标识
  252. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  253. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  254. signature: res.data.signature, // 必填,签名
  255. jsApiList: ["updateAppMessageShareData", "onMenuShareAppMessage", ] // 必填,需要使用的JS接口列表
  256. });
  257. })
  258. },
  259. shareimg(){
  260. //分享好友
  261. let self = this
  262. // 配置--配置全局
  263. wx.ready(function() { //需在用户可能点击分享按钮前就先调用
  264. wx.updateAppMessageShareData({
  265. title: self.user.userName+"邀请您成为销售", // 分享标题
  266. desc: self.user.deptName, // 分享描述
  267. link:self.copyLinks,
  268. imgUrl: self.codeLink.url ||self.imgs, // 分享图标
  269. success: function(res) {
  270. self.showzhidao=true
  271. self.setImg=false
  272. self.showShare=false
  273. // 设置成功
  274. uni.showToast({
  275. title: '卡片已生成',
  276. icon: 'none',
  277. duration: 1000
  278. });
  279. },
  280. fail: function(err) {
  281. // console.log(err);
  282. uni.showToast({
  283. title: '卡片生成失败,请重试',
  284. icon: 'none',
  285. duration: 2000
  286. })
  287. }
  288. })
  289. });
  290. },
  291. handleShare() {
  292. this.showShare = true
  293. // this.getjssdklist()
  294. // this.getlink('preload'); // 提前加载链接
  295. },
  296. //设置链接时长
  297. confirmTime() {
  298. this.setTimeShow = false
  299. this.showShare = false
  300. this.getlink('preload')
  301. this.copyLink()
  302. },
  303. closeimg(){
  304. this.setImg=false
  305. this.showShare=false
  306. },
  307. buildimg() {
  308. //生成海报
  309. this.setImg=!this.setImg
  310. this.getshareimg()
  311. },
  312. getshareimg(){
  313. //生成海报
  314. uni.showLoading({
  315. title: '正在生成中...'
  316. })
  317. const param={
  318. code:'',
  319. companyId:this.user.companyId,
  320. companyUserId:this.user.userId
  321. }
  322. becomeVipuserImg(param).then(res=>{
  323. if(res.code==200){
  324. this.codeLink=res.data
  325. this.getlink()
  326. // console.log(res)
  327. }else{
  328. uni.showToast({
  329. title: res.msg,
  330. icon: 'none',
  331. duration: 2000
  332. });
  333. }
  334. })
  335. },
  336. getlink(type){
  337. //生成链接
  338. const param={
  339. companyId:this.user.companyId,
  340. companyUserId:this.user.userId,
  341. tagids:'',
  342. limitTime:this.time
  343. }
  344. becomeVipuser(param).then(res=>{
  345. if(res.code==200){
  346. this.copyLinks=res.data
  347. if (this.copyLinks.startsWith('http://')) {
  348. this.copyLinks = this.copyLinks.replace('http://', 'https://');
  349. }
  350. // console.log(this.copyLinks,'分享链接')
  351. }else{
  352. }
  353. })
  354. },
  355. copyLink(){
  356. console.log(this.showShare)
  357. setTimeout(() => {
  358. uni.setClipboardData({
  359. data: this.copyLinks,
  360. success: () => {
  361. uni.showToast({
  362. title: '链接已复制',
  363. icon: 'none',
  364. duration: 2000
  365. });
  366. // this.setTimeShow = !this.setTimeShow
  367. this.showShare = false
  368. },
  369. fail: () => {
  370. uni.showToast({
  371. title: '复制失败',
  372. icon: 'none'
  373. });
  374. }
  375. });
  376. }, 100)
  377. },
  378. closeShare() {
  379. this.showShare = false
  380. },
  381. openShare() {
  382. // this.showShare = false
  383. },
  384. showLogout(){
  385. this.show=true;
  386. },
  387. hideLogout(){
  388. this.show=false;
  389. },
  390. logout(){
  391. uni.removeStorageSync('AppToken')
  392. // 条件编译判断平台,设置不同登录页路径
  393. let loginPage = '';
  394. // #ifdef H5
  395. loginPage = '/pages/auth/login';
  396. // #endif
  397. // #ifdef MP-WEIXIN
  398. loginPage = '/pages/auth/login';
  399. // #endif
  400. uni.navigateTo({
  401. url: loginPage,
  402. })
  403. },
  404. navTo(url){
  405. uni.navigateTo({
  406. url
  407. })
  408. },
  409. getCompanyUsers(){
  410. var data = {
  411. };
  412. getCompanyUser(data).then(res => {
  413. if(res.code==200){
  414. console.log(res)
  415. this.user=res.user;
  416. this.balance=res.balance
  417. if(res.user.posts){
  418. this.user.postname=res.user.posts.map(item=>item.postName).join(",")
  419. }
  420. if(res.user.roles){
  421. this.user.rolesname=res.user.roles.map(item=>item.roleName).join(",")
  422. }
  423. if(this.user.avatar){
  424. this.user.avatar=uni.getStorageSync('requestPath')+res.user.avatar
  425. }else{
  426. this.user.avatar=='';
  427. }
  428. console.log('头像',this.user.avatar)
  429. }else{
  430. }
  431. });
  432. },
  433. }
  434. }
  435. </script>
  436. <style lang="scss">
  437. page{
  438. height: 100%;
  439. background: #f6f6f6;
  440. }
  441. </style>
  442. <style scoped lang="scss">
  443. .share{
  444. display: inline-block;
  445. position: absolute;
  446. top: 0;
  447. left: 0;
  448. width: 100%;
  449. height: 100%;
  450. opacity: 0;
  451. }
  452. .container {
  453. font-family: PingFang SC, PingFang SC;
  454. font-weight: 400;
  455. font-size: 14px;
  456. color: #222222;
  457. height: 100%;
  458. overflow: hidden;
  459. }
  460. .imgshe{
  461. display: flex;
  462. flex-direction: row-reverse
  463. }
  464. .point-box{
  465. height: 100%;
  466. width: 100%;
  467. .xu-box{
  468. border: #f5f5f5 4rpx dashed;
  469. padding: 20rpx 20rpx;
  470. }
  471. }
  472. .setTimebox {
  473. font-family: PingFang SC, PingFang SC;
  474. font-weight: 400;
  475. font-size: 14px;
  476. width: fit-content;
  477. height: fit-content;
  478. }
  479. .codeimg {
  480. position: absolute;
  481. z-index: 9999;
  482. left: 40rpx;
  483. top: 40rpx;
  484. }
  485. .timetip {
  486. font-family: PingFang SC, PingFang SC;
  487. font-weight: 400;
  488. font-size: 14px;
  489. color: #2979ff;
  490. text-align: center;
  491. margin-bottom: 5px;
  492. }
  493. .content{
  494. position: relative;
  495. height: 100%;
  496. width: 100%;
  497. .bg{
  498. width: 100%;
  499. height: 550upx;
  500. position: absolute;
  501. top: 0;
  502. left: 0;
  503. z-index: 1;
  504. background: linear-gradient(to bottom, #dae9ff, #e1e1fd);
  505. // background: linear-gradient(to bottom, #8bbfff, #1773ff);
  506. border-radius: 0rpx 0rpx 60rpx 60rpx;
  507. }
  508. .cont-box{
  509. position: relative;
  510. z-index: 2;
  511. padding: 30rpx 30rpx 200rpx;
  512. .user-cont{
  513. // box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  514. padding: 30rpx;
  515. // background-color: #fff;
  516. border-radius: 15rpx;
  517. .user-box{
  518. width: 100%;
  519. display: flex;
  520. align-items: center;
  521. justify-content: flex-start;
  522. .left{
  523. flex:1;
  524. display: flex;
  525. align-items: center;
  526. justify-content: flex-start;
  527. image{
  528. border-radius: 50%;
  529. width:120rpx;
  530. height:120rpx;
  531. }
  532. .user{
  533. margin-left: 20rpx;
  534. width: calc(100% - 140rpx);
  535. display: flex;
  536. flex-direction: column;
  537. align-items: flex-start;
  538. justify-content: flex-start;
  539. .username{
  540. font-size: 38rpx;
  541. font-family: PingFang SC;
  542. color: #111;
  543. font-weight: bold;
  544. }
  545. .account{
  546. padding: 5rpx 0rpx;
  547. border-radius: 30rpx;
  548. margin-top: 20rpx;
  549. font-size: 24rpx;
  550. font-family: PingFang SC;
  551. color: #515151;
  552. }
  553. }
  554. }
  555. .right{
  556. image{
  557. width: 15rpx;
  558. height:30rpx;
  559. }
  560. }
  561. }
  562. .company{
  563. margin-top: 20rpx;
  564. display: flex;
  565. align-items: center;
  566. justify-content: flex-start;
  567. image{
  568. width:40rpx;
  569. height:40rpx;
  570. }
  571. .name{
  572. margin-left: 15rpx;
  573. font-size: 28rpx;
  574. color: #111;
  575. }
  576. }
  577. }
  578. .menu-box{
  579. box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  580. width: 100%;
  581. margin-top: 30rpx;
  582. padding: 30rpx;
  583. background-color: #fff;
  584. border-radius: 15rpx;
  585. .title-box{
  586. display: flex;
  587. align-items: center;
  588. justify-content: flex-start;
  589. .icon{
  590. width: 40rpx;
  591. height:40rpx;
  592. }
  593. .title{
  594. margin-left: 10rpx;
  595. font-size: 28rpx;
  596. font-family: PingFang SC;
  597. color: #111;
  598. }
  599. }
  600. .line{
  601. margin-top: 15rpx;
  602. height: 0.5rpx;
  603. width: 100%;
  604. background-color: #efefef;
  605. }
  606. .menus{
  607. margin-top: 30rpx;
  608. display: flex;
  609. align-items: center;
  610. justify-content: flex-start;
  611. flex-wrap: wrap;
  612. }
  613. .menu-item{
  614. display: flex;
  615. flex-direction: column;
  616. align-items: center;
  617. justify-content: center;
  618. width: 25%;
  619. margin-bottom: 20rpx;
  620. image{
  621. width:60rpx;
  622. height:60rpx;
  623. }
  624. .m-name{
  625. margin-top: 10rpx;
  626. font-size: 24rpx;
  627. font-family: PingFang SC;
  628. color: #111;
  629. }
  630. }
  631. }
  632. .menu-box1{
  633. width: 100%;
  634. margin-top: 30rpx;
  635. padding: 0rpx 30rpx;
  636. background-color: #fff;
  637. border-radius: 15rpx;
  638. .menu-item{
  639. width: 100%;
  640. display: flex;
  641. align-items: center;
  642. justify-content: flex-start;
  643. line-height: 100rpx;
  644. .left{
  645. flex:1;
  646. display: flex;
  647. align-items: center;
  648. justify-content: flex-start;
  649. image{
  650. width: 30rpx;
  651. height:30rpx;
  652. }
  653. .label{
  654. margin-left: 10rpx;
  655. }
  656. }
  657. .right{
  658. image{
  659. width: 10rpx;
  660. height:15rpx;
  661. }
  662. }
  663. }
  664. }
  665. }
  666. }
  667. .btn-box{
  668. margin: 30rpx 0rpx 30rpx;
  669. display: flex;
  670. align-items: center;
  671. justify-content: center;
  672. .sub-btn{
  673. // box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
  674. border: 1rpx solid #f8f8f8;
  675. background: #FFFFFF;
  676. width: 100%;
  677. height: 88upx;
  678. line-height: 88upx;
  679. text-align: center;
  680. font-size: 30upx;
  681. font-family: PingFang SC;
  682. color: #2979ff;
  683. }
  684. }
  685. .sharePop {
  686. background-color: #fff;
  687. padding: 20px 0;
  688. border-radius: 20px 20px 0 0;
  689. &-item {
  690. padding: 0 10px;
  691. box-sizing: border-box;
  692. font-family: PingFang SC, PingFang SC;
  693. font-weight: 400;
  694. font-size: 14px;
  695. display: inline-flex !important;
  696. image {
  697. height: 48px;
  698. width: 48px;
  699. margin-bottom: 10px;
  700. }
  701. }
  702. }
  703. </style>