user.vue 7.2 KB

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