my.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="my-box">
  3. <view class="my-content">
  4. <view class="my-top"></view>
  5. <image class="my-avatar" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')" :src="user.portrait"
  6. mode="aspectFill"></image>
  7. <view class="name" @tap="$navigateTo('/subPages/myPage/myDetail/myDetail')">{{user.userName || '登录/注册'}}
  8. </view>
  9. <view class="organization" v-if="user.organizedName"
  10. @tap="$navigateTo('/subPages/myPage/changeOrganization/changeOrganization')">
  11. {{user.organizedName}}
  12. </view>
  13. <view class="my-list">
  14. <view class="my-list-box">
  15. <view class="my-item" @tap="$navigateTo('/subPages/shopPage/webview/webview?url=/order')">
  16. <view class="my-icon bg3">
  17. <uv-icon name="home-fill" color="#fff" size="56"></uv-icon>
  18. </view>
  19. <view class="item-content">
  20. 商城订单
  21. </view>
  22. <view class="my-forward">
  23. <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
  24. </view>
  25. </view>
  26. <view class="my-item" @tap="$navigateTo('/subPages/myPage/organization/organization')">
  27. <view class="my-icon bg3">
  28. <uv-icon name="home-fill" color="#fff" size="56"></uv-icon>
  29. </view>
  30. <view class="item-content">
  31. 我的公司
  32. </view>
  33. <view class="my-forward">
  34. <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
  35. </view>
  36. </view>
  37. <view class="my-item" @tap="$navigateTo('/subPages/myPage/download/download')">
  38. <view class="my-icon bg5">
  39. <uv-icon name="grid-fill" color="#fff" size="56"></uv-icon>
  40. </view>
  41. <view class="item-content">
  42. 我的下载
  43. </view>
  44. <view class="my-forward">
  45. <uv-icon name="arrow-right" color="#c1c0c8" size="32"></uv-icon>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="fab-box" v-if="isCustomer" @click="$navigateTo('/subPages/myPage/chatList/chatList')">
  52. <view class="fab-data">
  53. <uv-badge type="error" max="99" numberType="overflow" :value="badge" :absolute="true" :offset="[0,0]"
  54. :customStyle="{
  55. zIndex:99
  56. }">
  57. </uv-badge>
  58. <uv-icon name="server-fill" color="#fff" size="60" labelPos="bottom" labelSize="20">
  59. </uv-icon>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. getUserInfoById,
  67. getCustomerServeListByQuery
  68. } from '@/request/api/my.js'
  69. export default {
  70. data() {
  71. return {
  72. user: {},
  73. isCustomer: false,
  74. badge: 0
  75. }
  76. },
  77. onReady() {
  78. uni.$on('changeChatList', this.initChat);
  79. },
  80. onShow() {
  81. this.initBadge();
  82. if (!uni.getStorageSync('token')) {
  83. this.user = {};
  84. this.isCustomer = false;
  85. } else {
  86. this.user = this.$store.getters.user;
  87. this.user.organizedName = this.$store.getters.organization && this.$store.getters.organization.name;
  88. this.init();
  89. this.initCustomerServe();
  90. }
  91. },
  92. methods: {
  93. async init() {
  94. let userInfo = await getUserInfoById(this.user.userId);
  95. if (userInfo.state) {
  96. this.user['userName'] = userInfo.data.name;
  97. this.user['userId'] = userInfo.data.id;
  98. this.user['portrait'] = userInfo.data.portrait;
  99. this.$store.dispatch('app/changeUser', this.user);
  100. }
  101. },
  102. async initCustomerServe() {
  103. let customerServe = await getCustomerServeListByQuery({
  104. organizationId: this.$store.getters.organization.id,
  105. userId: this.$store.getters.user.userId
  106. })
  107. if (customerServe.state && customerServe.data && customerServe.data.length > 0) {
  108. let data = customerServe.data[0];
  109. this.isCustomer = true;
  110. uni.setStorageSync('serveChatId', data.customerId);
  111. this.$customerServe.connect(data.customerId);
  112. this.initChat();
  113. }
  114. },
  115. initChat() {
  116. this.$customerServe.getConversationList(data => {
  117. let chatList = data.data.filter(node => node.conversationId !== 'system');
  118. let badge = 0;
  119. for (let i = 0; i < chatList.length; i++) {
  120. badge += chatList[i].unread
  121. }
  122. this.badge = badge;
  123. });
  124. },
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .my-box {
  130. height: 100vh;
  131. background: #fff;
  132. overflow-y: auto;
  133. .my-content {
  134. display: flex;
  135. flex-direction: column;
  136. align-items: center;
  137. padding-bottom: 80rpx;
  138. }
  139. .my-top {
  140. height: 260rpx;
  141. background-image: url('https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMDUzMDJ8MHwxfHNlYXJjaHw1fHxhYnN0cmFjdHxlbnwxfHx8fDE2NTI4OTYzNTU&ixlib=rb-1.2.1&q=80&w=1080');
  142. background-position: center center;
  143. background-size: cover;
  144. background-repeat: no-repeat;
  145. width: 100%;
  146. }
  147. .my-avatar {
  148. width: 200rpx;
  149. height: 200rpx;
  150. border-radius: 50%;
  151. margin-top: -100rpx;
  152. border: 6rpx solid #fff;
  153. background: #eee;
  154. }
  155. .name {
  156. font-size: 20px;
  157. font-weight: 700;
  158. margin: 10rpx 0;
  159. }
  160. .organization {
  161. font-weight: 300;
  162. }
  163. .my-list {
  164. width: 100%;
  165. padding: 60rpx 30rpx 30rpx 30rpx;
  166. box-sizing: border-box;
  167. .my-list-box {
  168. border-radius: 24rpx;
  169. box-shadow: 1px 1px 12px rgba(164, 164, 164, 0.25);
  170. overflow: hidden;
  171. }
  172. .my-item {
  173. display: flex;
  174. align-items: center;
  175. padding: 20rpx 30rpx;
  176. }
  177. .my-icon {
  178. width: 80rpx;
  179. height: 80rpx;
  180. border-radius: 16rpx;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. margin-right: 20rpx;
  185. background: #c1c0c8;
  186. &.bg1 {
  187. background: #88d498;
  188. }
  189. &.bg2 {
  190. background: #ffb997;
  191. }
  192. &.bg3 {
  193. background: #7ad9ff;
  194. }
  195. &.bg4 {
  196. background: #9ac0cd;
  197. }
  198. &.bg5 {
  199. background: #40e0d0;
  200. }
  201. }
  202. .item-content {
  203. flex: 1;
  204. width: 0;
  205. overflow: hidden;
  206. font-weight: 700;
  207. }
  208. }
  209. .fab-box {
  210. position: fixed;
  211. bottom: 60rpx;
  212. right: 30rpx;
  213. width: 100rpx;
  214. height: 100rpx;
  215. border-radius: 50%;
  216. background: $uv-primary;
  217. .fab-data {
  218. width: 100%;
  219. height: 100%;
  220. position: relative;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. }
  225. }
  226. }
  227. </style>