myPage.vue 15 KB

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