my.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="container my-container" v-if="haveData">
  3. <view class="my-top-info">
  4. <image :src="userInfo.Headimgurl" class="avatar" v-if="isLogin && userInfo.Headimgurl"></image>
  5. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/default_avatar.png" class="avatar" v-else></image>
  6. <view class="right-section">
  7. <template v-if="isLogin">
  8. <view class="info-item space-item text_oneLine" v-if="userInfo.Mobile || userInfo.Email">
  9. <view class="item-label" decode="true">{{ userInfo.Mobile ? "手机号" : "邮&nbsp;&nbsp;&nbsp;箱" }}</view>
  10. :{{ userInfo.Mobile || userInfo.Email }}
  11. </view>
  12. <view class="info-item space-item text_oneLine"> <view class="item-label" decode="true">姓&nbsp;&nbsp;&nbsp;名</view>:{{ userInfo.RealName || "暂无" }} </view>
  13. <view class="info-item text_oneLine"> <view class="item-label" decode="true">公&nbsp;&nbsp;&nbsp;司</view>:{{ userInfo.CompanyName || "暂无" }} </view>
  14. </template>
  15. <button class="no-log" v-else @click="loginHandle">{{ login_txt }}</button>
  16. </view>
  17. </view>
  18. <view class="auth-cont">
  19. <image src="https://hzstatic.hzinsights.com/cygx/czbk/auth_bg.png" class="auth_bg"></image>
  20. <view class="auth-info">
  21. <template v-if="isLogin">
  22. <text class="info-label">我的权限:</text>
  23. <scroll-view scroll-x="true" scroll-with-animation class="auth-ul" v-if="userInfo.HasPermission === 0">
  24. <!-- <view class="auth-ul" > -->
  25. <text class="auth-li" v-for="item in authList" :key="item">{{ item }}</text>
  26. <!-- </view> -->
  27. </scroll-view>
  28. <block v-else>
  29. <text class="no-auth">{{ userInfo.HasPermission === 3 ? "权限申请已提交,请等待审核" : "暂未开通行业权限" }}</text>
  30. <button class="auth-btn" @click="applyAuth" v-if="userInfo.HasPermission != 3">申请开通</button>
  31. </block>
  32. </template>
  33. <text class="notlog-tip" v-else>让好的研究不再是奢侈品</text>
  34. </view>
  35. </view>
  36. <view class="my-bot-cont">
  37. <view class="list-item border_bottom" @click="itemClickHandle('外呼')">
  38. <text>外呼号码</text>
  39. <view class="my-bot-box">
  40. <text v-if="userInfo.OutboundCountryCode && userInfo.OutboundMobile" style="margin-right: 40rpx; font-size: 28rpx">{{ userInfo.OutboundCountryCode }}-{{ userInfo.OutboundMobile }}</text>
  41. <text v-else style="margin-right: 40rpx; font-size: 28rpx">未设置</text>
  42. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="my-bot-cont">
  47. <view class="list-item border_bottom" @click="itemClickHandle('提问')">
  48. <text>我的提问</text>
  49. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  50. </view>
  51. <view class="list-item border_bottom" v-for="type in typeArr" :key="type" @click="itemClickHandle(type)">
  52. <text>{{ type }}</text>
  53. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import { Mine, checkToken, User } from "@/config/api.js";
  60. let app = getApp();
  61. export default {
  62. data() {
  63. return {
  64. isLogin: false, //是否绑定且授权
  65. login_txt: "",
  66. haveData: null, //显示页面
  67. typeArr: ["我的收藏", "访谈申请", "浏览历史", "优化建议"],
  68. typeObj: new Map([
  69. ["我的收藏", "myCollection"],
  70. ["访谈申请", "applyInterview"],
  71. ["浏览历史", "browseHistory"],
  72. ["优化建议", "advice"],
  73. ]),
  74. userInfo: {},
  75. authList: [],
  76. };
  77. },
  78. async onShow() {
  79. await this.$store.dispatch("checkHandle", "noGO");
  80. this.haveData = true;
  81. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  82. //已授权已绑定
  83. this.isLogin = true;
  84. this.getUser();
  85. } else {
  86. this.login_txt = this.$store.state.isAuth ? "点击登录" : "绑定联系方式";
  87. this.isLogin = false;
  88. }
  89. },
  90. methods: {
  91. /* 检查状态 */
  92. /* 获取用户信息 */
  93. getUser() {
  94. Mine.getInfo().then((res) => {
  95. if (res.Ret === 200) {
  96. this.authList = res.Data.PermissionName && res.Data.PermissionName.split(",");
  97. this.userInfo = res.Data;
  98. res.Data.Mobile && this.$db.set("mobile", res.Data.Mobile);
  99. }
  100. });
  101. },
  102. /* 点击登录 检验是否绑定或是否授权*/
  103. loginHandle() {
  104. /* 先授权再绑定 */
  105. if (this.$store.state.isAuth) {
  106. uni.navigateTo({
  107. url: "/pageMy/authGuide/authGuide",
  108. });
  109. } else {
  110. this.$store.state.isBind &&
  111. uni.navigateTo({
  112. url: "/pageMy/login/login",
  113. });
  114. }
  115. },
  116. /* 申请开通权限 */
  117. applyAuth() {
  118. /* 查看是否是潜在用户 */
  119. this.userInfo.HasPermission === 1
  120. ? User.applyTry({
  121. ApplyMethod: 3,
  122. }).then((res) => {
  123. if (res.Ret === 200) {
  124. uni.navigateTo({
  125. url: "/pageMy/applyResult/applyResult",
  126. });
  127. }
  128. })
  129. : this.userInfo.HasPermission === 2
  130. ? uni.navigateTo({
  131. url: "/pageMy/applyTrial/applyTrial",
  132. })
  133. : this.userInfo.HasPermission === 3
  134. ? uni.showModal({
  135. title: "",
  136. content: "您已经提交过申请了,请耐心等待",
  137. showCancel: false,
  138. confirmColor: "#365595",
  139. success: function (res) {},
  140. })
  141. : "";
  142. },
  143. /* 路径跳转 */
  144. itemClickHandle(type) {
  145. /* 是否登录 */
  146. if (this.isLogin) {
  147. if (type == "外呼") {
  148. uni.navigateTo({
  149. url: "/activityPages/editOutbound/editOutbound?title=设置外呼号码&identification=我的",
  150. });
  151. } else if (type == "提问") {
  152. uni.navigateTo({
  153. url: "/reportPages/myAskPage/myAskPage",
  154. });
  155. } else {
  156. let path = this.typeObj.get(type);
  157. uni.navigateTo({
  158. url: `/pageMy/${path}/${path}`,
  159. });
  160. }
  161. } else {
  162. this.loginHandle();
  163. }
  164. },
  165. },
  166. };
  167. </script>
  168. <style lang="scss" scoped>
  169. .my-container {
  170. background-color: #fff;
  171. .my-top-info {
  172. padding: 30rpx 34rpx;
  173. display: flex;
  174. align-items: center;
  175. .avatar {
  176. width: 168rpx;
  177. height: 168rpx;
  178. border-radius: 50%;
  179. margin-right: 45rpx;
  180. border: 1rpx solid #ccc;
  181. }
  182. .right-section {
  183. font-size: 34rpx;
  184. .info-item {
  185. width: 450rpx;
  186. .item-label {
  187. // text-align: justify;
  188. // text-align-last: justify;
  189. display: inline-block;
  190. // width: 110rpx;
  191. }
  192. &.space-item {
  193. margin-bottom: 10rpx;
  194. }
  195. }
  196. .no-log {
  197. padding: 0 20rpx;
  198. height: 56rpx;
  199. line-height: 52rpx;
  200. background-color: #fff;
  201. color: #3385ff;
  202. font-size: 24rpx;
  203. border: 2rpx solid #3385ff;
  204. }
  205. }
  206. }
  207. .auth-cont {
  208. width: 682rpx;
  209. height: 153rpx;
  210. margin: 38rpx auto;
  211. padding: 24rpx 36rpx;
  212. position: relative;
  213. color: #4a4a4a;
  214. .auth_bg {
  215. width: 682rpx;
  216. height: 153rpx;
  217. position: absolute;
  218. left: 0;
  219. top: 0;
  220. }
  221. .auth-info {
  222. position: relative;
  223. .notlog-tip {
  224. font-size: 30rpx;
  225. color: #333333;
  226. line-height: 105rpx;
  227. text-align: center;
  228. }
  229. .info-label {
  230. font-size: 34rpx;
  231. }
  232. .auth-ul {
  233. width: 100%;
  234. white-space: nowrap;
  235. margin-top: 15rpx;
  236. color: #333;
  237. .auth-li {
  238. display: inline-block;
  239. padding: 6rpx 20rpx;
  240. border: 1rpx solid #333333;
  241. border-radius: 4rpx;
  242. font-size: 24rpx;
  243. margin-right: 20rpx;
  244. &:last-child {
  245. margin-right: 0;
  246. }
  247. }
  248. }
  249. .no-auth {
  250. font-size: 28rpx;
  251. margin-top: 20rpx;
  252. }
  253. .auth-btn {
  254. width: 139rpx;
  255. height: 56rpx;
  256. background: rgba(255, 255, 255, 0.1);
  257. color: #3385ff;
  258. font-size: 24rpx;
  259. position: absolute;
  260. right: 0;
  261. top: 50%;
  262. transform: translateY(-50%);
  263. line-height: 56rpx;
  264. border: 2rpx solid #3385ff;
  265. }
  266. }
  267. }
  268. .my-bot-cont {
  269. .my-bot-box {
  270. display: flex;
  271. }
  272. .list-item {
  273. display: flex;
  274. align-items: center;
  275. justify-content: space-between;
  276. font-size: 34rpx;
  277. color: #4a4a4a;
  278. padding: 33rpx 34rpx;
  279. .icon-area {
  280. width: 100rpx;
  281. }
  282. }
  283. }
  284. }
  285. </style>