index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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=""></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. image:''
  56. },
  57. versions: "",
  58. updateTF: false
  59. }
  60. },
  61. methods: {
  62. handleLogin() {
  63. console.log('---------------------- login');
  64. uni.navigateTo({
  65. url: '/pages/login/login',
  66. });
  67. },
  68. async getEquipList() {
  69. const res = await this.$myRequest({
  70. url: '/api/api_gateway?method=home.homes.app_version_record',
  71. data: {
  72. ret: "first"
  73. }
  74. })
  75. console.log(res)
  76. // this.appName = res[0].app_name
  77. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  78. var ids = Number(plus.runtime.version.match(/\d+/g).join(""))
  79. if (this.versions > ids) {
  80. this.updateTF = true
  81. } else {
  82. this.updateTF = false
  83. }
  84. },
  85. //user.login.user_login_info
  86. //home.homes.personal_center
  87. async getUserlogin() {
  88. const session_key = uni.getStorageSync('session_key');
  89. this.isLogin = !!session_key;
  90. console.log(this.isLogin);
  91. if (!this.isLogin) {
  92. return;
  93. }
  94. const res = await this.$myRequest({
  95. url: '/api/api_gateway?method=user.login.user_login_info',
  96. })
  97. console.log(res.children)
  98. this.usernames = res.username
  99. this.getUsermsg(this.usernames)
  100. uni.setStorage({
  101. key: 'jurisdiction',
  102. data: JSON.stringify(res.children),
  103. success: () => {
  104. }
  105. })
  106. },
  107. async getuserinfonew() {
  108. const res = await this.$myRequest({
  109. url: '/api/v2/theme/home/info/',
  110. })
  111. if(res.items && res.items.logo_url){
  112. this.userinfos.image = res.items.logo_url
  113. } else{
  114. this.userinfos.image = ''
  115. }
  116. },
  117. async getUsermsg(user) {
  118. const res = await this.$myRequest({
  119. url: '/api/api_gateway?method=home.homes.personal_center',
  120. data: {
  121. username: user
  122. }
  123. })
  124. this.userinfos = res
  125. this.getuserinfonew()
  126. }, //user.login.logout_user
  127. async getlogout() {
  128. const res = await this.$myRequest({
  129. url: '/api/api_gateway?method=user.login.logout_user',
  130. })
  131. },
  132. about() {
  133. uni.navigateTo({
  134. url: "../about/about"
  135. })
  136. },
  137. imageError(e) {
  138. if (e) {
  139. this.userinfos.image = ""
  140. }
  141. },
  142. userinfo() {
  143. uni.navigateTo({
  144. url: "../user-info/user-info?data=" + JSON.stringify(this.userinfos)
  145. })
  146. },
  147. outto() {
  148. uni.showModal({
  149. title: '提示',
  150. content: '是否退出登录',
  151. success: (res) => {
  152. if (res.confirm) {
  153. this.getlogout()
  154. uni.removeStorage({
  155. key: "session_key"
  156. })
  157. uni.reLaunch({
  158. url: "../../login/login"
  159. })
  160. } else if (res.cancel) {
  161. console.log('用户点击取消');
  162. }
  163. }
  164. });
  165. }
  166. },
  167. onLoad() {
  168. this.getUserlogin()
  169. this.getEquipList()
  170. },
  171. onShow() {
  172. this.getUserlogin()
  173. this.$forceUpdate()
  174. }
  175. }
  176. </script>
  177. <style lang="scss">
  178. .subject {
  179. width: 100%;
  180. height: 100vh;
  181. background-color: #F9F9F9;
  182. }
  183. .personal {
  184. width: 90%;
  185. margin: 0 auto;
  186. display: flex;
  187. padding: 20rpx 0 40rpx;
  188. box-sizing: border-box;
  189. .personal_left {
  190. width: 18%;
  191. margin-right: 30rpx;
  192. image {
  193. width: 124rpx;
  194. height: 120rpx;
  195. border-radius: 60rpx;
  196. }
  197. }
  198. .personal_center {
  199. padding-top: 20rpx;
  200. p:nth-child(1) {
  201. font-size: 34rpx;
  202. font-weight: 700;
  203. margin-bottom: 10rpx;
  204. }
  205. p:nth-child(2) {
  206. font-size: 24rpx;
  207. }
  208. }
  209. .personal_right {
  210. width: 150rpx;
  211. background-color: #55C87B;
  212. height: 60rpx;
  213. text-align: center;
  214. border-radius: 30rpx;
  215. line-height: 60rpx;
  216. color: #FFFFFF;
  217. position: absolute;
  218. top: 50rpx;
  219. right: 30rpx;
  220. }
  221. }
  222. .AboutUs,
  223. .quit,
  224. .opinion {
  225. width: 90%;
  226. height: 100rpx;
  227. line-height: 100rpx;
  228. margin: 20rpx auto 0;
  229. position: relative;
  230. padding-left: 20rpx;
  231. font-size: 28rpx;
  232. .icon_left {
  233. margin-right: 20rpx;
  234. color: #55C87B !important;
  235. font-size: 32rpx;
  236. }
  237. .icon_right {
  238. position: absolute;
  239. top: 0;
  240. right: 10rpx;
  241. font-size: 32rpx !important;
  242. }
  243. .update {
  244. position: absolute;
  245. top: 34rpx;
  246. right: 40rpx;
  247. font-size: 16rpx !important;
  248. background-color: #f00;
  249. border-radius: 25rpx;
  250. height: 30rpx;
  251. padding: 2rpx 16rpx;
  252. line-height: 30rpx;
  253. color: #fff;
  254. }
  255. }
  256. .opinion {
  257. margin: 0 auto;
  258. border-top: 2rpx solid #EAEAEA;
  259. }
  260. </style>