index.vue 10 KB

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