my.vue 13 KB

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