my.nvue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 @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. } from '@/common/api.js'
  71. import permision from "@/js_sdk/wa-permission/permission.js"
  72. import {
  73. mapGetters
  74. } from 'vuex'
  75. import {api_config} from '@/config.js'
  76. export default {
  77. onLoad() {
  78. //#ifdef APP-PLUS
  79. plus.runtime.getProperty(plus.runtime.appid, (inf) => {
  80. let str;
  81. api_config == 'http://192.168.20.132:8081' ? str = ':Test' : str = ''
  82. this.version = inf.version+str
  83. });
  84. //#endif
  85. if (this.Token) {
  86. this.getUser()
  87. }
  88. uni.$on("changeUser",() =>{
  89. this.getUser()
  90. })
  91. },
  92. filters: {
  93. orgNameList(val) {
  94. if (!val) return
  95. let str = ''
  96. val.map(item => {
  97. str += item + '-'
  98. })
  99. return str
  100. },
  101. sex(val){
  102. return val == 1 ? '男' :'女'
  103. }
  104. },
  105. computed: {
  106. ...mapGetters([
  107. 'Token'
  108. ]),
  109. },
  110. data() {
  111. return {
  112. users: {
  113. },
  114. version: ""
  115. }
  116. },
  117. onShow() {
  118. },
  119. methods: {
  120. infoSet(){
  121. permision.gotoAppPermissionSetting()
  122. },
  123. chooseImg(){
  124. let that =this
  125. uni.chooseImage({
  126. count: 1,
  127. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  128. success: function (res) {
  129. uni.compressImage({
  130. src: res.tempFilePaths[0],
  131. quality: 10,
  132. success: resp => {
  133. plus.io.resolveLocalFileSystemURL(resp.tempFilePath, function(entry){
  134. entry.file( function(file){
  135. let fileReader = new plus.io.FileReader();
  136. fileReader.readAsDataURL( file );
  137. fileReader.onloadend = function(evt) {
  138. updateIcon({
  139. icon:evt.target.result,
  140. userId:that.$store.state.Token
  141. }).then(e =>{
  142. that.users.icon = evt.target.result
  143. })
  144. }
  145. });
  146. })
  147. }
  148. })
  149. }
  150. });
  151. },
  152. getUser(){
  153. getUser({
  154. userId:this.Token
  155. }).then(res => {
  156. this.users = res
  157. }).catch(e => {
  158. plus.nativeUI.toast('获取用户信息失败,请重新登录')
  159. setTimeout(() =>{
  160. exit().then(res => {
  161. this.$store.dispatch('setToken', "")
  162. // uni.clearStorage()
  163. this.$store.dispatch('setUsers', "{}")
  164. uni.reLaunch({
  165. url: '/pages/native/login'
  166. });
  167. }).catch(e => {
  168. plus.nativeUI.toast('服务退出登录失败,正强制退出...')
  169. setTimeout(() =>{
  170. this.$store.dispatch('setToken', "")
  171. this.$store.dispatch('setUsers', "{}")
  172. uni.reLaunch({
  173. url: '/pages/native/login'
  174. });
  175. },1000)
  176. })
  177. },1000)
  178. })
  179. },
  180. changePhone(){
  181. BeforeNavigateTo({
  182. url: '/pages/webview/changePhone',
  183. }, true)
  184. },
  185. changeEmail(){
  186. BeforeNavigateTo({
  187. url: '/pages/webview/changeEmail',
  188. }, true)
  189. },
  190. changeName(){
  191. BeforeNavigateTo({
  192. url: '/pages/webview/changeName',
  193. }, true)
  194. },
  195. switchChange(e){
  196. },
  197. changePass(){
  198. BeforeNavigateTo({
  199. url: '/pages/webview/changePassword',
  200. }, true)
  201. },
  202. APPUpdate() {
  203. return
  204. APPUpdate(true)
  205. },
  206. errorImg() {
  207. this.users.avatar = "/static/iconM.png"
  208. },
  209. goFeedback() {
  210. BeforeNavigateTo({
  211. url: '/pages/webview/feedback',
  212. }, true)
  213. },
  214. go() {
  215. BeforeNavigateTo({
  216. url: '/pages/hybrid/index',
  217. }, true)
  218. },
  219. remove() {
  220. uni.showActionSheet({
  221. itemList: ['确定退出'],
  222. success: (res) => {
  223. exit().then(res => {
  224. this.$store.dispatch('setToken', "")
  225. // uni.clearStorage()
  226. this.$store.dispatch('setUsers', "{}")
  227. uni.reLaunch({
  228. url: '/pages/native/login'
  229. });
  230. }).catch(e => {
  231. plus.nativeUI.toast('服务退出登录失败,正强制退出...')
  232. setTimeout(() =>{
  233. this.$store.dispatch('setToken', "")
  234. this.$store.dispatch('setUsers', "{}")
  235. uni.reLaunch({
  236. url: '/pages/native/login'
  237. });
  238. },1000)
  239. })
  240. }
  241. });
  242. },
  243. }
  244. }
  245. </script>
  246. <style scoped lang="scss">
  247. .icon {
  248. font-family: iconfont;
  249. font-size: 26px;
  250. }
  251. .m-page {
  252. /*#ifdef MP-WEIXIN*/
  253. height: 100vh;
  254. /*#endif*/
  255. .banner{
  256. width: 750rpx;
  257. height: 332rpx;
  258. }
  259. .m-center{
  260. margin: 20rpx 0 0 0;
  261. }
  262. .m-list {
  263. border-bottom:1px solid #E5E5E5;
  264. background: #fff;
  265. flex-direction: row;
  266. align-items: center;
  267. padding: 30rpx 30rpx;
  268. .butt {
  269. padding: 0;
  270. border: 0px;
  271. margin: 0;
  272. font-size: 32px !important;
  273. }
  274. .m-1,.m-2,.m-3,.m-4,.m-5,.m-6,.m-7{
  275. font-size: 34rpx;
  276. width: 50rpx;
  277. }
  278. .m-1{color: #F34E4E;}
  279. .m-2{color: #3EAB3E;}
  280. .m-3{color: #9127AB;}
  281. .m-4{color: #37A8FF;}
  282. .m-5{color: #E9C70C;}
  283. .m-6{color: #5C83F2;}
  284. .m-7{color: #F66D23;}
  285. .m-t {
  286. color: #666;
  287. font-size: 34rpx;
  288. }
  289. .m-r {
  290. flex: 1;
  291. text-align: right;
  292. color: #999;
  293. justify-content: flex-end;
  294. font-size: 32rpx;
  295. }
  296. }
  297. .m-b {
  298. justify-content: center;
  299. background: #0581FD;
  300. margin:50rpx;
  301. flex-direction: row;
  302. align-items: center;
  303. padding: 20rpx 30rpx;
  304. border-radius: 15rpx;
  305. border: 1px solid #0581FD;
  306. .m-t {
  307. color: #fff;
  308. font-size: 34rpx;
  309. }
  310. }
  311. .m-head {
  312. padding: 20rpx 30rpx;
  313. position: absolute;
  314. top: 0;
  315. height: 332rpx;
  316. margin-bottom: 30rpx;
  317. flex-direction: row;
  318. align-items: center;
  319. .img1 {
  320. width: 150rpx;
  321. height: 150rpx;
  322. border-radius: 100rpx;
  323. margin-right: 30rpx;
  324. }
  325. .h-t1 {
  326. color: #fff;
  327. font-size: 36rpx;
  328. }
  329. .h-t2 {
  330. color: #fff;
  331. padding-top: 15rpx;
  332. font-size: 34rpx;
  333. }
  334. .h-t3{
  335. color: #fff;
  336. padding-top: 15rpx;
  337. font-size: 28rpx;
  338. }
  339. }
  340. }
  341. </style>