index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. res.image = '';
  123. this.userinfos = res
  124. this.getuserinfonew()
  125. }, //user.login.logout_user
  126. async getlogout() {
  127. const res = await this.$myRequest({
  128. url: '/api/api_gateway?method=user.login.logout_user',
  129. })
  130. },
  131. about() {
  132. uni.navigateTo({
  133. url: "../about/about"
  134. })
  135. },
  136. imageError(e) {
  137. if (e) {
  138. this.userinfos.image = "../../../static/images/my/user.png"
  139. }
  140. },
  141. userinfo() {
  142. uni.navigateTo({
  143. url: "../user-info/user-info?data=" + JSON.stringify(this.userinfos)
  144. })
  145. },
  146. outto() {
  147. uni.showModal({
  148. title: '提示',
  149. content: '是否退出登录',
  150. success: (res) => {
  151. if (res.confirm) {
  152. this.getlogout()
  153. uni.removeStorage({
  154. key: "session_key"
  155. })
  156. uni.reLaunch({
  157. url: "../../login/login"
  158. })
  159. } else if (res.cancel) {
  160. console.log('用户点击取消');
  161. }
  162. }
  163. });
  164. }
  165. },
  166. onLoad() {
  167. this.getUserlogin()
  168. this.getEquipList()
  169. },
  170. onShow() {
  171. this.getUserlogin()
  172. this.$forceUpdate()
  173. }
  174. }
  175. </script>
  176. <style lang="scss">
  177. .subject {
  178. width: 100%;
  179. height: 100vh;
  180. background-color: #F9F9F9;
  181. }
  182. .personal {
  183. width: 90%;
  184. margin: 0 auto;
  185. display: flex;
  186. padding: 20rpx 0 40rpx;
  187. box-sizing: border-box;
  188. .personal_left {
  189. width: 18%;
  190. margin-right: 30rpx;
  191. image {
  192. width: 124rpx;
  193. height: 120rpx;
  194. border-radius: 60rpx;
  195. }
  196. }
  197. .personal_center {
  198. padding-top: 20rpx;
  199. p:nth-child(1) {
  200. font-size: 34rpx;
  201. font-weight: 700;
  202. margin-bottom: 10rpx;
  203. }
  204. p:nth-child(2) {
  205. font-size: 24rpx;
  206. }
  207. }
  208. .personal_right {
  209. width: 150rpx;
  210. background-color: #55C87B;
  211. height: 60rpx;
  212. text-align: center;
  213. border-radius: 30rpx;
  214. line-height: 60rpx;
  215. color: #FFFFFF;
  216. position: absolute;
  217. top: 50rpx;
  218. right: 30rpx;
  219. }
  220. }
  221. .AboutUs,
  222. .quit,
  223. .opinion {
  224. width: 90%;
  225. height: 100rpx;
  226. line-height: 100rpx;
  227. margin: 20rpx auto 0;
  228. position: relative;
  229. padding-left: 20rpx;
  230. font-size: 28rpx;
  231. .icon_left {
  232. margin-right: 20rpx;
  233. color: #55C87B !important;
  234. font-size: 32rpx;
  235. }
  236. .icon_right {
  237. position: absolute;
  238. top: 0;
  239. right: 10rpx;
  240. font-size: 32rpx !important;
  241. }
  242. .update {
  243. position: absolute;
  244. top: 34rpx;
  245. right: 40rpx;
  246. font-size: 16rpx !important;
  247. background-color: #f00;
  248. border-radius: 25rpx;
  249. height: 30rpx;
  250. padding: 2rpx 16rpx;
  251. line-height: 30rpx;
  252. color: #fff;
  253. }
  254. }
  255. .opinion {
  256. margin: 0 auto;
  257. border-top: 2rpx solid #EAEAEA;
  258. }
  259. </style>