user.vue 11 KB

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