index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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="imageError"></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 type="compose" style="color: #FFFFFF;margin-right: 10rpx;"></uni-icons>
  15. 编辑
  16. </view>
  17. </view>
  18. </view>
  19. <view style="background-color: #FFFFFF;margin: 20rpx auto 0;">
  20. <view class="AboutUs" @click="about">
  21. <u-icon name="pingtai" custom-prefix="custom-icon" class="icon_left"></u-icon>
  22. {{$isneutral?"关于我们":"关于更新"}}
  23. <p class="update" v-if="updateTF">NEW</p>
  24. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  25. </view>
  26. </view>
  27. <view style="background-color: #FFFFFF;" v-if="isLogin">
  28. <view class="quit" @click="outto">
  29. <u-icon name="tuichudenglu" custom-prefix="custom-icon" class="icon_left"></u-icon>
  30. 退出登录
  31. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  32. </view>
  33. </view>
  34. <view style="background-color: #ffffff" v-else>
  35. <view class="quit" @click="handleLogin">
  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>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. isLogin: false,
  53. usernames: '',
  54. userinfos: {},
  55. versions: "",
  56. updateTF: false
  57. }
  58. },
  59. methods: {
  60. handleLogin() {
  61. console.log('---------------------- login');
  62. uni.navigateTo({
  63. url: '/pages/login/login',
  64. });
  65. },
  66. async getEquipList() {
  67. const res = await this.$myRequest({
  68. url: '/api/api_gateway?method=home.homes.app_version_record',
  69. data: {
  70. ret: "first"
  71. }
  72. })
  73. console.log(res)
  74. // this.appName = res[0].app_name
  75. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  76. var ids = Number(plus.runtime.version.match(/\d+/g).join(""))
  77. if (this.versions > ids) {
  78. this.updateTF = true
  79. } else {
  80. this.updateTF = false
  81. }
  82. },
  83. //user.login.user_login_info
  84. //home.homes.personal_center
  85. async getUserlogin() {
  86. const session_key = uni.getStorageSync('session_key');
  87. this.isLogin = !!session_key;
  88. console.log(this.isLogin);
  89. if (!this.isLogin) {
  90. return;
  91. }
  92. const res = await this.$myRequest({
  93. url: '/api/api_gateway?method=user.login.user_login_info',
  94. })
  95. console.log(res.children)
  96. this.usernames = res.username
  97. this.getUsermsg(this.usernames)
  98. uni.setStorage({
  99. key: 'jurisdiction',
  100. data: JSON.stringify(res.children),
  101. success: () => {
  102. }
  103. })
  104. },
  105. async getuserinfonew() {
  106. const res = await this.$myRequest({
  107. url: '/api/v2/theme/home/info/',
  108. })
  109. if(res.items && res.items.logo_url){
  110. this.userinfos.image = res.items.logo_url
  111. } else{
  112. this.userinfos.image = ''
  113. }
  114. },
  115. async getUsermsg(user) {
  116. const res = await this.$myRequest({
  117. url: '/api/api_gateway?method=home.homes.personal_center',
  118. data: {
  119. username: user
  120. }
  121. })
  122. this.userinfos = res
  123. this.getuserinfonew()
  124. }, //user.login.logout_user
  125. async getlogout() {
  126. const res = await this.$myRequest({
  127. url: '/api/api_gateway?method=user.login.logout_user',
  128. })
  129. },
  130. about() {
  131. uni.navigateTo({
  132. url: "../about/about"
  133. })
  134. },
  135. imageError(e) {
  136. if (e) {
  137. this.userinfos.image = "../../../static/images/my/user.png"
  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. this.getEquipList()
  168. },
  169. onShow() {
  170. this.getUserlogin()
  171. this.$forceUpdate()
  172. }
  173. }
  174. </script>
  175. <style lang="scss">
  176. .subject {
  177. width: 100%;
  178. height: 100vh;
  179. background-color: #F9F9F9;
  180. }
  181. .personal {
  182. width: 90%;
  183. margin: 0 auto;
  184. display: flex;
  185. padding: 20rpx 0 40rpx;
  186. box-sizing: border-box;
  187. .personal_left {
  188. width: 18%;
  189. margin-right: 30rpx;
  190. image {
  191. width: 124rpx;
  192. height: 120rpx;
  193. border-radius: 60rpx;
  194. }
  195. }
  196. .personal_center {
  197. padding-top: 20rpx;
  198. p:nth-child(1) {
  199. font-size: 34rpx;
  200. font-weight: 700;
  201. margin-bottom: 10rpx;
  202. }
  203. p:nth-child(2) {
  204. font-size: 24rpx;
  205. }
  206. }
  207. .personal_right {
  208. width: 150rpx;
  209. background-color: #55C87B;
  210. height: 60rpx;
  211. text-align: center;
  212. border-radius: 30rpx;
  213. line-height: 60rpx;
  214. color: #FFFFFF;
  215. position: absolute;
  216. top: 50rpx;
  217. right: 30rpx;
  218. }
  219. }
  220. .AboutUs,
  221. .quit,
  222. .opinion {
  223. width: 90%;
  224. height: 100rpx;
  225. line-height: 100rpx;
  226. margin: 20rpx auto 0;
  227. position: relative;
  228. padding-left: 20rpx;
  229. font-size: 28rpx;
  230. .icon_left {
  231. margin-right: 20rpx;
  232. color: #55C87B !important;
  233. font-size: 32rpx;
  234. }
  235. .icon_right {
  236. position: absolute;
  237. top: 0;
  238. right: 10rpx;
  239. font-size: 32rpx !important;
  240. }
  241. .update {
  242. position: absolute;
  243. top: 34rpx;
  244. right: 40rpx;
  245. font-size: 16rpx !important;
  246. background-color: #f00;
  247. border-radius: 25rpx;
  248. height: 30rpx;
  249. padding: 2rpx 16rpx;
  250. line-height: 30rpx;
  251. color: #fff;
  252. }
  253. }
  254. .opinion {
  255. margin: 0 auto;
  256. border-top: 2rpx solid #EAEAEA;
  257. }
  258. </style>