user.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="container">
  3. <view class="content-box" @click="navTo('/pages/rescuers/rescuers')">
  4. <view class="user-section"><image :src="userInfo.avatar || '/static/error/missing-face.png'"></image></view>
  5. </view>
  6. <view class="cover-container" @click="navTo('/pages/rescuers/rescuers')">
  7. <view class="nickname">{{userInfo.nickname || '未登录'}}</view>
  8. <view class="login1" v-if="userInfo.helper == 1"><text>救援者{{userInfo.id}}</text></view>
  9. <view class="mobile" v-if="userInfo.mobile">{{userInfo.mobile }}</view>
  10. <view class="login" v-if="hasLogin == false" @click="navTo('/pages/public/wxLogin')"><text>点击登录系统</text></view>
  11. </view>
  12. <view class="item-box">
  13. <!-- <view class="flex item-list" @click="navTo('/pages/record/help')">
  14. <view class="flex_item list-icon">
  15. <view class="icon"><image src="/static/img/img004.png"></image></view>
  16. <view class="text">求救记录</view>
  17. </view>
  18. <view class="icon"><text class="iconfont iconenter"></text></view>
  19. </view> -->
  20. <view class="flex item-list" @click="navTo('/pages/rescuers/rescuers')">
  21. <view class="flex_item list-icon">
  22. <view class="icon"><image src="/static/tabBar/tab-cate-current.png"></image></view>
  23. <view class="text">救援者注册</view>
  24. </view>
  25. <view class="icon"><text class="iconfont iconenter"></text></view>
  26. </view>
  27. <view class="flex item-list" @click="navTo('/pages/address/address')">
  28. <view class="flex_item list-icon">
  29. <view class="icon"><image src="/static/img/address.png"></image></view>
  30. <view class="text">常用地址</view>
  31. </view>
  32. <view class="icon"><text class="iconfont iconenter"></text></view>
  33. </view>
  34. <view class="flex item-list" @click="navTo('/pages/user/about')">
  35. <view class="flex_item list-icon">
  36. <view class="icon"><image src="/static/img/img006.png"></image></view>
  37. <view class="text">功能介绍</view>
  38. </view>
  39. <view class="icon"><text class="iconfont iconenter"></text></view>
  40. </view>
  41. <!-- <view v-if="hasLogin == true" class="list-cell log-out-btn" @click="toLogout">
  42. <text class="cell-tit">退出登录</text>
  43. </view> -->
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { mapState, mapMutations } from 'vuex';
  49. import uniList from '@/components/uni-list/uni-list.vue';
  50. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  51. import { getUserInfo } from '@/api/login.js';
  52. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  53. import { logout } from '@/api/set.js';
  54. let startY = 0,
  55. moveY = 0,
  56. pageAtTop = true;
  57. export default {
  58. components: {
  59. uniList,
  60. uniListItem
  61. },
  62. data() {
  63. return {
  64. };
  65. },
  66. onShow() {
  67. console.log(this.hasLogin)
  68. // 判断是否已经登录
  69. if (this.hasLogin) {
  70. this.loadBaseData();
  71. }else{
  72. this.logout()
  73. }
  74. },
  75. computed: {
  76. ...mapState(['hasLogin','userInfo'])
  77. },
  78. methods: {
  79. ...mapMutations(['setUserInfo','logout']),
  80. // 加载初始数据
  81. loadBaseData() {
  82. let obj = this;
  83. getUserInfo({}).then(({ data }) => {
  84. obj.setUserInfo(data.user);
  85. console.log(data.user,'dddd')
  86. }).catch((e) => {
  87. obj.logout()
  88. });
  89. },
  90. //退出登录
  91. toLogout(){
  92. uni.showModal({
  93. content: '确定要退出登录么',
  94. success: (e)=>{
  95. if(e.confirm){
  96. this.out();
  97. }
  98. }
  99. });
  100. },
  101. // 退出请求
  102. out(){
  103. logout({}).then((e) => {
  104. this.logout()
  105. this.$api.msg(e.msg);
  106. }).catch((e) => {
  107. })
  108. },
  109. /**
  110. * 统一跳转接口,拦截未登录路由
  111. * navigator标签现在默认没有转场动画,所以用view
  112. */
  113. navTo(url) {
  114. if (!this.hasLogin) {
  115. // 保存地址
  116. saveUrl();
  117. // 登录拦截
  118. interceptor();
  119. } else {
  120. uni.navigateTo({
  121. url
  122. });
  123. }
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. page {
  130. height: 100%;
  131. background-color: #FFFFFF;
  132. .container {
  133. height: 100%;
  134. }
  135. }
  136. .content-box {
  137. background-color: #FF4F4F;
  138. height: 220rpx;
  139. width: 100%;
  140. .user-section{
  141. width: 200rpx;
  142. height: 200rpx;
  143. margin: 0rpx auto;
  144. position: relative;
  145. image{
  146. border: 8rpx solid #FFFFFF;
  147. position: absolute;
  148. transform: translate(0%, 50%);
  149. width: 200rpx;
  150. height: 200rpx;
  151. border-radius: 100rpx;
  152. }
  153. }
  154. }
  155. .list-cell{
  156. display:flex;
  157. align-items:baseline;
  158. padding: 20rpx $page-row-spacing;
  159. line-height:60rpx;
  160. position:relative;
  161. background: #fff;
  162. justify-content: center;
  163. box-shadow: 5rpx 5rpx 10rpx rgba(0, 0, 0, 0.2);
  164. &.log-out-btn{
  165. margin-top: 100rpx;
  166. .cell-tit{
  167. color: $uni-color-primary;
  168. text-align: center;
  169. margin-right: 0;
  170. }
  171. }
  172. .cell-tit{
  173. flex: 1;
  174. font-size: $font-base + 2rpx;
  175. color: $font-color-dark;
  176. margin-right:10rpx;
  177. }
  178. .cell-tip{
  179. font-size: $font-base;
  180. color: $font-color-light;
  181. }
  182. switch{
  183. transform: translateX(16rpx) scale(.84);
  184. }
  185. }
  186. .cover-container{
  187. width: 100%;
  188. text-align: center;
  189. padding-top: 120rpx;
  190. .nickname{
  191. font-size: 40rpx;
  192. color: #323232;
  193. }
  194. .mobile{
  195. color: #888888;
  196. font-size: 30rpx;
  197. padding-top: 25rpx;
  198. }
  199. .login{
  200. text-align: center;
  201. width: 100%;
  202. padding-top: 25rpx;
  203. text{
  204. font-size: 30rpx;
  205. color: #FFFFFF;
  206. border-radius: 50rpx;
  207. padding:10rpx 25rpx;
  208. background-color: #FF4F4F;
  209. }
  210. }
  211. .login1{
  212. width: 100%;
  213. text-align: center;
  214. margin-top: 25rpx;
  215. text{
  216. color: #FF4F4F;
  217. font-size: 30rpx;
  218. padding: 3rpx 25rpx;
  219. border-radius: 50rpx;
  220. border:2rpx solid #FF4F4F;
  221. }
  222. }
  223. }
  224. .item-box{
  225. width: 100%;
  226. padding: 50rpx 55rpx;
  227. .item-list{
  228. width: 100%;
  229. margin-top: 30rpx;
  230. .list-icon{
  231. image{
  232. width: 45rpx;
  233. height: 45rpx;
  234. margin-top: 10rpx;
  235. margin-right: 35rpx;
  236. }
  237. .text{
  238. color: #323232;
  239. font-size: 28rpx;
  240. font-weight:bold;
  241. }
  242. }
  243. }
  244. }
  245. </style>