user.vue 9.2 KB

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