my.vue 7.2 KB

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