index.vue 10.0 KB

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