index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. uni.removeStorage({
  166. key: "session_key"
  167. })
  168. uni.reLaunch({
  169. url: "../../login/login"
  170. })
  171. } else if (res.cancel) {
  172. console.log('用户点击取消');
  173. }
  174. }
  175. });
  176. }
  177. },
  178. onLoad() {
  179. this.getUserlogin()
  180. this.getEquipList()
  181. },
  182. onShow() {
  183. this.getUserlogin()
  184. this.$forceUpdate()
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .subject {
  190. width: 100%;
  191. height: 100vh;
  192. background: #F5F6FA;
  193. .subject-top{
  194. height: 450rpx;
  195. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/personBg.png');
  196. background-size: cover;
  197. }
  198. }
  199. .personal {
  200. width: 90%;
  201. margin: 0 auto;
  202. display: flex;
  203. padding: 20rpx 0 40rpx;
  204. padding-top: 136rpx;
  205. box-sizing: border-box;
  206. position: relative;
  207. .personal_left {
  208. width: 120rpx;
  209. height: 120rpx;
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. border-radius: 50%;
  214. margin-right: 30rpx;
  215. border: 4rpx solid #ffffff;
  216. image {
  217. width: 120rpx;
  218. height: 120rpx;
  219. border-radius: 60rpx;
  220. }
  221. }
  222. .personal_center {
  223. padding-top: 20rpx;
  224. color:#ffffff;
  225. p:nth-child(1) {
  226. width: 100%;
  227. font-size: 34rpx;
  228. font-weight: 700;
  229. margin-bottom: 10rpx;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. }
  234. .userinfo{
  235. width: 40rpx;
  236. height: 40rpx;
  237. border-radius: 16rpx;
  238. color:#ffffff;
  239. font-size: 24rpx;
  240. background: #00000014;
  241. margin-left: 16rpx;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. .edit-pen{
  246. font-size: 20rpx;
  247. }
  248. }
  249. p:nth-child(2) {
  250. font-size: 24rpx;
  251. }
  252. }
  253. .personal_right {
  254. width: 150rpx;
  255. background-color: #55c87b;
  256. height: 60rpx;
  257. text-align: center;
  258. border-radius: 30rpx;
  259. line-height: 60rpx;
  260. color: #ffffff;
  261. position: absolute;
  262. right: 30rpx;
  263. }
  264. }
  265. .menu{
  266. margin: 0 32rpx;
  267. background: #ffffff;
  268. border-radius: 16rpx;
  269. overflow: hidden;
  270. position: relative;
  271. top: -140rpx;
  272. }
  273. .AboutUs,
  274. .quit,
  275. .opinion {
  276. display:flex;
  277. align-items: center;
  278. width: 90%;
  279. height: 100rpx;
  280. line-height: 100rpx;
  281. margin: 0rpx auto;
  282. position: relative;
  283. padding-left: 20rpx;
  284. font-size: 28rpx;
  285. .icon_left {
  286. margin-right: 20rpx;
  287. color: #55c87b !important;
  288. width: 40rpx;
  289. height: 40rpx;
  290. }
  291. .icon_right {
  292. position: absolute;
  293. top: 0;
  294. right: 10rpx;
  295. font-size: 32rpx !important;
  296. }
  297. }
  298. .opinion {
  299. margin: 0 auto;
  300. border-top: 2rpx solid #eaeaea;
  301. }
  302. </style>