index.vue 9.9 KB

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