index.vue 8.0 KB

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