user.vue 12 KB

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