user.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="user-page">
  3. <view class="top-box">
  4. <view class="flex">
  5. <view class="avatar">
  6. <open-data type="userAvatarUrl"></open-data>
  7. </view>
  8. <view>
  9. <view class="user-name">{{userInfo.real_name||'--'}}</view>
  10. <view class="tel" v-if="userInfo.mobile">{{userInfo.mobile}}</view>
  11. <view class="tel" v-else>{{userInfo.email}}</view>
  12. </view>
  13. </view>
  14. <view class="flex company">
  15. <image src="../../static/company.png" mode="widthFix"/>
  16. <text>{{userInfo.company_name||'--'}}</text>
  17. </view>
  18. </view>
  19. <view class="content">
  20. <view class="flex item-card" >
  21. <image src="../../static/user-icon-1.png" mode="widthFix" />
  22. <text class="label">品种权限</text>
  23. <block v-if="userInfo.status=='冻结'||(userInfo.status=='试用'&&userInfo.is_suspend==1)">
  24. <text style="color:#666666;margin-left:10px">暂无权限</text>
  25. <van-button
  26. custom-class="apply-btn"
  27. plain round color="#DDAA6A"
  28. size="small"
  29. @click.stop="handleContact"
  30. >联系销售</van-button>
  31. </block>
  32. <block v-else-if="userInfo.permission_list.length==0">
  33. <text style="color:#666666;margin-left:10px">暂无权限</text>
  34. <van-button
  35. custom-class="apply-btn"
  36. plain round color="#DDAA6A"
  37. size="small"
  38. @click.stop="handleGoApplyPermission"
  39. >立即申请</van-button>
  40. </block>
  41. <view v-else class="right-text look" @click="handleToUserPermission">
  42. <text>查看</text>
  43. <van-icon name="arrow"></van-icon>
  44. </view>
  45. </view>
  46. <view class="flex item-card">
  47. <image src="../../static/calendar.png" mode="widthFix" />
  48. <text class="label">服务截止日期</text>
  49. <text class="right-text" v-if="!(userInfo.status=='冻结'||(userInfo.status=='试用'&&userInfo.is_suspend==1))">{{lastTime}}</text>
  50. </view>
  51. </view>
  52. <!-- 弹窗 -->
  53. <van-popup :show="pupData.show" @close="pupData.show=false" :close-on-click-overlay="false">
  54. <view class="global-pup">
  55. <view class="content">
  56. <rich-text :nodes="pupData.content"></rich-text>
  57. </view>
  58. <view class="flex bot">
  59. <view @click="pupData.show=false">知道了</view>
  60. </view>
  61. </view>
  62. </van-popup>
  63. </view>
  64. </template>
  65. <script>
  66. const moment=require('@/utils/moment-with-locales.min')
  67. import {apiLastApplyRecord,apiApplyPermission} from '@/api/user'
  68. export default {
  69. computed: {
  70. lastTime(){
  71. let timeArr=[]
  72. this.userInfo.permission_list&&this.userInfo.permission_list.forEach(item=>{
  73. item.permission_list.forEach(item2=>{
  74. timeArr.push(new Date(item2.end_date))
  75. })
  76. })
  77. let maxTime=Math.max(...timeArr)
  78. if(timeArr.length===0){
  79. return ''
  80. }else{
  81. return moment(maxTime).format('YYYY.MM.DD')
  82. }
  83. }
  84. },
  85. data () {
  86. return {
  87. pupData:{
  88. show:false,
  89. content:'',//弹窗html字符串
  90. }
  91. }
  92. },
  93. onShow() {
  94. this.$store.dispatch('getUserInfo')
  95. },
  96. methods: {
  97. async handleGoApplyPermission(){
  98. const res=await apiLastApplyRecord({source:1})
  99. if(res.code===200){
  100. if(!res.data){
  101. uni.navigateTo({
  102. url:"/pages-applyPermission/applyPermission?source=1"
  103. })
  104. }else{
  105. this.pupData.show=true
  106. this.pupData.content=`<p>您已提交过申请,请耐心等待</p>`
  107. // uni.navigateTo({
  108. // url:"/pages-applyPermission/applyResult"
  109. // })
  110. }
  111. }
  112. },
  113. handleToUserPermission(){
  114. if(this.userInfo.permission_list.length==0) return
  115. uni.navigateTo({ url: '/pages-user/permissionList' })
  116. },
  117. handleContact(){
  118. apiApplyPermission({
  119. company_name:this.userInfo.company_name,
  120. real_name:this.userInfo.real_name,
  121. }).then(res=>{
  122. if(res.code===200){
  123. console.log('主动申请成功');
  124. }
  125. })
  126. uni.makePhoneCall({
  127. phoneNumber: this.userInfo.seal_mobile
  128. });
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .user-page{
  135. min-height: calc(100vh - calc(50px + constant(safe-area-inset-bottom)));
  136. min-height: calc(100vh - calc(50px + env(safe-area-inset-bottom)));
  137. background-color: #EDEDED;
  138. }
  139. .top-box{
  140. height: 392rpx;
  141. background-color: #fff;
  142. padding: 98rpx 50rpx 0 50rpx;
  143. .avatar{
  144. width: 154rpx;
  145. height: 154rpx;
  146. border-radius: 16rpx;
  147. overflow: hidden;
  148. margin-right: 40rpx;
  149. }
  150. .user-name{
  151. font-size: 24px;
  152. font-weight: bold;
  153. color: #060606;
  154. }
  155. .tel{
  156. margin-top: 26rpx;
  157. color: #999;
  158. }
  159. .company{
  160. margin-top: 50rpx;
  161. image{
  162. width: 32rpx;
  163. height: 32rpx;
  164. margin-right: 8rpx;
  165. }
  166. color:#DBA665;
  167. }
  168. }
  169. .content{
  170. background-color: #fff;
  171. margin-top: 12rpx;
  172. padding: 0 34rpx;
  173. .item-card{
  174. position: relative;
  175. padding: 30rpx 0;
  176. border-bottom: 1px solid $global-border-color;
  177. image{
  178. width: 36rpx;
  179. height: 36rpx;
  180. }
  181. .label{
  182. font-weight: bold;
  183. margin-left: 20rpx;
  184. }
  185. .apply-btn{
  186. position: absolute;
  187. top: 50%;
  188. right: 0;
  189. transform: translateY(-50%);
  190. height: 50rpx;
  191. width: 156rpx;
  192. }
  193. .right-text{
  194. position: absolute;
  195. top: 50%;
  196. right: 0;
  197. transform: translateY(-50%);
  198. color: #666666;
  199. }
  200. .look{
  201. width: 100rpx;
  202. height: 100rpx;
  203. text-align: right;
  204. line-height: 100rpx;
  205. }
  206. }
  207. .item-card:last-child{
  208. border: none;
  209. }
  210. }
  211. </style>