index.vue 8.7 KB

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