index.vue 8.5 KB

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