my.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <view class="yywegg">
  3. <u-navbar :is-back="false" :border-bottom="false" :background="background">
  4. <view style="width: 100%;">
  5. </view>
  6. </u-navbar>
  7. <view class="">
  8. <view class="fzctob mywoddt">
  9. <!-- @click.stop="getnickImage" -->
  10. <image :src="userinfo ? userinfo.avater : '/static/lecturer/le01.png'"
  11. style="width: 152rpx;height: 152rpx;border-radius:160rpx;min-width:152rpx;margin-right: 24rpx;"
  12. mode=""></image>
  13. <view class="flztoa" style="width: 100%;">
  14. <view class="fsxto">
  15. <view class="letxtfy nickName-text">
  16. <span v-if="!userinfo" @click="login">请登录</span>
  17. <span v-else>{{ userinfo.nickname}}</span>
  18. <image src="/static/lecturer/bianji.png" mode="widthFix" class="title-icon-bianji" @click="goToModifyInfo"></image>
  19. </view>
  20. <!-- <text class="letxtfy">美丽的蝴蝶</text> -->
  21. <input @blur="inputBlur" v-if="userinfo && type == 0" type="text" style="width: 400rpx;"
  22. placeholder="请输入签名" placeholder-style="color: #fff;" v-model="userinfo.desc">
  23. <image @click="upLabel" v-if="userinfo && type == '1' && userinfo.lecturer.tag.length==0"
  24. src="/static/my/add_label.png" style="width: 40rpx; height: 40rpx; border-radius: 50%;">
  25. </image>
  26. <view class="fzctob letxtfya" v-if="userinfo != '' && type == '1'" @click="upLabel">
  27. <text v-if="index<2" v-for="(item,index) in userinfo.lecturer.tag"
  28. :key="index">{{item}}</text>
  29. </view>
  30. </view>
  31. <view class="fzddrew letxtfyb" v-if="userinfo != ''" @click="changetype">
  32. <image src="/static/lecturer/le02.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  33. <text>切换身份</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="flztoa lebkty">
  38. <navigator class="fzddrew" style="width: 25%;" url="../lecturer/wdgz" hover-class="none">
  39. <text>{{userinfo.focus?userinfo.focus:'0'}}</text>
  40. <text class="leshurt">关注</text>
  41. </navigator>
  42. <view class="leshuxd"></view>
  43. <navigator class="fzddrew" style="width: 25%;" url="../lecturer/wdsc" hover-class="none">
  44. <text>{{userinfo.fans?userinfo.fans:'0'}}</text>
  45. <text class="leshurt">粉丝</text>
  46. </navigator>
  47. </view>
  48. </view>
  49. <view class="leybbaw" @click="clickUrllist">
  50. <!-- <navigator class="flztoa lelbyyr" url="../lecturer/wdcp" hover-class="none">
  51. <text>我的测评</text>
  52. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  53. </navigator>
  54. <view class="lehettnn"></view> -->
  55. <navigator class="flztoa lelbyyr" url="../lecturer/wdsc" hover-class="none">
  56. <text>我的收藏</text>
  57. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  58. </navigator>
  59. <view class="lehettnn"></view>
  60. <navigator class="flztoa lelbyyr" url="../lecturer/wdhd" hover-class="none">
  61. <text>我的活动</text>
  62. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  63. </navigator>
  64. <view class="lehettnn"></view>
  65. <navigator class="flztoa lelbyyr" url="../lecturer/wdkc" hover-class="none" v-show="type==1">
  66. <text>我的课程</text>
  67. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  68. </navigator>
  69. <view class="lehettnn" v-show="is_lecturer==1"></view>
  70. <navigator class="flztoa lelbyyr" url="../lecturer/kcdd" hover-class="none">
  71. <text>课程订单</text>
  72. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  73. </navigator>
  74. <view class="lehettnn"></view>
  75. <navigator class="flztoa lelbyyr" url="../lecturer/wdxuexi" hover-class="none">
  76. <text>我的学习</text>
  77. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  78. </navigator>
  79. <view class="lehettnn"></view>
  80. <!-- <navigator class="flztoa lelbyyr" url="../lecturer/wdzx" hover-class="none">
  81. <text>我的答疑</text>
  82. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  83. </navigator>
  84. <view class="lehettnn"></view> -->
  85. <!-- <navigator class="flztoa lelbyyr" url="../index/wdjh" hover-class="none">
  86. <text>我的解惑</text>
  87. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  88. </navigator>
  89. <view class="lehettnn"></view> -->
  90. <!--
  91. <navigator class="flztoa lelbyyr" url="../index/coupon" hover-class="none">
  92. <text>课程优惠券</text>
  93. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  94. </navigator> -->
  95. </view>
  96. <!-- <view class="leybbaw">
  97. <view class="flztoa lelbyyr" @click="showCode">
  98. <text>邀请</text>
  99. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  100. </view>
  101. </view>
  102. <view class="leybbaw">
  103. <navigator class="flztoa lelbyyr" url="../index/invite">
  104. <text>邀请码</text>
  105. <image src="/static/lecturer/le03.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
  106. </navigator>
  107. </view> -->
  108. <u-popup v-model="show" mode="center">
  109. <view class="wdcjeer" v-if="userinfo">
  110. <view class="wddvbh">
  111. <image :src="userinfo.avatarUrl" class="wddimg" mode=""></image>
  112. <text class="wddvbhtxt">{{userinfo.nickName}}</text>
  113. <view class="fzctob kcwwerrt" v-if="type==1" style="margin-top: 10rpx;">
  114. <text v-for="(item,index) in userinfo.lecturer.tag" :key="index">{{item}}</text>
  115. </view>
  116. <text v-else style="color: #333333; font-size: 32rpx;">{{userinfo.note}}</text>
  117. </view>
  118. <view class="" style="height: 170rpx;"></view>
  119. <view class="wddbwwt">
  120. <view class="wdbhgt">
  121. <image :src="code" style="width: 318rpx;height: 318rpx;" mode=""></image>
  122. </view>
  123. <text class="wdbhddn">分享二维码</text>
  124. </view>
  125. <view class="wddvbhyu">
  126. <image src="/static/my/myq1.png" @click="saveImage" style="width: 128rpx;height: 128rpx;" mode="">
  127. </image>
  128. <image src="/static/my/myq2.png" @click="shareWechat" style="width: 128rpx;height: 128rpx;" mode="">
  129. </image>
  130. <image src="/static/my/myq3.png" @click="shareFriend" style="width: 128rpx;height: 128rpx;" mode="">
  131. </image>
  132. </view>
  133. </view>
  134. </u-popup>
  135. <view style="height: 120rpx;"></view>
  136. <tabBar :active-index="activeIndex" @change="onTabBarChange"></tabBar>
  137. <!-- 绘制海报插件 -->
  138. <!-- :isCanvasToTempFilePath="canvasto" @success="path = $event" -->
  139. <l-painter v-if="userinfo && code" ref="painter" isCanvasToTempFilePath @success="path = $event"
  140. custom-style="position: fixed; left: 200%;"
  141. css="width: 750rpx; padding-bottom: 40rpx; background: rgba(0,170,255,0); padding-top: 113rpx;">
  142. <l-painter-view
  143. css="width: 702rpx; text-align: center; box-sizing: border-box; margin-left: 24rpx; padding: 30rpx; padding-bottom: 80rpx; border-radius: 16rpx; background: white;">
  144. <l-painter-image :src="userinfo.avatarUrl"
  145. css="box-sizing: border-box; display: block; margin: auto; margin-top: -120rpx; width: 200rpx;height: 200rpx; border-radius: 50%; box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(0, 0, 0, 0.1607843137254902); border: 4rpx solid #FFFFFF;">
  146. </l-painter-image>
  147. <l-painter-text :text="userinfo.nickName"
  148. css="box-sizing: border-box; color: #333333; font-size: 50rpx;"></l-painter-text>
  149. <l-painter-text v-if="type==0" :text="userinfo.note"
  150. css="display: block; box-sizing: border-box; color: #333333; font-size: 22rpx;"></l-painter-text>
  151. <l-painter-view v-else>
  152. <l-painter-text v-for="(item,index) in userinfo.lecturer.tag" :key="index" :text="item"
  153. css="margin-top: 10rpx; margin-right: 20rpx; border-radius: 38rpx; background: #F4F4F4; color: #999999; padding: 2rpx 20rpx; display: inline-block; font-size: 20rpx;">
  154. </l-painter-text>
  155. </l-painter-view>
  156. <l-painter-view
  157. css="margin: auto; text-align: center; margin-top: 90rpx; width: 372rpx; height: 372rpx; background-image: url(/static/my/myr1.png) top center no-repeat">
  158. <l-painter-image :src="code"
  159. css="width: 318rpx; box-sizing: border-box; margin-top: 24rpx; height: 318rpx;">
  160. </l-painter-image>
  161. </l-painter-view>
  162. </l-painter-view>
  163. </l-painter>
  164. <!-- <image v-show="path" :src="path" mode="widthFix" style="width: 100%;"></image> -->
  165. <u-popup v-model="labelshow" mode="bottom" :closeable="false" :border-radius="20"
  166. :safe-area-inset-bottom="true">
  167. <view class="" style="padding: 50rpx;30rpx">
  168. <view class="flztoa" style="margin-bottom: 40rpx;">
  169. <text @click="labelshow = false;" style="color: #999999;">取消</text>
  170. <text style="font-size: 36rpx;font-weight: bold;">选择标签</text>
  171. <text @click="ensureLabel">确定</text>
  172. </view>
  173. <!-- <view class="tanckku">
  174. <uni-data-checkbox :multiple="true" mode="tag" v-model="radioa" :localdata="sex"
  175. selectedColor="#374B6E !important" style="margin-top: 24rpx;"></uni-data-checkbox>
  176. </view> -->
  177. <scroll-view scroll-y style="height: 500rpx;">
  178. <view class="label-outer">
  179. <view :class="item.toggle?'label-act':'class-label'" @click="changeLabel(index)"
  180. v-for="(item,index) in labellist" :key="index">{{item.title}}</view>
  181. </view>
  182. </scroll-view>
  183. </view>
  184. </u-popup>
  185. </view>
  186. </template>
  187. <style>
  188. page {
  189. background: #FAFAFA;
  190. }
  191. </style>
  192. <script>
  193. export default {
  194. data() {
  195. return {
  196. show: false,
  197. labelshow: false,
  198. background: {
  199. backgroundColor: '#95bf7f',
  200. },
  201. type: '', //0普通用户 1讲师
  202. userinfo: '', //全部用户信息
  203. path: '', // 海报生成的图片路径
  204. is_lecturer: 0,
  205. type: 0, // 展示当前身份 0 普通 1 讲师
  206. code: '',
  207. logininfo: '', // 登录成功后返回的info
  208. labellist: [],
  209. is_login: true,
  210. activeIndex: 3,
  211. }
  212. },
  213. onLoad() {
  214. // uni.showLoading({
  215. // title: '绘制中...',
  216. // })
  217. // this.getuserinfo(false);
  218. // uni.setStorageSync('id',4)
  219. //
  220. let invite_id = uni.getStorageSync('invite_id');
  221. let user_id = uni.getStorageSync('id');
  222. },
  223. watch: {
  224. path(val) {
  225. if (val != '') {
  226. uni.hideLoading()
  227. }
  228. }
  229. },
  230. onShow() {
  231. this.activeIndex = 3;
  232. this.is_lecturer = uni.getStorageSync('is_lecturer')
  233. // if(uni.getStorageSync('id')){
  234. // this.canvasto = true
  235. // }
  236. console.log('onshow')
  237. if (uni.getStorageSync('id')) {
  238. this.getuserinfo(false);
  239. this.type = uni.getStorageSync('type')
  240. } else {
  241. this.userinfo == '';
  242. }
  243. },
  244. methods: {
  245. onTabBarChange(index) {
  246. this.activeIndex = index;
  247. },
  248. // 点击修改
  249. goToModifyInfo(){
  250. uni.navigateTo({
  251. url: '/pages/lecturer/modifyInfo/modifyInfo',
  252. })
  253. },
  254. // 确定修改标签
  255. ensureLabel() {
  256. let toggleArr = this.labellist.filter(item => item.toggle)
  257. let tagsarr = []
  258. toggleArr.map(item => {
  259. tagsarr.push(item.title)
  260. })
  261. this.$post({
  262. data: {
  263. do: 'LecturerTagUpdate',
  264. data: {
  265. tags: tagsarr.join(','),
  266. id: uni.getStorageSync('id')
  267. }
  268. }
  269. }).then(res => {
  270. this.labelshow = false
  271. uni.showToast({
  272. icon: 'none',
  273. title: res.message,
  274. mask: true
  275. })
  276. setTimeout(() => {
  277. this.getuserinfo()
  278. }, 1500)
  279. console.log(res, '++++')
  280. })
  281. },
  282. // 改变标签选择状态
  283. changeLabel(index) {
  284. let length = this.labellist.filter(item => item.toggle).length
  285. if (length >= 2 && !this.labellist[index].toggle) {
  286. return
  287. }
  288. this.labellist[index].toggle = !this.labellist[index].toggle
  289. },
  290. // 讲师标签
  291. upLabel() {
  292. this.$post({
  293. data: {
  294. do: 'LecturerTag',
  295. data: {
  296. page: 1
  297. }
  298. }
  299. }).then(res => {
  300. console.log(res, '+++')
  301. let labellist = []
  302. // this.userinfo.lecturer.tag
  303. res.data.map(item => {
  304. labellist.push({
  305. title: item,
  306. toggle: this.userinfo.lecturer.tag.includes(item) ? true : false
  307. // toggle:false
  308. })
  309. })
  310. this.labellist = labellist
  311. this.labelshow = true
  312. })
  313. },
  314. // 更新
  315. inputBlur() {
  316. let id = uni.getStorageSync('id');
  317. this.$request.saveuserInfo({
  318. desc: this.userinfo.desc
  319. }).then( res =>{
  320. console.log(res)
  321. }).catch( e=>{
  322. console.log(e)
  323. })
  324. },
  325. getnickImage() {
  326. console.log(this.logininfo.id)
  327. uni.getUserProfile({
  328. desc: '用于昵称和头像的展示',
  329. success: res => {
  330. console.log(res, '++++')
  331. console.log({
  332. user_id: this.logininfo.id,
  333. nickName: res.userInfo.nickName,
  334. avatarUrl: res.userInfo.avatarUrl
  335. })
  336. this.$post({
  337. data: {
  338. do: 'UpdateUser',
  339. data: {
  340. user_id: this.logininfo.id,
  341. nickName: res.userInfo.nickName,
  342. avatarUrl: res.userInfo.avatarUrl
  343. }
  344. }
  345. }).then(res => {
  346. console.log(res, 'rrrrrrrrrr')
  347. for (let i in this.logininfo) {
  348. uni.setStorageSync(i, this.logininfo[i])
  349. }
  350. this.type == 0;
  351. this.getuserinfo();
  352. })
  353. // this.nickName = res.userInfo.nickName
  354. // this.avatarUrl = res.userInfo.avatarUrl
  355. // this.country = res.userInfo.country
  356. // this.province = res.userInfo.province
  357. // this.city = res.userInfo.city
  358. // this.gender = res.userInfo.gender
  359. // uni.login({
  360. // provider: 'weixin',
  361. // success: (res) => {
  362. // this.loginCode = res.code
  363. // uni.hideLoading()
  364. // this.popShow = true
  365. // },
  366. // })
  367. },
  368. fail: (err) => {
  369. uni.hideLoading()
  370. }
  371. })
  372. },
  373. showCode() {
  374. if (uni.getStorageSync('id')) {
  375. this.show = true
  376. } else {
  377. // #ifdef MP
  378. this.mpLogin()
  379. return
  380. // #endif
  381. }
  382. },
  383. // 获取二维码
  384. getCode() {
  385. this.$post({
  386. data: {
  387. do: 'GetUserQr',
  388. data: {
  389. user_id: uni.getStorageSync('id')
  390. }
  391. },
  392. loading: false
  393. }).then(res => {
  394. console.log(res, 'cccccccccccc')
  395. this.code = res.data.url
  396. })
  397. },
  398. login() {
  399. if(!this.is_login){
  400. return
  401. }
  402. this.is_login = false;
  403. this.mpLogin();
  404. // if (!uni.getStorageSync('id')) {
  405. // // #ifdef MP
  406. // this.mpLogin()
  407. // // #endif
  408. // // #ifndef MP
  409. // uni.navigateTo({
  410. // url: '/pages/login/appLogin'
  411. // })
  412. // // #endif
  413. // }
  414. },
  415. // 小程序登录
  416. mpLogin() {
  417. let that = this;
  418. uni.login({
  419. provider: 'weixin',
  420. success: (res) => {
  421. console.log(res, 'rrrrrr')
  422. const code = res.code;
  423. that.getLogin(code);
  424. }
  425. })
  426. },
  427. getLogin(c){
  428. let that = this;
  429. uni.showLoading({
  430. title: "登录中..."
  431. })
  432. that.$request.getLogin({code:c}).then(res => {
  433. uni.hideLoading();
  434. console.log(res)
  435. if(res.code == 0){
  436. that.logininfo = res.data;
  437. that.userinfo = res.data;
  438. uni.setStorageSync('userinfo',res.data);
  439. uni.setStorageSync('id',res.data.id);
  440. uni.setStorageSync("token",res.data.token);
  441. that.is_login = true;
  442. }else{
  443. uni.showToast({
  444. title: res.message,
  445. icon: 'none'
  446. })
  447. }
  448. // uni.showModal({
  449. // title: '提示',
  450. // content: '是否进行头像和昵称授权',
  451. // success: (res) => {
  452. // if (res.confirm) {
  453. // this.getnickImage()
  454. // }
  455. // }
  456. // })
  457. }).catch(e =>{
  458. uni.hideLoading();
  459. console.log(e)
  460. that.is_login = true;
  461. })
  462. },
  463. //获取用户信息
  464. getuserinfo(loading = true) {
  465. let id = uni.getStorageSync('id');
  466. this.$request.getuserinfo({
  467. id
  468. }).then( res =>{
  469. console.log(res)
  470. this.userinfo = res.data
  471. }).catch( e=>{
  472. console.log(e)
  473. })
  474. },
  475. changetype() {
  476. uni.navigateTo({
  477. url: '../index/yhdl',
  478. // success: () => {
  479. // setTimeout(() => {
  480. // this.userinfo = '' // 切换身份 重新绘制海报使用
  481. // }, 500)
  482. // }
  483. })
  484. },
  485. // 保存海报
  486. saveImage() {
  487. if (this.path) {
  488. uni.saveImageToPhotosAlbum({
  489. filePath: this.path,
  490. success: function() {
  491. uni.showToast({
  492. title: '保存成功'
  493. })
  494. }
  495. });
  496. } else {
  497. uni.showToast({
  498. title: '海报绘制失败,请截图分享',
  499. icon: 'none'
  500. })
  501. }
  502. },
  503. // 分享给好友
  504. shareWechat() {
  505. // #ifdef MP
  506. uni.showShareImageMenu({
  507. path: this.path
  508. })
  509. // #endif
  510. // #ifdef APP-PLUS
  511. uni.share({
  512. provider: "weixin",
  513. scene: "WXSceneSession", // WXSceneSession 微信聊天界面 WXSceneTimeline 朋友圈
  514. type: 2,
  515. imageUrl: this.path,
  516. success: function(res) {
  517. console.log("success:" + JSON.stringify(res));
  518. },
  519. fail: function(err) {
  520. console.log("fail:" + JSON.stringify(err));
  521. }
  522. });
  523. // #endif
  524. },
  525. // 分享朋友圈
  526. shareFriend() {
  527. // #ifdef MP
  528. uni.showToast({
  529. title: '请将海报保存到手机,自行分享。',
  530. icon: 'none'
  531. })
  532. // #endif
  533. // #ifdef APP-PLUS
  534. uni.share({
  535. provider: "weixin",
  536. scene: "WXSceneTimeline", // WXSceneSession 微信聊天界面 WXSceneTimeline 朋友圈
  537. type: 2,
  538. imageUrl: this.path,
  539. success: function(res) {
  540. console.log("success:" + JSON.stringify(res));
  541. },
  542. fail: function(err) {
  543. console.log("fail:" + JSON.stringify(err));
  544. }
  545. });
  546. // #endif
  547. },
  548. }
  549. }
  550. </script>
  551. <style lang="scss" scoped>
  552. .nickName-text{
  553. display: flex;
  554. align-items: center;
  555. }
  556. .title-icon-bianji{
  557. width: 32rpx;
  558. height: 36rpx;
  559. margin-left: 16rpx;
  560. }
  561. </style>
  562. <style>
  563. .label-outer {
  564. display: flex;
  565. flex-wrap: wrap;
  566. align-content: flex-start;
  567. }
  568. .label-outer>view {
  569. margin-right: 30rpx;
  570. margin-bottom: 30rpx;
  571. }
  572. .label-outer>view:nth-of-type(3n+3) {
  573. margin-right: 0rpx;
  574. }
  575. .class-label {
  576. width: 192rpx;
  577. height: 72rpx;
  578. background: #F4F4F4;
  579. border-radius: 36rpx 36rpx 36rpx 36rpx;
  580. opacity: 1;
  581. display: flex;
  582. justify-content: center;
  583. align-items: center;
  584. font-size: 28rpx;
  585. color: #999999;
  586. overflow: hidden;
  587. }
  588. .label-act {
  589. width: 192rpx;
  590. height: 72rpx;
  591. background: #374B6E;
  592. border-radius: 36rpx;
  593. font-size: 28rpx;
  594. color: #FFFFFF;
  595. display: flex;
  596. justify-content: center;
  597. align-items: center;
  598. font-size: 28rpx;
  599. color: #ffffff;
  600. overflow: hidden;
  601. }
  602. </style>