index.vue 12 KB

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