user.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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/question/question-icon.png" mode="widthFix" />
  64. <text class="label">我的问答</text>
  65. <view class="right-text look" @click="handleToQuestionPage">
  66. <!-- <text>查看</text> -->
  67. <text class="hint" v-if="questionUnread!==0">{{questionUnread}}</text>
  68. <van-icon name="arrow"></van-icon>
  69. </view>
  70. </view>
  71. <navigator url="/pages-voice/myVoice">
  72. <view class="flex item-card">
  73. <image src="../../static/voice/mine-voice-icon.png" mode="widthFix" />
  74. <text class="label">我的语音</text>
  75. <view class="right-text look">
  76. <text>查看</text>
  77. <van-icon name="arrow"></van-icon>
  78. </view>
  79. </view>
  80. <view></view>
  81. </navigator>
  82. <view class="flex item-card" v-if="userInfo.status!='试用'">
  83. <image src="../../static/calendar.png" mode="widthFix" />
  84. <text class="label">服务截止日期</text>
  85. <text class="right-text" v-if="!(userInfo.status=='冻结'||(userInfo.status=='试用'&&userInfo.is_suspend==1))">{{lastTime}}</text>
  86. </view>
  87. </view>
  88. <!-- 弹窗 -->
  89. <van-popup :show="pupData.show" @close="pupData.show=false" :close-on-click-overlay="false">
  90. <view class="global-pup">
  91. <view class="content">
  92. <rich-text :nodes="pupData.content"></rich-text>
  93. </view>
  94. <view class="flex bot">
  95. <view @click="pupData.show=false">知道了</view>
  96. </view>
  97. </view>
  98. </van-popup>
  99. </view>
  100. </template>
  101. <script>
  102. const moment=require('@/utils/moment-with-locales.min')
  103. import {apiLastApplyRecord,apiApplyPermission} from '@/api/user'
  104. import {apiGetUnread} from '@/api/question'
  105. export default {
  106. computed: {
  107. lastTime(){
  108. let timeArr=[]
  109. this.userInfo.permission_list&&this.userInfo.permission_list.forEach(item=>{
  110. item.permission_list.forEach(item2=>{
  111. timeArr.push(new Date(item2.end_date))
  112. })
  113. })
  114. let maxTime=Math.max(...timeArr)
  115. if(timeArr.length===0){
  116. return ''
  117. }else{
  118. return moment(maxTime).format('YYYY.MM.DD')
  119. }
  120. }
  121. },
  122. data () {
  123. return {
  124. pupData:{
  125. show:false,
  126. content:'',//弹窗html字符串
  127. },
  128. questionUnread:0
  129. }
  130. },
  131. onShow() {
  132. this.$store.dispatch('getUserInfo')
  133. this.getQuestionUnread()
  134. },
  135. methods: {
  136. async handleGoApplyPermission(){
  137. const res=await apiLastApplyRecord({source:1})
  138. if(res.code===200){
  139. if(!res.data){
  140. // 流失客户主动申请一次
  141. if(this.userInfo.status=='流失'){
  142. apiApplyPermission({
  143. company_name:this.userInfo.company_name,
  144. real_name:this.userInfo.real_name,
  145. source:1,
  146. from_page:'我的'
  147. }).then(res=>{
  148. if(res.code===200){
  149. console.log('主动申请成功');
  150. this.pupData.show=true
  151. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  152. }
  153. })
  154. return
  155. }
  156. uni.navigateTo({
  157. url:"/pages-applyPermission/applyPermission?source=1&from_page=我的"
  158. })
  159. }else{
  160. this.pupData.show=true
  161. this.pupData.content=`<p>您已提交过申请,请耐心等待</p>`
  162. // uni.navigateTo({
  163. // url:"/pages-applyPermission/applyResult"
  164. // })
  165. }
  166. }
  167. },
  168. handleToUserPermission(){
  169. if(this.userInfo.permission_list.length==0) return
  170. uni.navigateTo({ url: '/pages-user/permissionList' })
  171. },
  172. /* 消息通知页 */
  173. toMessageHadle() {
  174. uni.navigateTo({ url: '/pages-user/messageList' })
  175. },
  176. /* 我的设置 */
  177. toMySetting() {
  178. uni.navigateTo({ url: '/pages-user/mysetting' })
  179. },
  180. handleToQuestionPage(){
  181. uni.navigateTo({url:'/pages-question/answerList'})
  182. },
  183. handleContact(){
  184. apiApplyPermission({
  185. company_name:this.userInfo.company_name,
  186. real_name:this.userInfo.real_name,
  187. source:1,
  188. from_page:'我的'
  189. }).then(res=>{
  190. if(res.code===200){
  191. console.log('主动申请成功');
  192. }
  193. })
  194. uni.makePhoneCall({
  195. phoneNumber: this.userInfo.seal_mobile
  196. });
  197. },
  198. getQuestionUnread(){
  199. apiGetUnread().then(
  200. res=>{
  201. if(res.code===200){
  202. this.questionUnread = res.data
  203. }
  204. }
  205. )
  206. }
  207. }
  208. }
  209. </script>
  210. <style>
  211. page{
  212. padding-bottom: 0;
  213. }
  214. </style>
  215. <style lang="scss">
  216. .user-page{
  217. min-height: 100vh;
  218. /* min-height: calc(100vh - calc(50px + constant(safe-area-inset-bottom)));
  219. min-height: calc(100vh - calc(50px + env(safe-area-inset-bottom))); */
  220. background-color: #EDEDED;
  221. }
  222. .top-box{
  223. height: 392rpx;
  224. background-color: #fff;
  225. padding: 98rpx 50rpx 0 50rpx;
  226. .avatar{
  227. width: 154rpx;
  228. height: 154rpx;
  229. border-radius: 50%;
  230. // overflow: hidden;
  231. margin-right: 40rpx;
  232. position: relative;
  233. .avatar_ico {
  234. width: 40rpx;
  235. height: 40rpx;
  236. position: absolute;
  237. bottom: 0;
  238. right: 0;
  239. z-index: 2;
  240. }
  241. }
  242. .user-name{
  243. font-size: 24px;
  244. font-weight: bold;
  245. color: #060606;
  246. }
  247. .tel{
  248. color: #999;
  249. }
  250. .company{
  251. margin-top: 50rpx;
  252. image{
  253. width: 32rpx;
  254. height: 32rpx;
  255. margin-right: 8rpx;
  256. }
  257. color:#DBA665;
  258. }
  259. .nick-name {
  260. font-size: 28rpx;
  261. margin: 20rpx 0;
  262. }
  263. }
  264. .content{
  265. background-color: #fff;
  266. margin-top: 12rpx;
  267. padding: 0 34rpx;
  268. .item-card{
  269. position: relative;
  270. padding: 30rpx 0;
  271. border-bottom: 1px solid $global-border-color;
  272. image{
  273. width: 36rpx;
  274. height: 36rpx;
  275. }
  276. .label{
  277. font-weight: bold;
  278. margin-left: 20rpx;
  279. }
  280. .apply-btn{
  281. position: absolute;
  282. top: 50%;
  283. right: 0;
  284. transform: translateY(-50%);
  285. height: 50rpx;
  286. width: 156rpx;
  287. }
  288. .right-text{
  289. position: absolute;
  290. top: 50%;
  291. right: 0;
  292. transform: translateY(-50%);
  293. color: #666666;
  294. }
  295. .look{
  296. width: 100rpx;
  297. height: 100rpx;
  298. text-align: right;
  299. line-height: 100rpx;
  300. display: flex;
  301. align-items: center;
  302. justify-content: flex-end;
  303. .hint{
  304. width:30rpx;
  305. height:30rpx;
  306. background-color: #FF0000FF;
  307. color:#fff;
  308. font-size: 20rpx;
  309. text-align: center;
  310. line-height: 30rpx;
  311. border-radius: 50%;
  312. display: inline-block;
  313. }
  314. }
  315. .unread-ico {
  316. width: 30rpx;
  317. height: 30rpx;
  318. display: inline-block;
  319. border-radius: 50%;
  320. color: #ffff;
  321. background: #D62020;
  322. line-height: 30rpx;
  323. text-align: center;
  324. font-size: 24rpx;
  325. margin-left: 20rpx;
  326. }
  327. }
  328. .item-card:last-child{
  329. border: none;
  330. }
  331. }
  332. </style>