user.vue 7.4 KB

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