myPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="container my-container" v-if="haveData">
  3. <view class="top-content-box">
  4. <view class="nav-bar-wrap" :style="{ height: navBarStyle.height, paddingTop: navBarStyle.paddingTop, paddingBottom: navBarStyle.paddingBottom }">
  5. <van-icon custom-class="search-icon" name="arrow-left" size="24px" @click="goBack" />
  6. </view>
  7. </view>
  8. <view class="my-background">
  9. <view class="my-notice" v-if="myNotice">
  10. 添加到我的小程序,做您手边的研究素材库👆
  11. <van-icon @click="myNotice = false" class="my-icon" name="cross" />
  12. </view>
  13. </view>
  14. <view class="my-info">
  15. <view class="my-top-info">
  16. <block v-if="isUserBindingPhoneNumber">
  17. <view class="info">
  18. <view class="info-img">
  19. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  20. <image class="avatar" v-if="headimgurl" :src="headimgurl"></image>
  21. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/logo.png" class="avatar" v-else></image>
  22. </button>
  23. </view>
  24. <view class="info-list">
  25. <block v-if="isLogin">
  26. <text class="name">{{ userInfo.RealName || "--" }}</text>
  27. <text class="mobile">{{ userInfo.Mobile || userInfo.Email }}</text>
  28. <text class="company-name">{{ userInfo.CompanyName || "--" }}</text>
  29. </block>
  30. <block v-else>
  31. <text class="name">Hi,请绑定联系方式~</text>
  32. <text class="bind-btn" @click="loginHandle">绑定联系方式</text>
  33. </block>
  34. </view>
  35. </view>
  36. <view class="auth-info">
  37. <template v-if="isLogin">
  38. <scroll-view scroll-x="true" scroll-with-animation class="auth-ul" v-if="userInfo.HasPermission === 0">
  39. <text class="auth-li" v-for="item in authList" :key="item">{{ item }}</text>
  40. </scroll-view>
  41. <block v-else>
  42. <button class="auth-btn" @click="applyAuth" v-if="userInfo.HasPermission != 3">申请开通权限</button>
  43. </block>
  44. </template>
  45. <text v-else class="no-auth">暂无品种权限信息</text>
  46. </view>
  47. <view class="info-item">
  48. <view class="item" @click="itemClickHandle('活动日程')">
  49. <text class="item-number">{{ userInfo.ScheduleNum }}</text>
  50. <text class="item-text">活动日程</text>
  51. </view>
  52. <view class="item item-label" @click="itemClickHandle('我的收藏')">
  53. <text class="item-number">{{ userInfo.ConNum }}</text>
  54. <text class="item-text">收藏</text>
  55. </view>
  56. <view class="item" @click="itemClickHandle('我的足迹')">
  57. <text class="item-number">{{ userInfo.HistoryNum }}</text>
  58. <text class="item-text">足迹</text>
  59. </view>
  60. </view>
  61. </block>
  62. <block v-else>
  63. <view class="btn-login">
  64. <image src="https://hzstatic.hzinsights.com/cygx/icon/activity-no-data.png"></image>
  65. <view>暂无您的登录信息</view>
  66. <view>请登陆后再查看此页面内容</view>
  67. <view class="login-button" @click="pleaseGoLogin">立即登陆</view>
  68. </view>
  69. </block>
  70. </view>
  71. <view class="info-bot">
  72. <block v-for="type in typeArr" :key="type">
  73. <view class="list-item border_bottom" v-if="(type === '关于我们' && wholeShowListData.IsShowAboutVideo) || type != '关于我们'" @click="itemClickHandle(type)">
  74. <text>{{ type }}</text>
  75. <view class="my-bot-box">
  76. <block v-if="type == '外呼号码'">
  77. <text v-if="userInfo.OutboundCountryCode && userInfo.OutboundMobile" style="margin-right: 40rpx; font-size: 28rpx"
  78. >{{ userInfo.OutboundCountryCode }}-{{ userInfo.OutboundMobile }}</text
  79. >
  80. <text v-else style="margin-right: 40rpx; font-size: 28rpx">未设置</text>
  81. </block>
  82. <block v-if="type == '关注公众号'">
  83. <text style="margin-right: 20rpx; font-size: 28rpx">查研观向小助手</text>
  84. </block>
  85. <block v-if="type == 'PC网页版'">
  86. <text @click="copyPcWebUrl" style="margin-right: 20rpx; font-size: 28rpx; color: #376cbb">web.hzinsights.com</text>
  87. </block>
  88. <u-icon v-if="type != 'PC网页版'" name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  89. </view>
  90. </view>
  91. </block>
  92. </view>
  93. <view class="bottom-text">您手边的研究素材库</view>
  94. </view>
  95. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  96. <Loading />
  97. </view>
  98. </template>
  99. <script>
  100. import { uploadurl, Mine, checkToken, User } from "@/config/api.js";
  101. import freeCharge from "@/components/freeCharge";
  102. import NotHaveLogin from "../../components/notHaveLogin.vue";
  103. let app = getApp();
  104. export default {
  105. components: {
  106. freeCharge,
  107. NotHaveLogin,
  108. },
  109. data() {
  110. return {
  111. isLogin: false, //是否绑定且授权
  112. haveData: null, //显示页面
  113. typeArr: [],
  114. typeObj: new Map([
  115. ["外呼号码", "editOutbound"],
  116. ["活动提问", "myAskPage"],
  117. ["我的留言", "myLeavingMessage"],
  118. ["优化建议", "advice"],
  119. ["关于我们", "followUs"],
  120. ["产品内测", "internalTesting"],
  121. ["关注公众号", "accountsOfficial"],
  122. ["我的足迹", "browseHistory"],
  123. ["活动日程", "mySchedulepage"],
  124. ["我的收藏", "myCollection"],
  125. ]),
  126. userInfo: {},
  127. authList: [],
  128. myNotice: true,
  129. headimgurl: "",
  130. };
  131. },
  132. onShow() {
  133. this.haveData = true;
  134. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  135. //已授权已绑定
  136. this.isLogin = true;
  137. this.getUser();
  138. } else {
  139. this.isLogin = false;
  140. }
  141. },
  142. watch: {
  143. "wholeShowListData.IsBelongRai": {
  144. handler(newVal) {
  145. this.typeArr = this.isUserBindingPhoneNumber ? ["外呼号码", "活动提问", "我的留言", "优化建议", "关于我们", "产品内测", "关注公众号", "PC网页版"] : ["关于我们", "关注公众号", "PC网页版"];
  146. if (!newVal) {
  147. this.typeArr.splice(5, 1);
  148. }
  149. },
  150. deep: true,
  151. },
  152. },
  153. methods: {
  154. //获取胶囊位置
  155. initNavBar() {
  156. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  157. this.navBarStyle = {
  158. height: menuButtonInfo.height + menuButtonInfo.top + 8 + "px",
  159. paddingTop: menuButtonInfo.top - 4 + "px",
  160. paddingBottom: "4px",
  161. };
  162. },
  163. // 返回
  164. goBack() {
  165. uni.navigateBack();
  166. },
  167. //点击了头像
  168. onChooseAvatar(e) {
  169. this.getRecordTracking("头像");
  170. let token = this.$db.get("access_token");
  171. let authHeader = token || "";
  172. let that = this;
  173. uni.uploadFile({
  174. url: uploadurl,
  175. filePath: e.detail.avatarUrl,
  176. header: {
  177. "Content-Type": "multipart/form-data",
  178. Authorization: authHeader,
  179. },
  180. name: "file",
  181. success(res) {
  182. let data = JSON.parse(res.data);
  183. that.headimgurl = data.Data.ResourceUrl;
  184. User.headimgurlUpdate({ Headimgurl: data.Data.ResourceUrl });
  185. },
  186. });
  187. },
  188. /* 检查状态 */
  189. /* 获取用户信息 */
  190. getUser() {
  191. Mine.getInfo().then((res) => {
  192. if (res.Ret === 200) {
  193. this.authList = res.Data.PermissionName && res.Data.PermissionName.split(",");
  194. this.userInfo = res.Data;
  195. this.headimgurl = res.Data.Headimgurl;
  196. res.Data.Mobile && this.$db.set("mobile", res.Data.Mobile);
  197. }
  198. });
  199. },
  200. /* 点击登录 检验是否绑定或是否授权*/
  201. loginHandle() {
  202. /* 先授权再绑定 */
  203. if (this.$store.state.isAuth) {
  204. uni.navigateTo({
  205. url: "/pageMy/authGuide/authGuide",
  206. });
  207. } else {
  208. this.$store.state.isBind &&
  209. uni.navigateTo({
  210. url: "/pageMy/login/login",
  211. });
  212. }
  213. },
  214. /* 申请开通权限 */
  215. applyAuth() {
  216. /* 查看是否是潜在用户 */
  217. this.userInfo.HasPermission === 1
  218. ? User.applyTry({
  219. ApplyMethod: 3,
  220. }).then((res) => {
  221. if (res.Ret === 200) {
  222. uni.navigateTo({
  223. url: "/pageMy/applyResult/applyResult",
  224. });
  225. }
  226. })
  227. : this.userInfo.HasPermission === 2
  228. ? uni.navigateTo({
  229. url: "/pageMy/applyTrial/applyTrial",
  230. })
  231. : this.userInfo.HasPermission === 3
  232. ? uni.showModal({
  233. title: "",
  234. content: "您已经提交过申请了,请耐心等待",
  235. showCancel: false,
  236. confirmColor: "#365595",
  237. success: function (res) {},
  238. })
  239. : "";
  240. },
  241. /* 路径跳转 */
  242. itemClickHandle(type) {
  243. let istype = type === "关注公众号" || type === "优化建议" || type === "外呼号码" ? type : "";
  244. istype && this.getRecordTracking("istype");
  245. /* 是否登录 */
  246. if (this.isLogin || type === "关注公众号" || type == "关于我们" || type === "PC网页版") {
  247. switch (type) {
  248. case "外呼号码":
  249. uni.navigateTo({
  250. url: "/activityPages/editOutbound/editOutbound?title=设置外呼号码&identification=我的",
  251. });
  252. break;
  253. case "关注公众号":
  254. uni.navigateTo({
  255. url: "/activityPages/accountsOfficial/accountsOfficial",
  256. });
  257. break;
  258. case "活动提问":
  259. uni.navigateTo({
  260. url: "/reportPages/myAskPage/myAskPage",
  261. });
  262. break;
  263. case "产品内测":
  264. uni.navigateTo({
  265. url: "/reportPages/internalTesting/internalTesting",
  266. });
  267. break;
  268. case "PC网页版":
  269. "";
  270. break;
  271. default:
  272. let path = this.typeObj.get(type);
  273. uni.navigateTo({
  274. url: `/pageMy/${path}/${path}`,
  275. });
  276. }
  277. } else {
  278. this.loginHandle();
  279. }
  280. },
  281. // 复制网页链接
  282. copyPcWebUrl() {
  283. uni.setClipboardData({
  284. data: "web.hzinsights.com",
  285. success: function () {
  286. uni.showToast({
  287. title: "已复制到剪贴板",
  288. icon: "none",
  289. duration: 2000,
  290. });
  291. },
  292. });
  293. },
  294. },
  295. onLoad() {
  296. this.initNavBar();
  297. },
  298. };
  299. </script>
  300. <style lang="scss" scoped>
  301. .my-container {
  302. background-color: $uni-bg-color;
  303. position: relative;
  304. .top-content-box {
  305. position: sticky;
  306. top: 0;
  307. left: 0;
  308. width: 100%;
  309. z-index: 9;
  310. }
  311. .nav-bar-wrap {
  312. width: 100%;
  313. padding-left: 35rpx;
  314. display: flex;
  315. align-items: center;
  316. position: relative;
  317. .search-icon {
  318. position: absolute;
  319. left: 34rpx;
  320. top: 50%;
  321. transform: translateY(-50%);
  322. }
  323. }
  324. .nav-bar-wrap {
  325. color: #fff;
  326. position: fixed;
  327. top: 0;
  328. left: 0;
  329. width: 100%;
  330. z-index: 999;
  331. }
  332. .my-background {
  333. height: 480rpx;
  334. width: 100%;
  335. background: url("https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/my_bg.jpg") no-repeat;
  336. background-size: 100% 100%;
  337. padding-top: 206rpx;
  338. .my-notice {
  339. height: 55rpx;
  340. width: 690rpx;
  341. margin: 0 auto;
  342. background: rgba(255, 255, 255, 0.5);
  343. border-radius: 8px;
  344. line-height: 55rpx;
  345. text-align: center;
  346. color: #ffffff;
  347. position: relative;
  348. padding-right: 20rpx;
  349. .my-icon {
  350. position: absolute;
  351. right: 20rpx;
  352. top: 50%;
  353. transform: translateY(-50%);
  354. font-weight: bold;
  355. font-size: 16px;
  356. }
  357. }
  358. }
  359. .my-info {
  360. position: absolute;
  361. background: $uni-bg-color;
  362. top: 301rpx;
  363. left: 50%;
  364. transform: translateX(-50%);
  365. padding-bottom: 100rpx;
  366. padding-bottom: calc(100rpx + constant(safe-area-inset-bottom));
  367. padding-bottom: calc(100rpx + env(safe-area-inset-bottom));
  368. .my-top-info {
  369. width: 690rpx;
  370. margin: 0 auto;
  371. height: 436rpx;
  372. background: url("https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/my_log.png") no-repeat;
  373. background-color: #ffffff;
  374. background-position: right top;
  375. background-size: 267rpx 274rpx;
  376. box-sizing: border-box;
  377. box-shadow: 0px 0rpx 7rpx 1rpx #f0f3f5;
  378. border-radius: 8rpx;
  379. .info {
  380. padding: 61rpx 0 0 30rpx;
  381. display: flex;
  382. .info-img {
  383. width: 126rpx;
  384. height: 126rpx;
  385. background: #c4c4c4;
  386. border-radius: 50%;
  387. overflow: hidden;
  388. .avatar-wrapper {
  389. width: 126rpx;
  390. height: 126rpx;
  391. }
  392. .avatar {
  393. width: 126rpx;
  394. height: 126rpx;
  395. border-radius: 50%;
  396. }
  397. }
  398. .info-list {
  399. display: flex;
  400. flex-direction: column;
  401. justify-content: space-between;
  402. margin-left: 32rpx;
  403. font-size: 24rpx;
  404. font-weight: 400;
  405. color: #666666;
  406. .name {
  407. font-size: 30rpx;
  408. color: #000000;
  409. line-height: 35rpx;
  410. font-weight: 500;
  411. }
  412. .bind-btn {
  413. display: flex;
  414. align-items: center;
  415. justify-content: center;
  416. color: $uni-color-new;
  417. width: 181rpx;
  418. height: 49rpx;
  419. background: #edf4ff;
  420. border-radius: 8rpx;
  421. border: 1rpx solid $uni-color-new;
  422. }
  423. }
  424. }
  425. .auth-info {
  426. width: 100%;
  427. overflow: hidden;
  428. margin-top: 36rpx;
  429. .auth-ul {
  430. white-space: nowrap;
  431. padding: 0 30rpx;
  432. color: $uni-color-new;
  433. .auth-li {
  434. display: inline-block;
  435. padding: 1rpx 20rpx;
  436. border: 1rpx solid $uni-color-new;
  437. border-radius: 4rpx;
  438. font-size: 24rpx;
  439. margin-right: 20rpx;
  440. background: #edf4ff;
  441. &:last-child {
  442. margin-right: 50rpx;
  443. }
  444. }
  445. }
  446. .no-auth {
  447. text-align: center;
  448. font-size: 28rpx;
  449. color: #999999;
  450. }
  451. .auth-btn {
  452. width: 181rpx;
  453. height: 49rpx;
  454. margin: 0 auto;
  455. color: #376cbb;
  456. font-size: 24rpx;
  457. line-height: 47rpx;
  458. border: 2rpx solid #376cbb;
  459. }
  460. }
  461. .info-item {
  462. display: flex;
  463. padding-left: 30rpx;
  464. margin: 36rpx auto 0;
  465. .item {
  466. width: 208rpx;
  467. height: 76rpx;
  468. display: flex;
  469. flex-direction: column;
  470. justify-content: space-between;
  471. text-align: center;
  472. .item-number {
  473. font-size: 40rpx;
  474. font-weight: 500;
  475. }
  476. }
  477. .item-label {
  478. border-right: 1rpx solid #ececec;
  479. border-left: 1rpx solid #ececec;
  480. }
  481. }
  482. }
  483. .info-bot {
  484. padding: 0 20rpx;
  485. background-color: #fff;
  486. box-shadow: 0px 0rpx 7rpx 1rpx #f0f3f5;
  487. border-radius: 8rpx;
  488. margin-top: 20rpx;
  489. .list-item {
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. font-size: 34rpx;
  494. color: #4a4a4a;
  495. padding: 33rpx 34rpx;
  496. .icon-area {
  497. width: 100rpx;
  498. }
  499. &:last-child {
  500. position: static;
  501. }
  502. }
  503. .my-bot-box {
  504. display: flex;
  505. }
  506. }
  507. }
  508. .bottom-text {
  509. position: absolute;
  510. background: $uni-bg-color;
  511. bottom: 80rpx;
  512. right: 0;
  513. z-index: 9;
  514. font-size: 20rpx;
  515. color: #999999;
  516. width: 100%;
  517. text-align: center;
  518. }
  519. .not-bind-login {
  520. position: absolute;
  521. top: 301rpx;
  522. left: 50%;
  523. transform: translateX(-50%);
  524. width: 95%;
  525. height: 1234rpx;
  526. background-color: #fff;
  527. border-radius: 8rpx;
  528. border: 1px solid #ececec;
  529. .bottom-text {
  530. position: absolute;
  531. bottom: -50rpx;
  532. }
  533. }
  534. .btn-login {
  535. padding-top: 60rpx;
  536. display: flex;
  537. flex-direction: column;
  538. justify-content: center;
  539. align-items: center;
  540. color: #999999;
  541. font-size: 24rpx;
  542. line-height: 36rpx;
  543. image {
  544. width: 261rpx;
  545. height: 201rpx;
  546. }
  547. .login-button {
  548. margin-top: 20rpx;
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. width: 156rpx;
  553. height: 52rpx;
  554. border-radius: 9rpx;
  555. color: #fff;
  556. font-weight: 600;
  557. background-color: #376cbb;
  558. }
  559. }
  560. }
  561. </style>