index.vue 6.8 KB

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