index.vue 9.1 KB

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