my.vue 6.8 KB

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