index.vue 9.0 KB

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