index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. });
  80. console.log(res.children);
  81. this.usernames = res.username;
  82. this.getUsermsg(this.usernames);
  83. uni.setStorage({
  84. key: 'jurisdiction',
  85. data: JSON.stringify(res.children),
  86. });
  87. },
  88. async getuserinfonew() {
  89. const res = await this.$myRequest({
  90. url: '/api/v2/theme/home/info/',
  91. });
  92. if (res.items && res.items.logo_url) {
  93. this.userinfos.image = res.items.logo_url;
  94. } else {
  95. this.userinfos.image = '';
  96. }
  97. },
  98. async getUsermsg(user) {
  99. const res = await this.$myRequest({
  100. url: '/api/api_gateway?method=home.homes.personal_center',
  101. data: {
  102. username: user,
  103. },
  104. });
  105. console.log(res);
  106. this.userinfos = res;
  107. this.getuserinfonew();
  108. }, //user.login.logout_user
  109. async getlogout() {
  110. const res = await this.$myRequest({
  111. url: '/api/api_gateway?method=user.login.logout_user',
  112. });
  113. },
  114. handleLogin() {
  115. console.log('---------------------- login');
  116. uni.navigateTo({
  117. url: '/pages/login/login',
  118. });
  119. },
  120. about() {
  121. uni.navigateTo({
  122. url: '../about/about',
  123. });
  124. },
  125. error(e) {
  126. this.userinfos.image =
  127. '../../../static/images/my/f856c0422304bdd24a008f4d75b76e3.png';
  128. },
  129. // feedback(){
  130. // uni.navigateTo({
  131. // url:"../feedback/feedback"
  132. // })
  133. // },
  134. userinfo() {
  135. uni.navigateTo({
  136. url: '../user-info/user-info?data=' + JSON.stringify(this.userinfos),
  137. });
  138. },
  139. outto() {
  140. uni.showModal({
  141. title: '提示',
  142. content: '是否退出登录',
  143. success: (res) => {
  144. if (res.confirm) {
  145. this.getlogout();
  146. uni.removeStorage({
  147. key: 'session_key',
  148. });
  149. uni.reLaunch({
  150. url: '../../login/login',
  151. });
  152. } else if (res.cancel) {
  153. console.log('用户点击取消');
  154. }
  155. },
  156. });
  157. },
  158. },
  159. onLoad() {
  160. this.getUserlogin();
  161. },
  162. onShow() {
  163. this.getUserlogin();
  164. this.$forceUpdate();
  165. },
  166. };
  167. </script>
  168. <style lang="scss">
  169. .subject {
  170. width: 100%;
  171. height: 100vh;
  172. background-color: #f9f9f9;
  173. }
  174. .personal {
  175. width: 90%;
  176. margin: 0 auto;
  177. display: flex;
  178. padding: 20rpx 0 40rpx;
  179. box-sizing: border-box;
  180. .personal_left {
  181. width: 18%;
  182. margin-right: 30rpx;
  183. image {
  184. width: 124rpx;
  185. height: 120rpx;
  186. border-radius: 60rpx;
  187. }
  188. }
  189. .personal_center {
  190. padding-top: 20rpx;
  191. p:nth-child(1) {
  192. font-size: 34rpx;
  193. font-weight: 700;
  194. margin-bottom: 10rpx;
  195. }
  196. p:nth-child(2) {
  197. font-size: 24rpx;
  198. }
  199. }
  200. .personal_right {
  201. width: 150rpx;
  202. background-color: #55c87b;
  203. height: 60rpx;
  204. text-align: center;
  205. border-radius: 30rpx;
  206. line-height: 60rpx;
  207. color: #ffffff;
  208. position: absolute;
  209. top: 50rpx;
  210. right: 30rpx;
  211. }
  212. }
  213. .AboutUs,
  214. .quit,
  215. .opinion {
  216. width: 90%;
  217. height: 100rpx;
  218. line-height: 100rpx;
  219. margin: 20rpx auto 0;
  220. position: relative;
  221. padding-left: 20rpx;
  222. font-size: 28rpx;
  223. .icon_left {
  224. margin-right: 20rpx;
  225. color: #55c87b !important;
  226. font-size: 32rpx;
  227. }
  228. .icon_right {
  229. position: absolute;
  230. top: 0;
  231. right: 10rpx;
  232. font-size: 32rpx !important;
  233. }
  234. }
  235. .opinion {
  236. margin: 0 auto;
  237. border-top: 2rpx solid #eaeaea;
  238. }
  239. </style>