user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <view class="content">
  3. <view class="top" style="position: relative;">
  4. <view class="avater">
  5. <image :src="userInfo.avatar" class="avater-img" mode="" v-if="userInfo.avatar"></image>
  6. <image src="../../static/img/002.png" mode="" v-else class="avater-img"></image>
  7. </view>
  8. <view class="name-box">
  9. <view class="name-top">
  10. {{userInfo.nickname}}<text v-if="userInfo && userInfo.level_name && userInfo.level > 1">{{'('+ userInfo.level_name +')'}}</text>
  11. </view>
  12. <!-- <view class="" v-if="userInfo && userInfo.level_name && userInfo.level > 1" style="color: #fff;font-size: 32rpx;">
  13. <text v-if="vip_endtime < newTime">已到期,立即续费</text><text>{{userInfo.vip_endtime | time}} 到期<text @click="xuFei()">(续费)</text></text>
  14. </view> -->
  15. </view>
  16. <!-- <view class="sy-box flex">
  17. <view class="sy-item">
  18. <view class="sy-item-name">
  19. 我的积分
  20. </view>
  21. <view class="sy-item-val">
  22. {{userInfo.score || '0'}}
  23. </view>
  24. </view>
  25. <view class="sy-item">
  26. <view class="sy-item-name">
  27. 帮助项目
  28. </view>
  29. <view class="sy-item-val">
  30. {{helpCount}}
  31. </view>
  32. </view>
  33. </view> -->
  34. </view>
  35. <!-- <view class="btm-box flex" @click="navTo('/pages/user/myFu')" style="">
  36. <image src="../../static/icon/u-1.png" mode="widthFix" class="left-img"></image>
  37. <view class="">我的帮扶</view>
  38. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  39. </view> -->
  40. <!-- <view class="nav-item flex" @click="navTo('/pages/form/myDonate')">
  41. <view class="item-left flex">
  42. <image src="../../static/icon/u-jk.png" mode="" class="img1"></image>
  43. <view class="title">捐款记录</view>
  44. </view>
  45. <view class="item-right">
  46. >
  47. </view>
  48. </view> -->
  49. <view class="btm-box flex" @click="navTo('/pages/form/myDonate')">
  50. <image src="../../static/icon/u-2.png" mode="widthFix" class="left-img"></image>
  51. <view class="">捐款记录</view>
  52. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  53. </view>
  54. <!-- <view class="btm-box flex" @click="tohelp" >
  55. <image src="../../static/icon/u-3.png" mode="widthFix" class="left-img"></image>
  56. <view class="">求援记录</view>
  57. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  58. </view> -->
  59. <!-- <view class="btm-box flex"@click="torreco">
  60. <image src="../../static/icon/u-2.png" mode="widthFix" class="left-img"></image>
  61. <view class="">救援记录</view>
  62. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  63. </view>
  64. <view class="btm-box flex" @click="tohelp" >
  65. <image src="../../static/icon/u-3.png" mode="widthFix" class="left-img"></image>
  66. <view class="">求援记录</view>
  67. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  68. </view> -->
  69. <!-- <view class="btm-box flex" @click="commonaddress">
  70. <image src="../../static/icon/u-4.png" mode="widthFix" class="left-img"></image>
  71. <view class="">常用地址</view>
  72. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  73. </view> -->
  74. <!-- <view class="btm-box flex" @click="tocertificates">
  75. <image src="../../static/icon/u-5.png" mode="widthFix" class="left-img"></image>
  76. <view class="">我的证书</view>
  77. <image src="../../static/icon/goto.png" mode="widthFix" class="right-img"></image>
  78. </view> -->
  79. <!-- <view class="loginout" @click="loginout()">
  80. 退出
  81. </view> -->
  82. </view>
  83. </template>
  84. <script>
  85. import { userapplylst } from '@/api/help.js'
  86. import {
  87. mapState,
  88. mapMutations
  89. } from 'vuex';
  90. import {
  91. saveUrl,
  92. interceptor
  93. } from '@/utils/loginUtils.js';
  94. import { detail_training } from '@/api/train.js';
  95. import {
  96. userinfo,
  97. logout
  98. } from '@/api/user.js';
  99. // #ifdef H5
  100. import {
  101. weixindata
  102. } from '@/utils/wxAuthorized';
  103. // #endif
  104. import { getVipmoney, createOrder } from '@/api/index.js'
  105. export default {
  106. data() {
  107. return {
  108. helpCount: 0,//帮助数量
  109. common_address:'',
  110. name:'',
  111. signDate:'',
  112. id:0,
  113. is_over:0,
  114. newTime: 0,
  115. money: '',
  116. mid: '',
  117. }
  118. },
  119. filters: {
  120. time(val) {
  121. let str = '';
  122. // console.log(val)
  123. if (val) {
  124. let date = new Date(val * 1000);
  125. let Y = date.getFullYear();
  126. let M = date.getMonth() + 1 > 9 ? (date.getMonth()+1) : '0' + (date.getMonth()+1);
  127. let D = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
  128. str = Y + '年' + M + '月' + D + '日';
  129. }
  130. return str;
  131. },
  132. },
  133. onShow() {
  134. console.log(this);
  135. let obj = this
  136. // 判断是否已经登录
  137. if (this.hasLogin) {
  138. this.loadBaseData();
  139. getVipmoney().then(({
  140. data
  141. }) => {
  142. console.log(data, 'getVipmoney');
  143. data.forEach(e => {
  144. if (e.name == obj.userInfo.level_name) {
  145. obj.money = e.pay_price;
  146. obj.mid = e.id;
  147. console.log(obj.money, obj.mid)
  148. }
  149. });
  150. });
  151. } else {
  152. saveUrl();
  153. uni.showModal({
  154. title: '登录',
  155. content: '您未登录,是否马上登陆?',
  156. success: e => {
  157. if (e.confirm) {
  158. interceptor();
  159. }
  160. },
  161. fail: e => {
  162. console.log(e);
  163. }
  164. });
  165. }
  166. this.type = this.userInfo.type;
  167. this.common_address = this.userInfo.common_address
  168. let str = new Date()
  169. this.newTime = str.getTime()
  170. console.log('点前保存的地址',this.common_address)
  171. // 保存当前页面
  172. this.userapplylst()
  173. },
  174. onReady() {
  175. console.log(99999)
  176. // detail_training({
  177. // id:this.id,
  178. // }).then(({data}) => {
  179. // console.log(999,data)
  180. // this.name = data.name
  181. // this.signDate = data.add_time
  182. // this.is_over = data.is_over
  183. // })
  184. },
  185. computed: {
  186. ...mapState('user', ['hasLogin', 'userInfo']),
  187. ...mapState(['weichatObj']),
  188. },
  189. methods: {
  190. ...mapMutations('user', ['setUserInfo','logout']),
  191. // 续费
  192. xuFei() {
  193. let obj = this
  194. uni.showModal({
  195. title: '提示',
  196. content: '续费' + obj.userInfo.level_name + '需要缴纳' + obj.money + '元年费,是否续费',
  197. success: function(res) {
  198. if (res.confirm) {
  199. console.log('用户点击确定');
  200. createOrder({
  201. level_id: obj.mid,
  202. body: '红会年费',
  203. pay_type: 0,
  204. // name: obj.name,
  205. pay_price: obj.money,
  206. from: 'weixin'
  207. }).then(({data}) =>{
  208. let res = data.jsConfig;
  209. obj.weichatObj.chooseWXPay({
  210. timestamp: res.timestamp,
  211. nonceStr: res.nonceStr,
  212. package: res.package,
  213. signType: res.signType,
  214. paySign: res.paySign,
  215. success: function(res) {
  216. // uni.navigateTo({
  217. // url: '../joinSuc/joinNow'
  218. // });
  219. obj.loadBaseData()
  220. uni.showModal({
  221. title:'提示',
  222. content: '续费成功'
  223. })
  224. },
  225. fail: function(res) {
  226. console.log(res, "失败")
  227. console.log(res.errMsg)
  228. }
  229. });
  230. })
  231. } else if (res.cancel) {
  232. console.log('用户点击取消');
  233. }
  234. }
  235. });
  236. },
  237. // 登出
  238. loginout() {
  239. let obj = this;
  240. uni.showModal({
  241. content: '确定要退出登录么',
  242. success: e => {
  243. if (e.confirm) {
  244. logout({}).then(e => {
  245. obj.logout();
  246. uni.switchTab({
  247. url: '/pages/index/index'
  248. })
  249. })
  250. .catch(e => {
  251. console.log(e);
  252. });
  253. }
  254. }
  255. });
  256. },
  257. tojkjl() {
  258. uni.navigateTo({
  259. url: '/pages/user/jkjl'
  260. })
  261. },
  262. loadBaseData() {
  263. userinfo({}).then(({
  264. data
  265. }) => {
  266. this.setUserInfo(data);
  267. });
  268. // #ifdef H5
  269. weixindata();
  270. // #endif
  271. // detail_training({
  272. // id:this.id,
  273. // }).then(({data}) => {
  274. // console.log(9,data)
  275. // this.name = data.name
  276. // this.signDate = data.add_time
  277. // this.is_over = data.is_over
  278. // })
  279. },
  280. toMyfu() {
  281. uni.navigateTo({
  282. url: '/pages/user/myFu'
  283. })
  284. },
  285. torreco() {
  286. uni.navigateTo({
  287. url: '/pages/applic/rescuerecords'
  288. })
  289. },
  290. tohelp() {
  291. uni.navigateTo({
  292. url: '/pages/applic/helprecords'
  293. })
  294. },
  295. commonaddress() {
  296. uni.navigateTo({
  297. url: '/pages/applic/commonaddress?add=' + this.common_address
  298. })
  299. },
  300. tocertificates() {
  301. uni.navigateTo({
  302. // pages/form/certificatesList
  303. // url: '/pages/form/certificates?name=' + this.name + '&signDate=' + this.signDate
  304. url: '/pages/form/certificatesList'
  305. })
  306. },
  307. navTo(url) {
  308. console.log(url)
  309. uni.navigateTo({
  310. url: url
  311. })
  312. },
  313. userapplylst() {
  314. let obj = this
  315. userapplylst({
  316. page:1,
  317. limit:1000,
  318. status:1
  319. }).then(res => {
  320. console.log(res)
  321. obj.helpCount = res.data.data.length
  322. })
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss">
  328. page {
  329. min-height: 100%;
  330. height: auto;
  331. background: #f8f8f8;
  332. }
  333. .content {
  334. line-height: 1.5;
  335. background-color:#f8f8f8;
  336. height: 100%;
  337. .top {
  338. width: 750rpx;
  339. height: 601rpx;
  340. // background-color: #fa7e67;
  341. display: flex;
  342. flex-direction: column;
  343. align-items: center;
  344. // padding-left: 55rpx;
  345. align-items: center;
  346. justify-content: center;
  347. background-image: url(../../static/img/user-bg.png);
  348. background-size: 100% 100%;
  349. .avater {
  350. width: 150rpx;
  351. height: 150rpx;
  352. // margin-right: 28rpx;
  353. .avater-img {
  354. width: 100%;
  355. height: 100%;
  356. border-radius: 50%;
  357. }
  358. }
  359. .name-box {
  360. // flex: 1;
  361. padding-top: 25rpx;
  362. .name-top {
  363. font-size: 42rpx;
  364. font-weight: 400;
  365. margin-bottom: 15rpx;
  366. font-size: 32rpx;
  367. font-family: PingFang SC;
  368. font-weight: 500;
  369. color: #FFFFFF;
  370. text-align: center;
  371. }
  372. .name-bottom{
  373. margin-top: 16rpx;
  374. display: flex;
  375. align-items: center;
  376. // justify-content: center;
  377. .nameInfo{
  378. color: #FFFFFF;
  379. padding: 6rpx 16rpx;
  380. border: 1rpx solid #FFFFFF;
  381. border-radius: 12rpx;
  382. // background-color: pink;
  383. }
  384. }
  385. .name-footbox {
  386. .name-foot {
  387. text-align: center;
  388. font-size: 22rpx;
  389. font-weight: 400;
  390. color: #FFFFFF;
  391. background: rgba(255, 255, 255, 0.2);
  392. border: 1px solid #FFFFFF;
  393. border-radius: 20rpx;
  394. padding: 3rpx 13rpx;
  395. }
  396. }
  397. }
  398. }
  399. .center-box {
  400. width: 687rpx;
  401. // height: 235px;
  402. background: #FFE8E8;
  403. border-radius: 16rpx;
  404. margin: -90rpx auto 0;
  405. .center-top {
  406. width: 687rpx;
  407. height: 80rpx;
  408. background: #FFFFFF;
  409. border-radius: 16rpx 16rpx 0 0;
  410. display: flex;
  411. align-items: center;
  412. padding-left: 30rpx;
  413. .top-left {
  414. width: 126rpx;
  415. line-height: 32rpx;
  416. text-align: center;
  417. background: linear-gradient(0deg, #C90F1B, #F14D33);
  418. font-size: 22rpx;
  419. font-weight: 400;
  420. color: #FFFFFF;
  421. border-radius: 20rpx;
  422. margin-right: 10rpx;
  423. }
  424. .top-right {
  425. font-size: 22rpx;
  426. font-weight: 400;
  427. color: #CB151D;
  428. }
  429. }
  430. .center-foot {
  431. height: 155rpx;
  432. display: flex;
  433. .foot-list {
  434. flex: 1;
  435. text-align: center;
  436. padding-top: 20rpx;
  437. .list-top {
  438. font-size: 39rpx;
  439. font-weight: 400;
  440. color: #CB141D;
  441. line-height: 58rpx;
  442. }
  443. .list-foot {
  444. font-size: 39rpx;
  445. font-weight: 400;
  446. color: #666666;
  447. line-height: 58rpx;
  448. }
  449. }
  450. }
  451. }
  452. .tt {
  453. display: flex;
  454. flex-wrap: wrap;
  455. padding-left:32rpx;
  456. .tt-box {
  457. width: 206rpx;
  458. height: 206rpx;
  459. border-radius: 10rpx;
  460. display: flex;
  461. flex-direction: column;
  462. align-items: center;
  463. justify-content: center;
  464. margin-right: 35rpx;
  465. margin-bottom: 30rpx;
  466. image {
  467. width: 64rpx;
  468. height: 64rpx;
  469. }
  470. .tt-txt {
  471. font-size: 24rpx;
  472. font-family: PingFang SC;
  473. font-weight: bold;
  474. color: #5A5A74;
  475. padding-top: 35rpx;
  476. }
  477. }
  478. }
  479. }
  480. .nav-wrapper {
  481. width: 678rpx;
  482. // height: 560rpx;
  483. background: #FFFFFF;
  484. box-shadow: 0px 2rpx 24rpx 0rpx rgba(0, 0, 0, 0.06);
  485. border-radius: 20rpx;
  486. margin: 32rpx auto 0;
  487. color: #555555;
  488. .nav-item {
  489. height: 115rpx;
  490. border-bottom: 1rpx #F6F6F6 solid;
  491. &:last-of-type {
  492. border-bottom: none;
  493. }
  494. justify-content: space-between;
  495. align-items: center;
  496. padding: 0 36rpx 0 40rpx;
  497. .item-left {
  498. align-items: center;
  499. image {
  500. // background-color: red;
  501. }
  502. .img1 {
  503. width: 34rpx;
  504. height: 34rpx;
  505. margin-right: 21rpx;
  506. }
  507. .img2 {
  508. width: 36rpx;
  509. height: 32rpx;
  510. margin-right: 19rpx;
  511. }
  512. .img3 {
  513. width: 28rpx;
  514. height: 36rpx;
  515. margin-right: 25rpx;
  516. }
  517. .img4 {
  518. width: 36rpx;
  519. height: 28rpx;
  520. margin-right: 19rpx;
  521. }
  522. .title {
  523. font-size: 32rpx;
  524. font-family: PingFang SC;
  525. font-weight: 500;
  526. color: #555555;
  527. }
  528. }
  529. .item-right {
  530. line-height: 115rpx;
  531. }
  532. }
  533. }
  534. .sy-box {
  535. position: absolute;
  536. bottom: 80rpx;
  537. // bottom: 105rpx;
  538. // height: 148rpx;
  539. width: 750rpx;
  540. // background-color: #bfa;
  541. .sy-item {
  542. flex-grow: 1;
  543. text-align: center;
  544. font-size: 28rpx;
  545. font-family: PingFang SC;
  546. font-weight: 500;
  547. color: #FFFFFF;
  548. .sy-item-val {
  549. font-size: 50rpx;
  550. font-weight: bold;
  551. }
  552. }
  553. }
  554. .btm-box {
  555. align-items: center;
  556. width: 706rpx;
  557. height: 104rpx;
  558. background: #ffffff;
  559. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  560. border-radius: 28rpx;
  561. margin: 20rpx auto;
  562. position: relative;
  563. padding: 0 33rpx 0 24rpx;
  564. font-size: 29rpx;
  565. font-weight: bold;
  566. color: #5d5d5d;
  567. .left-img {
  568. width: 40rpx;
  569. }
  570. .right-img {
  571. width: 14rpx;
  572. }
  573. view {
  574. flex-grow: 1;
  575. padding-left: 12rpx;
  576. }
  577. }
  578. .loginout {
  579. width: 560rpx;
  580. line-height: 80rpx;
  581. border: 1rpx solid #fa7e67;
  582. border-radius: 40rpx;
  583. text-align: center;
  584. margin: 60rpx auto 0;
  585. font-size: 30rpx;
  586. font-weight: 500;
  587. color: #fa7e67;
  588. background-color: #fff;
  589. }
  590. </style>