user.vue 12 KB

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