index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="user-content">
  3. <view class="status_bar" :style="`background:${$config('primaryColor')}`">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <!-- 头部 -->
  7. <view class="user-head" :style="`background:${$config('primaryColor')}`">
  8. <view class="user-photo">
  9. <u-avatar :src="userAvatarUrl" size="100" class="avatar"></u-avatar>
  10. </view>
  11. <view class="user-info">
  12. <text class="user-name">{{userData.orgName}}</text>
  13. <text class="user-phone">{{userData.username}}</text>
  14. </view>
  15. <view class="user-org" @click="show = true" v-if="orglist&&orglist.length">
  16. 切换 <u-icon name="arrow-right"></u-icon>
  17. </view>
  18. </view>
  19. <!-- 列表 -->
  20. <view class="user-list">
  21. <u-cell-group>
  22. <u-cell-item icon="volume" icon-size="36" :icon-style="{color:'#00aaff'}" index="3" @click="toPage(3)" title="消息">
  23. <u-badge :count="noReadNums" :absolute="false" slot="right-icon"></u-badge>
  24. </u-cell-item>
  25. <u-cell-item icon="edit-pen" icon-size="38" :icon-style="{color:'#00aaff'}" index="1" @click="toPage(1)" title="修改密码"></u-cell-item>
  26. <u-cell-item icon="man-delete" icon-size="38" :icon-style="{color:'#00aaff'}" index="1" @click="closeAccount" title="注销账户"></u-cell-item>
  27. </u-cell-group>
  28. <u-cell-group>
  29. <!-- <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="关于我们"></u-cell-item> -->
  30. <u-cell-item icon="level" icon-size="34" :icon-style="{color:'#00aaff'}" index="2" @click="toPage(2)" :value="curVer.version" title="版本检查"></u-cell-item>
  31. <u-cell-item icon="file-text" icon-size="36" :icon-style="{color:'#00aaff'}" index="0" @click="toPage(0)" title="服务协议及隐私政策"></u-cell-item>
  32. </u-cell-group>
  33. </view>
  34. <!-- 退出 -->
  35. <view class="user-btn">
  36. <u-button type="success" :custom-style="{background:$config('primaryColor')}" hover-class="none" @click="quitOutSys" shape="circle">退出登录</u-button>
  37. </view>
  38. <u-action-sheet :list="orglist" v-model="show" @click="changeAcount" :tips="tips" :cancel-btn="true"></u-action-sheet>
  39. </view>
  40. </template>
  41. <script>
  42. import { getUserInfo, logout, login, getUnreadCount, logoff } from '@/api/user.js'
  43. import { getSysVersion } from '@/api/data.js'
  44. import { checkVersionToLoadUpdate, clzConfirm } from '@/libs/tools';
  45. import market from "@/js_sdk/dc-market/market.js"
  46. export default {
  47. data() {
  48. return {
  49. isRemember: false,
  50. show:false,
  51. tips: {
  52. text: '切换账户',
  53. color: '#999',
  54. fontSize: 32
  55. },
  56. userInfoData: null, // 用户信息
  57. userAvatarUrl: '' ,// 用户头像
  58. curVer: null,
  59. noReadNums: 0,
  60. };
  61. },
  62. onShow() {
  63. this.getUnread()
  64. console.log(this.userData)
  65. },
  66. computed: {
  67. orglist() {
  68. // 当前连锁账户
  69. const orgs = this.$store.state.vuex_authOrgs;
  70. const user = this.$store.state.vuex_userData;
  71. if(orgs){
  72. orgs.map(item => {
  73. item.text = item.orgName
  74. })
  75. }
  76. return orgs ? orgs.filter(item => item.orgSn != user.orgSn) : []
  77. },
  78. userData () {
  79. return this.$store.state.vuex_userData;
  80. },
  81. isIos(){
  82. return uni.getSystemInfoSync().platform == "ios"
  83. }
  84. },
  85. onLoad() {
  86. uni.setNavigationBarColor({
  87. frontColor: '#ffffff',
  88. backgroundColor: this.$config('primaryColor')
  89. })
  90. this.isRemember = this.$store.state.vuex_isRemember;
  91. this.curVer = getApp().globalData.version;
  92. },
  93. methods:{
  94. // 未读消息
  95. getUnread(){
  96. getUnreadCount().then(res => {
  97. this.noReadNums = res.data.no_read_count || 0
  98. })
  99. },
  100. // 过滤权限code
  101. fiterAuthCode(data) {
  102. data.permCodes = data.permCodes.filter(item => item.indexOf('_mobile') > 0);
  103. return data;
  104. },
  105. // 切换账户
  106. changeAcount(index){
  107. const _this = this
  108. const item = this.orglist[index]
  109. console.log(index,item)
  110. this.$store.state.vuex_changeOrg = item.orgSn
  111. this.$set(getApp().globalData,'changeOrg',item.orgSn)
  112. setTimeout(()=>{
  113. // 登录
  114. login({ username: '', password: '' }).then(res => {
  115. console.log(res)
  116. uni.hideLoading();
  117. if (res.status == 200) {
  118. _this.$u.vuex('vuex_userData', _this.fiterAuthCode(res.data.auth_user));
  119. _this.$u.vuex('vuex_token', res.data.access_token);
  120. _this.$u.vuex('vuex_authOrgs',res.data.auth_orgs);
  121. getApp().globalData.token = res.data.access_token;
  122. uni.setStorageSync('loginTimeOut', 'NO');
  123. this.toMain()
  124. uni.$emit("refreshSalesHomeBL")
  125. uni.showToast({ icon: 'none', title: '切换成功!' });
  126. }else{
  127. uni.showToast({ icon: 'none', title: res.message });
  128. }
  129. });
  130. },100)
  131. },
  132. // 跳转到首页
  133. toMain() {
  134. uni.switchTab({
  135. url: '/pages/sales/index'
  136. });
  137. },
  138. // 打开对应的页面
  139. toPage(index){
  140. let pageUrl=[
  141. '/pages/login/userAuthYs?fromPage=usercenter',
  142. '/pages/userCenter/changePwd',
  143. 'getVersion',
  144. '/pages/xtNotice/xtNotice'
  145. ]
  146. if(index != 2){
  147. uni.navigateTo({
  148. url: pageUrl[index]
  149. })
  150. }else{
  151. this[pageUrl[index]]()
  152. }
  153. },
  154. // 注销
  155. closeAccount(){
  156. const _this = this;
  157. clzConfirm({
  158. title: '提示',
  159. content: '账户注销后将不能再使用iSCM系统,且您的所有相关数据将被删除,您确定注销吗?',
  160. success: function(res) {
  161. if (res.confirm || res.index == 0) {
  162. logoff().then(ret => {
  163. if(ret.status == 200){
  164. _this.toLogin()
  165. }
  166. })
  167. }
  168. }
  169. });
  170. },
  171. // 退出登录确认弹框
  172. quitOutSys() {
  173. const _this = this;
  174. clzConfirm({
  175. title: '提示',
  176. content: '确定退出登录?',
  177. success: function(res) {
  178. if (res.confirm || res.index == 0) {
  179. logout().then(ret => {
  180. if (ret.status == 200) {
  181. _this.toLogin()
  182. }
  183. });
  184. }
  185. }
  186. });
  187. },
  188. toLogin(){
  189. // this.$store.commit("$closeWebsocket")
  190. this.$set(getApp().globalData,'changeOrg','')
  191. uni.setStorageSync('setStatusIndexFunc', 0);
  192. this.$u.vuex('vuex_userData', '');
  193. this.$u.vuex('vuex_token', '');
  194. this.$u.vuex('vuex_authOrgs','');
  195. getApp().globalData.token = '';
  196. this.$u.vuex('vuex_tempData', '');
  197. setTimeout(function() {
  198. uni.reLaunch({
  199. url: '/pages/login/login'
  200. });
  201. }, 500);
  202. },
  203. // 获取最新版本信息
  204. getVersion() {
  205. let version = getApp().globalData.version
  206. console.log(version)
  207. getSysVersion({versionType:version.platform=='android'?'ANDROID':'IOS'}).then(ret => {
  208. console.log(JSON.stringify(ret))
  209. if(ret.status == 200){
  210. console.log(ret.data)
  211. this.$store.state.vuex_versionInfo = ret.data
  212. //进行版本型号的比对 以及下载更新请求
  213. checkVersionToLoadUpdate(ret.data, 1, market);
  214. }
  215. })
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .user-content{
  222. width: 100%;
  223. .user-head{
  224. display: flex;
  225. align-items: center;
  226. padding: 80rpx 35rpx;
  227. .user-photo{
  228. flex-shrink: 0;
  229. margin-right: 5rpx;
  230. }
  231. .user-org{
  232. color: #fff;
  233. }
  234. .user-info{
  235. flex-grow: 1;
  236. padding: 0 20rpx;
  237. color: #FFFFFF;
  238. .user-name{
  239. display: block;
  240. font-size: 36rpx;
  241. margin-bottom: 10rpx;
  242. }
  243. .user-phone{
  244. display: block;
  245. font-size: 28rpx;
  246. }
  247. }
  248. }
  249. .user-list{
  250. padding: 0 20upx;
  251. > view{
  252. margin: 20upx 0;
  253. border-radius: 15upx;
  254. box-shadow: 0upx 3upx 6upx #eee;
  255. overflow: hidden;
  256. }
  257. }
  258. .user-btn{
  259. padding: 85rpx 200rpx;
  260. }
  261. }
  262. </style>