my.nvue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="m-page">
  3. <image class="banner" src="../../static/mybg.png" mode="" ></image>
  4. <view class="m-head">
  5. <image class="img1" :src="users.icon || '/static/user.png'" @error="errorImg" @click="chooseImg" mode="aspectFit"></image>
  6. <view class="h-view" v-if="Token">
  7. <text class="h-t1">{{users.account}}</text>
  8. <!-- <text class="h-t2">{{users | sex}}</text> -->
  9. <text class="h-t2 icon" @click="changeName">昵称:{{users.name}}&#xe6ae;</text>
  10. <text class="h-t3">上次登录时间:{{users.loginTime}}</text>
  11. </view>
  12. <view class="h-view" v-if="!Token">
  13. <text class="h-t1">暂未登录</text>
  14. </view>
  15. </view>
  16. <view class="m-list" @click="changePhone">
  17. <text class="icon m-1">&#xe60b;</text>
  18. <text class="m-t">手机号</text>
  19. <text class="m-r icon">{{users.mobile}}&#xe65f;</text>
  20. </view>
  21. <view class="m-list" @click="changeEmail">
  22. <text class="icon m-2">&#xe605;</text>
  23. <text class="m-t">邮箱</text>
  24. <text class="m-r icon">{{users.email}}&#xe65f;</text>
  25. </view>
  26. <view class="m-list" @click="changePass">
  27. <text class="icon m-3">&#xe626;</text>
  28. <text class="m-t ">密码安全</text>
  29. <text class="m-r icon">&#xe65f;</text>
  30. </view>
  31. <view class="m-list">
  32. <text class="icon m-4">&#xe602;</text>
  33. <text class="m-t">接受新消息通知 </text>
  34. <switch class="m-r" color="#3EAB3E" style="transform:scale(0.8);margin-left: 280rpx;" :checked="newCheck" @change="switchChange" />
  35. </view>
  36. <view class="m-list m-center" @click="infoSet">
  37. <text class="icon m-5">&#xe621;</text>
  38. <text class="m-t">消息设置</text>
  39. <text class="m-r icon">&#xe65f;</text>
  40. </view>
  41. <view class="m-list" @click="APPUpdate(true)">
  42. <text class="icon m-6">&#xe613;</text>
  43. <text class="m-t">关于系统</text>
  44. <text class="m-r">{{version}}</text>
  45. </view>
  46. <view class="m-list" @click="goFeedback">
  47. <text class="icon m-7">&#xe659;</text>
  48. <text class="m-t">帮助与反馈</text>
  49. <text class="m-r icon">&#xe65f;</text>
  50. </view>
  51. <view class=" m-b" @click="remove">
  52. <text class="m-t">退出登录</text>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. var domModule = weex.requireModule('dom');
  58. domModule.addRule('fontFace', {
  59. 'fontFamily': "iconfont",
  60. 'src': "url('/static/iconfont.ttf')"
  61. })
  62. import APPUpdate from '@/uni_modules/APPUpdate/js_sdk/appUpdate';
  63. import {
  64. BeforeNavigateTo
  65. } from '../../common/utils.js'
  66. import {
  67. getUser,
  68. updateIcon,
  69. exit,
  70. updateMsgStatus
  71. } from '@/common/api.js'
  72. import permision from "@/js_sdk/wa-permission/permission.js"
  73. import {
  74. mapGetters
  75. } from 'vuex'
  76. import {api_config} from '@/config.js'
  77. export default {
  78. onLoad() {
  79. //#ifdef APP-PLUS
  80. plus.runtime.getProperty(plus.runtime.appid, (inf) => {
  81. let str;
  82. api_config == 'http://192.168.20.132:8081' ? str = ':Test' : str = ''
  83. this.version = inf.version+str
  84. });
  85. //#endif
  86. if (this.Token) {
  87. this.getUser()
  88. }
  89. uni.$on("changeUser",() =>{
  90. this.getUser()
  91. })
  92. },
  93. filters: {
  94. orgNameList(val) {
  95. if (!val) return
  96. let str = ''
  97. val.map(item => {
  98. str += item + '-'
  99. })
  100. return str
  101. },
  102. sex(val){
  103. return val == 1 ? '男' :'女'
  104. }
  105. },
  106. computed: {
  107. ...mapGetters([
  108. 'Token'
  109. ]),
  110. },
  111. data() {
  112. return {
  113. users: {
  114. },
  115. version: "",
  116. newCheck:false
  117. }
  118. },
  119. onShow() {
  120. this.newCheck = uni.getStorageSync("getRealNews")==1?true:false;
  121. },
  122. methods: {
  123. infoSet(){
  124. permision.gotoAppPermissionSetting()
  125. },
  126. chooseImg(){
  127. let that =this
  128. uni.chooseImage({
  129. count: 1,
  130. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  131. success: function (res) {
  132. uni.compressImage({
  133. src: res.tempFilePaths[0],
  134. quality: 10,
  135. success: resp => {
  136. plus.io.resolveLocalFileSystemURL(resp.tempFilePath, function(entry){
  137. entry.file( function(file){
  138. let fileReader = new plus.io.FileReader();
  139. fileReader.readAsDataURL( file );
  140. fileReader.onloadend = function(evt) {
  141. updateIcon({
  142. icon:evt.target.result,
  143. userId:that.$store.state.Token
  144. }).then(e =>{
  145. that.users.icon = evt.target.result
  146. })
  147. }
  148. });
  149. })
  150. }
  151. })
  152. }
  153. });
  154. },
  155. getUser(){
  156. getUser({
  157. userId:this.Token
  158. }).then(res => {
  159. this.users = res
  160. }).catch(e => {
  161. plus.nativeUI.toast('获取用户信息失败,请重新登录')
  162. setTimeout(() =>{
  163. exit().then(res => {
  164. this.$store.dispatch('setToken', "")
  165. // uni.clearStorage()
  166. this.$store.dispatch('setUsers', "{}")
  167. uni.reLaunch({
  168. url: '/pages/native/login'
  169. });
  170. }).catch(e => {
  171. plus.nativeUI.toast('服务退出登录失败,正强制退出...')
  172. setTimeout(() =>{
  173. this.$store.dispatch('setToken', "")
  174. this.$store.dispatch('setUsers', "{}")
  175. uni.reLaunch({
  176. url: '/pages/native/login'
  177. });
  178. },1000)
  179. })
  180. },1000)
  181. })
  182. },
  183. changePhone(){
  184. BeforeNavigateTo({
  185. url: '/pages/webview/changePhone',
  186. }, true)
  187. },
  188. changeEmail(){
  189. BeforeNavigateTo({
  190. url: '/pages/webview/changeEmail',
  191. }, true)
  192. },
  193. changeName(){
  194. BeforeNavigateTo({
  195. url: '/pages/webview/changeName',
  196. }, true)
  197. },
  198. switchChange(e){
  199. uni.setStorageSync("getRealNews",e.detail.value?1:0)
  200. updateMsgStatus({
  201. userId: this.$store.state.Token,
  202. status:e.detail.value?1:0
  203. }).then(res => {console.log(res)
  204. }).catch(e => {
  205. console.log(e)
  206. })
  207. },
  208. changePass(){
  209. BeforeNavigateTo({
  210. url: '/pages/webview/changePassword',
  211. }, true)
  212. },
  213. APPUpdate() {
  214. return
  215. APPUpdate(true)
  216. },
  217. errorImg() {
  218. this.users.avatar = "/static/iconM.png"
  219. },
  220. goFeedback() {
  221. BeforeNavigateTo({
  222. url: '/pages/webview/feedback',
  223. }, true)
  224. },
  225. go() {
  226. BeforeNavigateTo({
  227. url: '/pages/hybrid/index',
  228. }, true)
  229. },
  230. remove() {
  231. uni.showActionSheet({
  232. itemList: ['确定退出'],
  233. success: (res) => {
  234. exit().then(res => {
  235. this.$store.dispatch('setToken', "")
  236. // uni.clearStorage()
  237. this.$store.dispatch('setUsers', "{}")
  238. uni.reLaunch({
  239. url: '/pages/native/login'
  240. });
  241. }).catch(e => {
  242. plus.nativeUI.toast('服务退出登录失败,正强制退出...')
  243. setTimeout(() =>{
  244. this.$store.dispatch('setToken', "")
  245. this.$store.dispatch('setUsers', "{}")
  246. uni.reLaunch({
  247. url: '/pages/native/login'
  248. });
  249. },1000)
  250. })
  251. }
  252. });
  253. },
  254. }
  255. }
  256. </script>
  257. <style scoped lang="scss">
  258. .icon {
  259. font-family: iconfont;
  260. font-size: 26px;
  261. }
  262. .m-page {
  263. /*#ifdef MP-WEIXIN*/
  264. height: 100vh;
  265. /*#endif*/
  266. .banner{
  267. width: 750rpx;
  268. height: 332rpx;
  269. }
  270. .m-center{
  271. margin: 20rpx 0 0 0;
  272. }
  273. .m-list {
  274. border-bottom:1px solid #E5E5E5;
  275. background: #fff;
  276. flex-direction: row;
  277. align-items: center;
  278. padding: 30rpx 30rpx;
  279. .butt {
  280. padding: 0;
  281. border: 0px;
  282. margin: 0;
  283. font-size: 32px !important;
  284. }
  285. .m-1,.m-2,.m-3,.m-4,.m-5,.m-6,.m-7{
  286. font-size: 34rpx;
  287. width: 50rpx;
  288. }
  289. .m-1{color: #F34E4E;}
  290. .m-2{color: #3EAB3E;}
  291. .m-3{color: #9127AB;}
  292. .m-4{color: #37A8FF;}
  293. .m-5{color: #E9C70C;}
  294. .m-6{color: #5C83F2;}
  295. .m-7{color: #F66D23;}
  296. .m-t {
  297. color: #666;
  298. font-size: 34rpx;
  299. }
  300. .m-r {
  301. flex: 1;
  302. text-align: right;
  303. color: #999;
  304. justify-content: flex-end;
  305. font-size: 32rpx;
  306. }
  307. }
  308. .m-b {
  309. justify-content: center;
  310. background: #0581FD;
  311. margin:50rpx;
  312. flex-direction: row;
  313. align-items: center;
  314. padding: 20rpx 30rpx;
  315. border-radius: 15rpx;
  316. border: 1px solid #0581FD;
  317. .m-t {
  318. color: #fff;
  319. font-size: 34rpx;
  320. }
  321. }
  322. .m-head {
  323. padding: 20rpx 30rpx;
  324. position: absolute;
  325. top: 0;
  326. height: 332rpx;
  327. margin-bottom: 30rpx;
  328. flex-direction: row;
  329. align-items: center;
  330. .img1 {
  331. width: 150rpx;
  332. height: 150rpx;
  333. border-radius: 100rpx;
  334. margin-right: 30rpx;
  335. }
  336. .h-t1 {
  337. color: #fff;
  338. font-size: 36rpx;
  339. }
  340. .h-t2 {
  341. color: #fff;
  342. padding-top: 15rpx;
  343. font-size: 34rpx;
  344. }
  345. .h-t3{
  346. color: #fff;
  347. padding-top: 15rpx;
  348. font-size: 28rpx;
  349. }
  350. }
  351. }
  352. </style>