index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="subject">
  3. <view style="width: 100%; position: relative" class="subject-top">
  4. <view class="personal" v-if="isLogin">
  5. <view class="personal_left">
  6. <image :src="userinfos.image" mode="" @error="error"></image>
  7. </view>
  8. <view class="personal_center">
  9. <p>
  10. {{ usernames }}
  11. <view @click="userinfo" class="userinfo">
  12. <u-icon
  13. name="edit-pen"
  14. class="edit-pen"
  15. ></u-icon>
  16. </view>
  17. </p>
  18. <p>{{ userinfos.email || userinfos.mobile || '' }}</p>
  19. </view>
  20. <!-- <view class="personal_right" @click="userinfo">
  21. <uni-icons
  22. type="compose"
  23. style="margin-right: 10rpx"
  24. color="#FFFFFF"
  25. ></uni-icons>
  26. 编辑
  27. </view> -->
  28. </view>
  29. </view>
  30. <view class="menu">
  31. <view>
  32. <view class="AboutUs" @click="about">
  33. <image :src="personIcon" mode="" class="icon_left"></image>
  34. {{$isneutral?"关于我们":"关于更新"}}
  35. <p class="update" v-if="updateTF">NEW</p>
  36. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  37. </view>
  38. </view>
  39. <view style="background-color: #ffffff" v-if="isLogin">
  40. <view class="quit" @click="outto">
  41. <image :src="logoutIcon" mode="" class="icon_left"></image>
  42. 退出登录
  43. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  44. </view>
  45. </view>
  46. <view style="background-color: #ffffff" v-else>
  47. <view class="quit" @click="handleLogin">
  48. <image :src="logoutIcon" mode="" class="icon_left"></image>
  49. 去登录
  50. <uni-icons type="arrowright" class="icon_right"></uni-icons>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import personIcon from '../../assets/personIcon1.png';
  58. import logoutIcon from '../../assets/logout.png';
  59. export default {
  60. data() {
  61. return {
  62. personIcon,
  63. logoutIcon,
  64. isLogin: false,
  65. usernames: '',
  66. userinfos: {},
  67. versions: "",
  68. updateTF: false
  69. }
  70. },
  71. methods: {
  72. handleLogin() {
  73. console.log('---------------------- login');
  74. uni.navigateTo({
  75. url: '/pages/login/login',
  76. });
  77. },
  78. async getEquipList() {
  79. const res = await this.$myRequest({
  80. url: '/api/api_gateway?method=home.homes.app_version_record',
  81. data: {
  82. ret: "first"
  83. }
  84. })
  85. console.log(res)
  86. // this.appName = res[0].app_name
  87. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  88. var ids = Number(plus.runtime.version.match(/\d+/g).join(""))
  89. if (this.versions > ids) {
  90. this.updateTF = true
  91. } else {
  92. this.updateTF = false
  93. }
  94. },
  95. //user.login.user_login_info
  96. //home.homes.personal_center
  97. async getUserlogin() {
  98. const session_key = uni.getStorageSync('session_key');
  99. this.isLogin = !!session_key;
  100. console.log(this.isLogin);
  101. if (!this.isLogin) {
  102. return;
  103. }
  104. const res = await this.$myRequest({
  105. url: '/api/api_gateway?method=user.login.user_login_info',
  106. })
  107. console.log(res.children)
  108. this.usernames = res.username
  109. this.getUsermsg(this.usernames)
  110. uni.setStorage({
  111. key: 'jurisdiction',
  112. data: JSON.stringify(res.children),
  113. success: () => {
  114. }
  115. })
  116. },
  117. async getuserinfonew() {
  118. const res = await this.$myRequest({
  119. url: '/api/v2/theme/home/info/',
  120. })
  121. if(res.items && res.items.logo_url){
  122. this.userinfos.image = res.items.logo_url
  123. } else{
  124. this.userinfos.image = ''
  125. }
  126. },
  127. async getUsermsg(user) {
  128. const res = await this.$myRequest({
  129. url: '/api/api_gateway?method=home.homes.personal_center',
  130. data: {
  131. username: user
  132. }
  133. })
  134. res.image = '';
  135. this.userinfos = res
  136. this.getuserinfonew()
  137. }, //user.login.logout_user
  138. async getlogout() {
  139. const res = await this.$myRequest({
  140. url: '/api/api_gateway?method=user.login.logout_user',
  141. })
  142. },
  143. about() {
  144. uni.navigateTo({
  145. url: "../about/about"
  146. })
  147. },
  148. imageError(e) {
  149. if (e) {
  150. this.userinfos.image = "../../../static/images/my/user.png"
  151. }
  152. },
  153. userinfo() {
  154. uni.navigateTo({
  155. url: "../user-info/user-info?data=" + JSON.stringify(this.userinfos)
  156. })
  157. },
  158. outto() {
  159. uni.showModal({
  160. title: '提示',
  161. content: '是否退出登录',
  162. success: (res) => {
  163. if (res.confirm) {
  164. this.getlogout()
  165. // 清除上一个用户的权限缓存与存储,防止残留
  166. this.$resetPermissionList()
  167. uni.removeStorage({
  168. key: "session_key"
  169. })
  170. uni.reLaunch({
  171. url: "../../login/login"
  172. })
  173. } else if (res.cancel) {
  174. console.log('用户点击取消');
  175. }
  176. }
  177. });
  178. }
  179. },
  180. onLoad() {
  181. this.getUserlogin()
  182. this.getEquipList()
  183. },
  184. onShow() {
  185. this.getUserlogin()
  186. this.$forceUpdate()
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. .subject {
  192. width: 100%;
  193. height: 100vh;
  194. background: #F5F6FA;
  195. .subject-top{
  196. height: 450rpx;
  197. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/personBg.png');
  198. background-size: cover;
  199. }
  200. }
  201. .personal {
  202. width: 90%;
  203. margin: 0 auto;
  204. display: flex;
  205. padding: 20rpx 0 40rpx;
  206. padding-top: 136rpx;
  207. box-sizing: border-box;
  208. position: relative;
  209. .personal_left {
  210. width: 120rpx;
  211. height: 120rpx;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. border-radius: 50%;
  216. margin-right: 30rpx;
  217. border: 4rpx solid #ffffff;
  218. image {
  219. width: 120rpx;
  220. height: 120rpx;
  221. border-radius: 60rpx;
  222. }
  223. }
  224. .personal_center {
  225. padding-top: 20rpx;
  226. color:#ffffff;
  227. p:nth-child(1) {
  228. width: 100%;
  229. font-size: 34rpx;
  230. font-weight: 700;
  231. margin-bottom: 10rpx;
  232. display: flex;
  233. align-items: center;
  234. justify-content: center;
  235. }
  236. .userinfo{
  237. width: 40rpx;
  238. height: 40rpx;
  239. border-radius: 16rpx;
  240. color:#ffffff;
  241. font-size: 24rpx;
  242. background: #00000014;
  243. margin-left: 16rpx;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. .edit-pen{
  248. font-size: 20rpx;
  249. }
  250. }
  251. p:nth-child(2) {
  252. font-size: 24rpx;
  253. }
  254. }
  255. .personal_right {
  256. width: 150rpx;
  257. background-color: #55c87b;
  258. height: 60rpx;
  259. text-align: center;
  260. border-radius: 30rpx;
  261. line-height: 60rpx;
  262. color: #ffffff;
  263. position: absolute;
  264. right: 30rpx;
  265. }
  266. }
  267. .menu{
  268. margin: 0 32rpx;
  269. background: #ffffff;
  270. border-radius: 16rpx;
  271. overflow: hidden;
  272. position: relative;
  273. top: -140rpx;
  274. }
  275. .AboutUs,
  276. .quit,
  277. .opinion {
  278. display:flex;
  279. align-items: center;
  280. width: 90%;
  281. height: 100rpx;
  282. line-height: 100rpx;
  283. margin: 0rpx auto;
  284. position: relative;
  285. padding-left: 20rpx;
  286. font-size: 28rpx;
  287. .icon_left {
  288. margin-right: 20rpx;
  289. color: #55c87b !important;
  290. width: 40rpx;
  291. height: 40rpx;
  292. }
  293. .icon_right {
  294. position: absolute;
  295. top: 0;
  296. right: 10rpx;
  297. font-size: 32rpx !important;
  298. }
  299. }
  300. .opinion {
  301. margin: 0 auto;
  302. border-top: 2rpx solid #eaeaea;
  303. }
  304. </style>