index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="subject">
  3. <view style="width: 100%; position: relative" class="subject-top">
  4. <view class="personal" v-if="isLogin">
  5. <view class="personal_left">
  6. <image :src="userinfos.image" mode="" @error="error"></image>
  7. </view>
  8. <view class="personal_center">
  9. <p>
  10. {{ usernames }}
  11. <view @click="userinfo" class="userinfo">
  12. <u-icon name="edit-pen" class="edit-pen"></u-icon>
  13. </view>
  14. </p>
  15. <p>{{ userinfos.email || userinfos.mobile || '' }}</p>
  16. </view>
  17. <!-- <view class="personal_right" @click="userinfo">
  18. <uni-icons
  19. type="compose"
  20. style="margin-right: 10rpx"
  21. color="#FFFFFF"
  22. ></uni-icons>
  23. 编辑
  24. </view> -->
  25. </view>
  26. </view>
  27. <view class="menu">
  28. <view>
  29. <view class="AboutUs" @click="about">
  30. <image :src="personIcon" mode="" class="icon_left"></image>
  31. 关于我们
  32. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  33. </view>
  34. </view>
  35. <view style="background-color: #ffffff" v-if="isLogin">
  36. <view class="quit" @click="outto">
  37. <image :src="logoutIcon" mode="" class="icon_left"></image>
  38. 退出登录
  39. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  40. </view>
  41. </view>
  42. <view style="background-color: #ffffff" v-else>
  43. <view class="quit" @click="handleLogin">
  44. <image :src="logoutIcon" mode="" class="icon_left"></image>
  45. 去登录
  46. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import personIcon from '../../assets/personIcon.png';
  54. import logoutIcon from '../../assets/logout.png';
  55. export default {
  56. data() {
  57. return {
  58. personIcon,
  59. logoutIcon,
  60. usernames: '',
  61. userinfos: {},
  62. isLogin: false,
  63. };
  64. },
  65. methods: {
  66. //user.login.user_login_info
  67. //home.homes.personal_center
  68. async getUserlogin() {
  69. const session_key = uni.getStorageSync('session_key');
  70. this.isLogin = !!session_key;
  71. if (!this.isLogin) {
  72. return;
  73. }
  74. const res = await this.$myRequest({
  75. url: '/api/api_gateway?method=user.login.user_login_info',
  76. method: 'POST',
  77. });
  78. console.log(res.children);
  79. this.usernames = res.username;
  80. this.getUsermsg(this.usernames);
  81. uni.setStorage({
  82. key: 'jurisdiction',
  83. data: JSON.stringify(res.children),
  84. });
  85. },
  86. async getuserinfonew() {
  87. const res = await this.$myRequest({
  88. url: '/api/v2/theme/home/info/',
  89. });
  90. if (res.items && res.items.logo_url) {
  91. this.userinfos.image = res.items.logo_url;
  92. } else {
  93. this.userinfos.image = '';
  94. }
  95. },
  96. async getUsermsg(user) {
  97. const res = await this.$myRequest({
  98. url: '/api/api_gateway?method=home.homes.personal_center',
  99. data: {
  100. username: user,
  101. },
  102. });
  103. console.log(res);
  104. res.image = '';
  105. this.userinfos = res;
  106. this.getuserinfonew();
  107. }, //user.login.logout_user
  108. async getlogout() {
  109. const res = await this.$myRequest({
  110. url: '/api/api_gateway?method=user.login.logout_user',
  111. });
  112. },
  113. handleLogin() {
  114. console.log('---------------------- login');
  115. uni.navigateTo({
  116. url: '/pages/login/login',
  117. });
  118. },
  119. about() {
  120. uni.navigateTo({
  121. url: '../about/about',
  122. });
  123. },
  124. error(e) {
  125. this.userinfos.image =
  126. '../../../static/images/my/f856c0422304bdd24a008f4d75b76e3.png';
  127. },
  128. // feedback(){
  129. // uni.navigateTo({
  130. // url:"../feedback/feedback"
  131. // })
  132. // },
  133. userinfo() {
  134. uni.navigateTo({
  135. url: '../user-info/user-info?data=' + JSON.stringify(this.userinfos),
  136. });
  137. },
  138. outto() {
  139. uni.showModal({
  140. title: '提示',
  141. content: '是否退出登录',
  142. success: (res) => {
  143. if (res.confirm) {
  144. this.getlogout();
  145. // 清除上一个用户的权限缓存与存储,防止残留
  146. this.$resetPermissionList();
  147. uni.removeStorage({
  148. key: 'session_key',
  149. });
  150. uni.reLaunch({
  151. url: '../../login/login',
  152. });
  153. } else if (res.cancel) {
  154. console.log('用户点击取消');
  155. }
  156. },
  157. });
  158. },
  159. },
  160. onLoad() {
  161. this.getUserlogin();
  162. },
  163. onShow() {
  164. this.getUserlogin();
  165. this.$forceUpdate();
  166. },
  167. };
  168. </script>
  169. <style lang="scss">
  170. .subject {
  171. width: 100%;
  172. height: 100vh;
  173. background: #f5f6fa;
  174. .subject-top {
  175. height: 450rpx;
  176. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/personBg.png');
  177. background-size: cover;
  178. }
  179. }
  180. .personal {
  181. width: 90%;
  182. margin: 0 auto;
  183. display: flex;
  184. padding: 20rpx 0 40rpx;
  185. padding-top: 136rpx;
  186. box-sizing: border-box;
  187. position: relative;
  188. .personal_left {
  189. width: 120rpx;
  190. height: 120rpx;
  191. display: flex;
  192. align-items: center;
  193. justify-content: center;
  194. border-radius: 50%;
  195. margin-right: 30rpx;
  196. border: 4rpx solid #ffffff;
  197. image {
  198. width: 120rpx;
  199. height: 120rpx;
  200. border-radius: 60rpx;
  201. }
  202. }
  203. .personal_center {
  204. padding-top: 20rpx;
  205. color: #ffffff;
  206. p:nth-child(1) {
  207. width: 100%;
  208. font-size: 34rpx;
  209. font-weight: 700;
  210. margin-bottom: 10rpx;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. }
  215. .userinfo {
  216. width: 40rpx;
  217. height: 40rpx;
  218. border-radius: 16rpx;
  219. color: #ffffff;
  220. font-size: 24rpx;
  221. background: #00000014;
  222. margin-left: 16rpx;
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. .edit-pen {
  227. font-size: 20rpx;
  228. }
  229. }
  230. p:nth-child(2) {
  231. font-size: 24rpx;
  232. }
  233. }
  234. .personal_right {
  235. width: 150rpx;
  236. background-color: #55c87b;
  237. height: 60rpx;
  238. text-align: center;
  239. border-radius: 30rpx;
  240. line-height: 60rpx;
  241. color: #ffffff;
  242. position: absolute;
  243. right: 30rpx;
  244. }
  245. }
  246. .menu {
  247. margin: 0 32rpx;
  248. background: #ffffff;
  249. border-radius: 16rpx;
  250. overflow: hidden;
  251. position: relative;
  252. top: -140rpx;
  253. }
  254. .AboutUs,
  255. .quit,
  256. .opinion {
  257. display: flex;
  258. align-items: center;
  259. width: 90%;
  260. height: 100rpx;
  261. line-height: 100rpx;
  262. margin: 0rpx auto;
  263. position: relative;
  264. padding-left: 20rpx;
  265. font-size: 28rpx;
  266. .icon_left {
  267. margin-right: 20rpx;
  268. color: #55c87b !important;
  269. width: 40rpx;
  270. height: 40rpx;
  271. }
  272. .icon_right {
  273. position: absolute;
  274. top: 0;
  275. right: 10rpx;
  276. font-size: 32rpx !important;
  277. }
  278. }
  279. .opinion {
  280. margin: 0 auto;
  281. border-top: 2rpx solid #eaeaea;
  282. }
  283. </style>