index.vue 6.7 KB

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