index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view class="person_wrap">
  3. <template v-if="userInfo.userId">
  4. <view class="navbar-wrap">
  5. <view class="column" :class="{ fixed: isFixedTop }" :style="{ background: background }" id="navbar">
  6. <view class="left"></view>
  7. <view style="font-size:36rpx" class="center">我的</view>
  8. <view class="right" @click="handleSetting">
  9. <u-icon name="setting" color="#333"></u-icon>
  10. </view>
  11. </view>
  12. <!-- <view class="column" v-if="isFixedTop"></view> -->
  13. </view>
  14. <view class="header_wrap">
  15. <view class="header_top_wrap">
  16. <view class="header_info_left">
  17. <u-avatar @click="handleAvatarClick" :src="$avatar(userInfo.avatar)" size="100rpx"></u-avatar>
  18. <view class="info_wrap">
  19. <view class="info_top">
  20. <text class="follow_name">{{ userInfo.userName }}</text>
  21. <u-switch v-model="onlineStatus" active-value='0' inactive-value='1'
  22. :loading="onlineLoading" @change="changeOnlineStatus"></u-switch>
  23. <text class="identity">{{ onlineStatus === '0' ? '上线' : '下线' }}</text>
  24. <!-- 只有当showRoleSwitch为true时才显示切换权限按钮 -->
  25. <view class="identity" v-if="$store.state.user.showRoleSwitch" @click="handleSwitchRole">切换权限</view>
  26. </view>
  27. <view class="info_bottom">
  28. <text>{{ userInfo.phonenumber }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="header_info_right" @click="toPersonal">
  33. <u-icon name="arrow-right" color="#aaa"></u-icon>
  34. </view>
  35. </view>
  36. <view class="parson_menu_wrap" v-if="isCrmRole">
  37. <view class="parson_menu_list">
  38. <navigator url="/pages/publicClue/index" open-type="switchTab" class="menu_item"
  39. hover-class="none">
  40. <image src="@/static/parson/icon-wf.png" mode=""></image>
  41. <text>销售公海</text>
  42. </navigator>
  43. <navigator url='/pages/message/index' open-type="navigate" class="menu_item" hover-class="none">
  44. <image src="@/static/parson/icon-myMessage.png" mode=""></image>
  45. <text>我的消息</text>
  46. </navigator>
  47. <!-- <navigator url='/pages/order/index' open-type="navigate"
  48. class="menu_item" hover-class="none">
  49. <image src="@/static/parson/icon-mycase.png" mode=""></image>
  50. <text>接单中心</text>
  51. </navigator> -->
  52. <navigator url='/pages/privateClue/index' open-type="switchTab" class="menu_item"
  53. hover-class="none">
  54. <image src="@/static/parson/clue.png" mode=""></image>
  55. <text>销售线索</text>
  56. </navigator>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="cards_wrap">
  61. <cards></cards>
  62. </view>
  63. </template>
  64. <u-loading-page :loading="true" v-else></u-loading-page>
  65. <u-picker :show="showSwitchRole" :columns="columns" keyName="label" :defaultIndex="defaultIndex" @confirm="confirmSwitchRole" @cancel="showSwitchRole = false"></u-picker>
  66. </view>
  67. </template>
  68. <script>
  69. import cards from "./cards/index.vue"
  70. // import optionList from "./option/index.vue"
  71. import permision from "@/js_sdk/wa-permission/permission.js";
  72. import { getRoles } from '@/utils/util.js'
  73. export default {
  74. components: {
  75. // optionList,
  76. cards
  77. },
  78. data() {
  79. return {
  80. onlineLoading: false,
  81. switchSystemShow: false,
  82. navbarInitTop: 0, //导航栏初始化距顶部的距离
  83. isFixedTop: true, //是否固定顶部
  84. background: "", // 为了实现渐变背景颜色
  85. showModal: false,
  86. showSwitchRole: false,
  87. columns: [],
  88. defaultIndex: [this.$store.state.user.currentRoleIndex],
  89. isHaveCRM: false,
  90. isHaveSalesman: false,
  91. isHaveWarehouse: false,
  92. };
  93. },
  94. computed: {
  95. isCrmRole(){
  96. return getRoles().some(v => v.includes('CRM'))
  97. },
  98. userInfo() {
  99. return this.$store.state.user.userInfo;
  100. },
  101. onlineStatus: {
  102. get() {
  103. return this.$store.state.user.userInfo.onlineStatus;
  104. },
  105. set(val) {
  106. this.$store.commit("user/SET_USER_ONLINE_STATUS", val);
  107. },
  108. },
  109. nickName() {
  110. return this.userInfo.nickName;
  111. },
  112. userName() {
  113. return this.userInfo.userName;
  114. },
  115. deptName() {
  116. return this.userInfo.newOrgName;
  117. },
  118. time() {
  119. return this.$dayjs().format("YYYY-MM-DD HH:mm:ss")
  120. },
  121. systemList() {
  122. return this.$store.state.user.systemList;
  123. },
  124. filterSystemList() {
  125. return this.systemList.filter(v => this.userInfo.subsystemList.some(u => v.value === u.systemCode));
  126. },
  127. currentSystem: {
  128. get() {
  129. return this.$store.getters.system.value
  130. },
  131. set(val) {
  132. const system = this.systemList.find(v => v.value === val);
  133. // 如果有没保存的催记直接清掉
  134. this.$store.commit("follow/SET_FORM", {});
  135. this.$store.commit("follow/SET_PARAMS", {});
  136. this.$store.commit("user/SET_SYSTEM", system);
  137. this.$store.commit("user/SET_BELONGSYSTEM", {
  138. code: val,
  139. callback: (flag) => {
  140. if (flag) {
  141. setTimeout(() => {
  142. // 定时器可加可不加
  143. uni.reLaunch({
  144. url: "/pages/person/index",
  145. success: () => {
  146. uni.$u.toast("切换成功,当前为" + system.text);
  147. }
  148. })
  149. }, 300)
  150. } else {
  151. this.$store.commit("user/SET_TOKEN", "");
  152. this.$store.commit("user/SET_USERINFO", {});
  153. uni.reLaunch({
  154. url: "/pages/login/index",
  155. success() {
  156. uni.$u.toast("请检查您是否有该系统权限");
  157. }
  158. })
  159. }
  160. }
  161. })
  162. },
  163. },
  164. },
  165. methods: {
  166. handleSwitchRole(){
  167. this.columns = [];
  168. let roles = this.$store.state.user.availableRoles;
  169. let roleOptions = [];
  170. const hasAdminRole = roles.some(role => role.includes('admin'));
  171. const hasCrmRole = roles.some(role => role.includes('CRM'));
  172. const hasWAREandSALE = roles.some(role => role.includes('WAREandSALE'));
  173. if(hasAdminRole || (hasCrmRole && hasWAREandSALE) ){//管理员、crm+仓库、crm+销售、仓库+销售
  174. roleOptions.push(
  175. { label: 'CRM权限', value: 'CRM' },
  176. { label: '仓库和销售权限', value: 'WAREandSALE' },
  177. );
  178. }else if(hasCrmRole){//只有crm
  179. roleOptions.push(
  180. { label: 'CRM权限', value: 'CRM' },
  181. );
  182. }else if(hasWAREandSALE){//只有仓库或销售
  183. roleOptions.push(
  184. { label: '仓库和销售权限', value: 'WAREandSALE' },
  185. );
  186. }
  187. this.columns = [roleOptions];
  188. this.showSwitchRole = true;
  189. },
  190. confirmSwitchRole(e) {
  191. this.showSwitchRole = false;
  192. this.$store.commit('user/SET_CURRENT_ROLE_INDEX', e.indexs[0]);
  193. setTimeout(()=>{
  194. this.$store.commit('user/SWITCH_ROLE', e.value[0]);
  195. },50)
  196. },
  197. changeOnlineStatus(val) {
  198. this.onlineLoading = true;
  199. uni.$u.api.changeOnlineStatus({ userId: this.$store.state.user.userInfo.userId, onlineStatus: val });
  200. this.onlineLoading = false;
  201. },
  202. handleTest() {
  203. uni.navigateTo({
  204. url: "/pages/demo/demo"
  205. })
  206. },
  207. // 确认选择系统事件
  208. handleSystemConfirm() {
  209. },
  210. // 取消选择系统事件
  211. handleSystemCancel() {
  212. },
  213. // 点击打开选择系统
  214. handleSwitchSystem() {
  215. this.$refs.switch.showModal();
  216. },
  217. onPullDownRefresh() {
  218. uni.stopPullDownRefresh();
  219. this.$store.dispatch("user/getUserInfo");
  220. },
  221. toPersonal() {
  222. uni.navigateTo({
  223. url: "/pages/profile/index"
  224. })
  225. },
  226. handleSetting() {
  227. uni.navigateTo({
  228. url: "/pages/setting/index"
  229. })
  230. },
  231. registerFun() {
  232. if (!this.$store.state.app.callSystem) {
  233. this.$store.dispatch("app/getExtensionByUserId", {
  234. userId: this.$store.state.user.userInfo.userId
  235. }).then((res) => {
  236. Promise.all([permision.requestAndroidPermission("android.permission.RECORD_AUDIO"), permision.requestAndroidPermission('android.permission.MODIFY_AUDIO_SETTINGS')]).then(result => {
  237. const flag = result.every(v => v == 1);
  238. if (flag) {
  239. this.$store.dispatch("app/createWv");
  240. }
  241. })
  242. });
  243. }
  244. },
  245. handleAvatarClick() {
  246. //跳转个人资料
  247. uni.navigateTo({
  248. url: "/pages/profile/index"
  249. })
  250. }
  251. },
  252. mounted() {
  253. if (this.navbarInitTop == 0) {
  254. const query = uni.createSelectorQuery().in(this);
  255. //获取节点距离顶部的距离
  256. query.select("#navbar").boundingClientRect(function (rect) {
  257. if (rect && rect.top > 0) {
  258. var navbarInitTop = parseInt(rect.top);
  259. this.navbarInitTop = navbarInitTop;
  260. }
  261. }).exec();
  262. }
  263. if (this.$store.state.user.token) {
  264. this.$store.dispatch("user/getUserInfo");
  265. } else {
  266. uni.navigateTo({
  267. url: "/pages/login/index"
  268. })
  269. }
  270. },
  271. /**
  272. * 监听页面滑动事件
  273. */
  274. onPageScroll: function (e) {
  275. var scrollTop = parseInt(e.scrollTop); //滚动条距离顶部高度
  276. this.background = `rgba(255, 255, 255,${scrollTop / (scrollTop + 60)})`;
  277. //判断'滚动条'滚动的距离 和 '元素在初始时'距顶部的距离进行判断
  278. var isSatisfy = scrollTop >= this.navbarInitTop ? true : false;
  279. //为了防止不停的setData, 这儿做了一个等式判断。 只有处于吸顶的临界值才会不相等
  280. if (this.isFixedTop === isSatisfy) {
  281. return false;
  282. }
  283. this.isFixedTop = isSatisfy;
  284. }
  285. };
  286. </script>
  287. <style>
  288. .watermarkCans {
  289. width: 250rpx;
  290. height: 250rpx;
  291. position: absolute;
  292. z-index: -1;
  293. }
  294. </style>
  295. <style lang="scss" scoped>
  296. .switchSysytemSelect {
  297. height: 0rpx;
  298. overflow: hidden;
  299. }
  300. .switchSysytemBtn {
  301. width: 630rpx;
  302. margin: auto;
  303. margin-top: 60rpx;
  304. ::v-deep .u-button {
  305. border-radius: 100rpx;
  306. }
  307. }
  308. .person_wrap {
  309. background-size: cover;
  310. background-repeat: no-repeat;
  311. // padding: 0 30rpx;
  312. position: relative;
  313. height: 100vh;
  314. .header_wrap {
  315. box-sizing: border-box;
  316. background: url("@/static/parson/parson_background.png");
  317. background-size: cover;
  318. width: 750rpx;
  319. // position: absolute;
  320. // top: 0;
  321. // left: 0;
  322. padding: 170rpx 30rpx 0 30rpx;
  323. .header_top_wrap {
  324. display: flex;
  325. justify-content: space-between;
  326. align-items: center;
  327. .header_info_left {
  328. display: flex;
  329. align-items: center;
  330. // image {
  331. // width: 100rpx;
  332. // height: 100rpx;
  333. // margin-right: 30rpx;
  334. // border-radius: 50%;
  335. // }
  336. .info_wrap {
  337. margin-left: 20rpx;
  338. .info_top {
  339. margin-bottom: 20rpx;
  340. display: flex;
  341. align-items: center;
  342. .follow_name {
  343. font-size: 32rpx;
  344. color: #202020;
  345. font-weight: bold;
  346. margin-right: 20rpx;
  347. }
  348. .identity {
  349. display: inline-block;
  350. width: 100rpx;
  351. line-height: 36rpx;
  352. background: #ffffff;
  353. border-radius: 18px;
  354. text-align: center;
  355. font-size: 22rpx;
  356. color: #666666;
  357. margin-left: 10px;
  358. }
  359. }
  360. .info_bottom {
  361. text {
  362. font-size: 28rpx;
  363. color: #666666;
  364. }
  365. }
  366. }
  367. }
  368. .header_info_right {
  369. ::v-deep .u-icon__icon {
  370. font-size: 30rpx !important;
  371. }
  372. }
  373. }
  374. .cards_wrap {
  375. padding: 0 30rpx 0 30rpx;
  376. }
  377. .box {
  378. height: 200vh;
  379. }
  380. .parson_menu_wrap {
  381. background: #ffffff;
  382. border-radius: 20px;
  383. box-shadow: 0px 4px 20px 0px rgba(16, 140, 255, 0.10);
  384. margin-top: 58rpx;
  385. .parson_menu_list {
  386. display: flex;
  387. padding: 40rpx 0;
  388. .menu_item {
  389. width: 33%;
  390. display: flex;
  391. flex-direction: column;
  392. align-items: center;
  393. image {
  394. width: 48rpx;
  395. height: 48rpx;
  396. margin-bottom: 24rpx;
  397. }
  398. text {
  399. font-size: 28rpx;
  400. color: #202020;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .secondHalf {
  407. padding: 0 30rpx;
  408. }
  409. .box {
  410. height: 200vh;
  411. }
  412. }
  413. .navbar-wrap {
  414. width: 750rpx;
  415. .left {
  416. width: 70rpx;
  417. }
  418. .right {
  419. margin-right: 30rpx;
  420. ::v-deep .u-icon__icon {
  421. font-size: 40rpx !important;
  422. }
  423. }
  424. }
  425. .navbar-wrap .column {
  426. box-sizing: border-box;
  427. padding-top: 60rpx;
  428. width: 750rpx;
  429. height: 170rpx;
  430. display: flex;
  431. justify-content: space-between;
  432. align-items: center;
  433. background: transparent;
  434. top: 0;
  435. left: 0;
  436. z-index: 100;
  437. }
  438. .navbar-wrap .column.fixed {
  439. width: 750rpx;
  440. position: fixed;
  441. }
  442. .navbar-wrap .column .center {
  443. text-align: center;
  444. font-size: 36rpx;
  445. color: #333333;
  446. letter-spacing: 1px;
  447. position: relative;
  448. }
  449. </style>