myinfo.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="myinfo">
  3. <!-- 顶部信息 -->
  4. <view class="myinfo_top">
  5. <view class="userImg">
  6. <u--image width='128rpx' height="128rpx" :src="myinfo.img" shape="circle"></u--image>
  7. </view>
  8. <view @click="tologin()" class="myinfo_text">
  9. <view class="myinfo_name">
  10. <text class="userName" >{{myinfo.name}}</text>
  11. <!-- <view class="myinfo_id">
  12. id:{{myinfo.id}}
  13. </view> -->
  14. </view>
  15. <!-- <view class="myinfo_qm">
  16. {{myinfo.qm}}
  17. </view> -->
  18. </view>
  19. <view @click="toUserInfo()">
  20. <u--image width="40rpx" height="40rpx" src="/static/myinfo/iconm_bianj.png" ></u--image>
  21. </view>
  22. </view>
  23. <!-- 中段菜单 -->
  24. <view class="myinfo_menus">
  25. <view class="myinfo_title">
  26. 常用功能
  27. </view>
  28. <view class="menus">
  29. <view v-for="item in list" :key="item.id">
  30. <view class="menus_item" @click="openLink(item)">
  31. <u-badge v-if="item.name == '我的订单'" :absolute="true" :offset='offset'
  32. numberType="overflow" type="error" max="99" :value="myinfo.orderCount"></u-badge>
  33. <u--image width="64rpx" height="64rpx" :src="item.url" ></u--image>
  34. {{item.name}}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 下段菜单 -->
  40. <view class="myinfo_menus">
  41. <view class="myinfo_title">
  42. 其他
  43. </view>
  44. <view class="menus_foot">
  45. <view @click="openLink(item)" v-for="item in list2" :key="item.id">
  46. <view class="menus_foot_item">
  47. <view style="display: flex;align-items: center;">
  48. <u--image width="48rpx" height="48rpx" :src="item.url" ></u--image>
  49. <view style="margin-left: 20rpx;">{{item.name}}</view>
  50. </view>
  51. <u--image width="48rpx" height="48rpx" src="/static/myinfo/btn_right.png" ></u--image>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {myInfo} from '@/http/api/common.js'
  60. export default {
  61. data() {
  62. return {
  63. offset:[-10,-10],
  64. myinfo:{
  65. name:'未登录',
  66. id:'0',
  67. qm:'无',
  68. orderCount:'0',
  69. img:'https://cdn.uviewui.com/uview/album/1.jpg',
  70. },
  71. list:[
  72. {
  73. id:1,
  74. url:'/static/myinfo/iconm_xiaoxi.png',
  75. name:'消息中心',
  76. linkto:'/pages/myinfo/notifiesPage'
  77. },
  78. {
  79. id:2,
  80. url:'/static/myinfo/iconm_gouwu.png',
  81. name:'购物车',
  82. openType:'switchTab',
  83. linkto:'/pages/market/market'
  84. },
  85. {
  86. id:3,
  87. url:'/static/myinfo/icon_dingdang.png',
  88. name:'我的订单',
  89. linkto:'/pages/market/allOrder'
  90. },
  91. {
  92. id:4,
  93. url:'/static/myinfo/icomm_jilu.png',
  94. name:'浏览记录',
  95. linkto:'/pages/market/BrowsingHistory?showType=jilu'
  96. },
  97. ],
  98. list2:[
  99. {
  100. id:1,
  101. url:'/static/myinfo/icomx_souc.png',
  102. name:'我的收藏',
  103. linkto:'/pages/market/BrowsingHistory?showType=shouchang'
  104. },
  105. {
  106. id:2,
  107. url:'/static/myinfo/icomx_dizhi.png',
  108. name:'我的地址',
  109. linkto:'/pages/myinfo/address'
  110. },
  111. {
  112. id:3,
  113. url:'/static/myinfo/icomx_message.png',
  114. name:'意见反馈',
  115. linkto:'/pages/myinfo/userInfo?showType=fangkui'
  116. },
  117. // {
  118. // id:4,
  119. // url:'/static/myinfo/iconx_xitongg.png',
  120. // name:'设置'
  121. // },
  122. ]
  123. }
  124. },
  125. onShow() {
  126. if(uni.getStorageSync('AppAuthorization')){
  127. // 获取个人信息
  128. this.getmyInfo()
  129. }
  130. },
  131. methods: {
  132. async getmyInfo(){
  133. let res = await myInfo()
  134. if (res.data.code == 200) {
  135. this.myinfo.name = res.data.data.nickName
  136. this.myinfo.img = res.data.data.image
  137. this.myinfo.orderCount = res.data.data?.orderCount || 0
  138. }
  139. },
  140. tologin(){
  141. if(uni.getStorageSync('AppAuthorization')){
  142. //登录
  143. return
  144. }
  145. uni.navigateTo({
  146. url: '/pages/myinfo/login'
  147. });
  148. },
  149. toUserInfo(){
  150. uni.navigateTo({
  151. url: '/pages/myinfo/userInfo'
  152. });
  153. },
  154. openLink(data){
  155. console.log(data.name,data.openType);
  156. if (data?.linkto) {
  157. if (data.openType == 'switchTab') {
  158. uni.switchTab({
  159. url: data.linkto
  160. });
  161. }else{
  162. uni.navigateTo({
  163. url: data.linkto
  164. });
  165. }
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style>
  172. .myinfo{
  173. background: linear-gradient(180deg, #D3E5FF 0%, rgba(246,246,246,0.2) 100%);
  174. }
  175. .userImg{
  176. width: 128rpx;
  177. height: 128rpx;
  178. }
  179. .userName{
  180. min-width: 64rpx;
  181. height: 45rpx;
  182. font-size: 32rpx;
  183. font-weight: bold;
  184. color: #333333;
  185. line-height: 36rpx;
  186. }
  187. .myinfo_top{
  188. display: flex;
  189. width: 90vw;
  190. margin: 0 auto;
  191. align-items: center;
  192. padding-top: 40rpx;
  193. }
  194. .myinfo_text{
  195. margin-left: 40rpx;
  196. min-width: 460rpx;
  197. }
  198. .myinfo_name{
  199. display: flex;
  200. align-items: center;
  201. }
  202. .myinfo_id{
  203. margin-left: 20rpx;
  204. width: 145rpx;
  205. height: 40rpx;
  206. background: linear-gradient(180deg, #46A6FF 0%, #96CBFB 100%);
  207. border-radius: 24rpx 24rpx 24rpx 24rpx;
  208. opacity: 1;
  209. text-align: center;
  210. font-size: 24rpx;
  211. font-weight: 400;
  212. color: #FFFFFF;
  213. line-height: 36rpx;
  214. }
  215. .myinfo_qm{
  216. height: 40rpx;
  217. font-size: 28rpx;
  218. font-weight: 400;
  219. color: #999999;
  220. line-height: 36rpx;
  221. }
  222. .myinfo_menus{
  223. width: 90vw;
  224. margin: 0 auto;
  225. background-color: white;
  226. margin-top: 40rpx;
  227. border-radius: 24rpx 24rpx 24rpx 24rpx;
  228. opacity: 1;
  229. }
  230. .myinfo_title{
  231. font-size: 40rpx;
  232. padding: 30rpx 0 30rpx 40rpx;
  233. width: 128rpx;
  234. height: 45rpx;
  235. font-size: 32rpx;
  236. font-weight: bold;
  237. color: #333333;
  238. line-height: 45rpx;
  239. }
  240. .menus_item{
  241. display: flex;
  242. flex-direction: column;
  243. align-items: center;
  244. font-size: 28rpx;
  245. font-weight: 400;
  246. color: #333333;
  247. line-height: 36rpx;
  248. position: relative
  249. }
  250. .menus{
  251. padding-bottom: 40rpx;
  252. display: flex;
  253. justify-content: space-around;
  254. }
  255. .menus_foot{
  256. width: 90%;
  257. margin: 0 auto;
  258. }
  259. .menus_foot_item{
  260. display: flex;
  261. align-items: center;
  262. height: 100rpx;
  263. justify-content: space-between;
  264. }
  265. </style>