index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <view class="subject">
  4. <view style="width: 100%; background-color: #ffffff; position: relative">
  5. <view class="personal" v-if="isLogin">
  6. <view class="personal_left">
  7. <image :src="userinfos.image" mode="" @error="error"></image>
  8. </view>
  9. <view class="personal_center">
  10. <p>{{ usernames }}</p>
  11. <p>{{ userinfos.email || userinfos.mobile }}</p>
  12. </view>
  13. <view class="personal_right" @click="userinfo">
  14. <uni-icons
  15. type="compose"
  16. style="margin-right: 10rpx"
  17. color="#FFFFFF"
  18. ></uni-icons>
  19. 编辑
  20. </view>
  21. </view>
  22. </view>
  23. <view style="background-color: #ffffff; margin: 20rpx auto 0">
  24. <view class="AboutUs" @click="about">
  25. <u-icon
  26. name="pingtai"
  27. custom-prefix="custom-icon"
  28. class="icon_left"
  29. ></u-icon>
  30. 关于我们
  31. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  32. </view>
  33. </view>
  34. <view style="background-color: #ffffff" v-if="isLogin">
  35. <view class="quit" @click="outto">
  36. <u-icon
  37. name="tuichudenglu"
  38. custom-prefix="custom-icon"
  39. class="icon_left"
  40. ></u-icon>
  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. export default {
  61. data() {
  62. return {
  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. this.userinfos = res;
  108. this.getuserinfonew();
  109. }, //user.login.logout_user
  110. async getlogout() {
  111. const res = await this.$myRequest({
  112. url: '/api/api_gateway?method=user.login.logout_user',
  113. });
  114. },
  115. handleLogin() {
  116. console.log('---------------------- login');
  117. uni.navigateTo({
  118. url: '/pages/login/login',
  119. });
  120. },
  121. about() {
  122. uni.navigateTo({
  123. url: '../about/about',
  124. });
  125. },
  126. error(e) {
  127. this.userinfos.image =
  128. '../../../static/images/my/f856c0422304bdd24a008f4d75b76e3.png';
  129. },
  130. // feedback(){
  131. // uni.navigateTo({
  132. // url:"../feedback/feedback"
  133. // })
  134. // },
  135. userinfo() {
  136. uni.navigateTo({
  137. url: '../user-info/user-info?data=' + JSON.stringify(this.userinfos),
  138. });
  139. },
  140. outto() {
  141. uni.showModal({
  142. title: '提示',
  143. content: '是否退出登录',
  144. success: (res) => {
  145. if (res.confirm) {
  146. this.getlogout();
  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-color: #f9f9f9;
  174. }
  175. .personal {
  176. width: 90%;
  177. margin: 0 auto;
  178. display: flex;
  179. padding: 20rpx 0 40rpx;
  180. box-sizing: border-box;
  181. .personal_left {
  182. width: 18%;
  183. margin-right: 30rpx;
  184. image {
  185. width: 124rpx;
  186. height: 120rpx;
  187. border-radius: 60rpx;
  188. }
  189. }
  190. .personal_center {
  191. padding-top: 20rpx;
  192. p:nth-child(1) {
  193. font-size: 34rpx;
  194. font-weight: 700;
  195. margin-bottom: 10rpx;
  196. }
  197. p:nth-child(2) {
  198. font-size: 24rpx;
  199. }
  200. }
  201. .personal_right {
  202. width: 150rpx;
  203. background-color: #55c87b;
  204. height: 60rpx;
  205. text-align: center;
  206. border-radius: 30rpx;
  207. line-height: 60rpx;
  208. color: #ffffff;
  209. position: absolute;
  210. top: 50rpx;
  211. right: 30rpx;
  212. }
  213. }
  214. .AboutUs,
  215. .quit,
  216. .opinion {
  217. width: 90%;
  218. height: 100rpx;
  219. line-height: 100rpx;
  220. margin: 20rpx auto 0;
  221. position: relative;
  222. padding-left: 20rpx;
  223. font-size: 28rpx;
  224. .icon_left {
  225. margin-right: 20rpx;
  226. color: #55c87b !important;
  227. font-size: 32rpx;
  228. }
  229. .icon_right {
  230. position: absolute;
  231. top: 0;
  232. right: 10rpx;
  233. font-size: 32rpx !important;
  234. }
  235. }
  236. .opinion {
  237. margin: 0 auto;
  238. border-top: 2rpx solid #eaeaea;
  239. }
  240. </style>