my.vue 6.5 KB

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