drawer.nvue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div>
  3. <scroller :style="{ height: systemInfo.windowHeight + 'px' }">
  4. <view class="drawerBg">
  5. <image style="width: 750rpx;height: 672rpx;"
  6. src="../../../static/sidebar_white.png"></image>
  7. </view>
  8. <view class="blank-space"></view>
  9. <view class="flex justify-center align-center ">
  10. <view style="width: 146rpx;height: 146rpx; border-radius: 45px;">
  11. <image class="avatar-img bg-black" mode="aspectFit" :src="avatarUrl">
  12. </image>
  13. </view>
  14. <view class="flex flex-direction-row align-center margin-12px " @tap="onNavEditInfoPage">
  15. <text class="text-22px text-bold">{{userName}}
  16. </text>
  17. <image style="width: 34rpx;height: 34rpx; margin-left: 22rpx;" src="/static/sideEdit.png"></image>
  18. </view>
  19. </view>
  20. <view class="flex justify-center align-center position-relative" style="height: 256rpx;">
  21. <view class="pos-top-center ">
  22. <image class="bg-days" src="../../../static/bg-days.png"></image>
  23. </view>
  24. <text class="text-12px text-right text-white bg-days-text">{{days}}天</text>
  25. <text
  26. class="text-more text-13px text-gray text-cut text-lines1 margin-12px ">{{signature!=='null'?signature:'111111111'}}</text>
  27. </view>
  28. <list class="list-wrapper">
  29. <cell v-for="item in lists" :key="item.id">
  30. <div class="text-wrapper" @click="clickitem(item.id,item.page_type)">
  31. <view class="flex flex-direction-row align-center">
  32. <image style="width: 34rpx;height:34rpx; margin-right: 36rpx;" :src="item.url"></image>
  33. <text class="text-15px text-medium">{{item.name}}</text>
  34. </view>
  35. <text class="icon">&#xe583;</text>
  36. </div>
  37. </cell>
  38. </list>
  39. <div class="flex justify-center align-center" style="margin-top: 140rpx; margin-bottom: 140rpx">
  40. <div class="close-drawer" @click="onExit">
  41. <text class="text-16px" style="color: #6B6B6B;">退出登录</text>
  42. </div>
  43. </div>
  44. </scroller>
  45. </div>
  46. </template>
  47. <script>
  48. import sideBarData from '@/components/side-bar/sideBar.js';
  49. import {
  50. mapState,
  51. mapMutations
  52. } from 'vuex';
  53. export default {
  54. computed: mapState(['bCanvasShow', 'token', 'userName', 'avatarUrl', 'days', 'signature', 'weight',
  55. 'height','systemInfo'
  56. ]),
  57. data() {
  58. return {
  59. lists: sideBarData.getSideBarList,
  60. signature: null
  61. }
  62. },
  63. beforeCreate() {
  64. const domModule = weex.requireModule('dom')
  65. domModule.addRule('fontFace', {
  66. fontFamily: "unibtn",
  67. 'src': "url('../../../static/font/uni.ttf')"
  68. });
  69. },
  70. created() {
  71. // for (let i = 0; i < 5; i++) {
  72. // this.lists.push({
  73. // id: i,
  74. // name: 'Item' + i,
  75. // });
  76. // }
  77. },
  78. methods: {
  79. ...mapMutations(['loginUserInfo', 'onLuanchLogin', 'delectToken']),
  80. hideDrawer() {
  81. uni.getCurrentSubNVue().hide('auto')
  82. },
  83. clickitem(e,_pageType) {
  84. // uni.$emit('drawer-page', e);
  85. this.onNavListItem(_pageType);
  86. },
  87. // 跳转编辑信息页面
  88. onNavEditInfoPage() {
  89. uni.navigateTo({
  90. url: '../../my-page/userInfo/userInfo',
  91. success: res => {},
  92. fail: () => {},
  93. complete: () => {}
  94. });
  95. },
  96. //侧边栏对应页面跳转
  97. onNavListItem(pageType) {
  98. // console.log(pageType);
  99. if (pageType == "my") {
  100. this.onNavMyPage();
  101. return;
  102. }
  103. // return;
  104. let url = '';
  105. switch (pageType) {
  106. case "recently":
  107. case "watchGame":
  108. url = '/pages/personal-page/list/list?type=' + pageType;
  109. break;
  110. case "ranking":
  111. url = '/pages/game-page/game-ranking/game-ranking';
  112. break;
  113. case "feedback":
  114. url = '/pages/login-page/feedback/feedback';
  115. break;
  116. case "friend":
  117. url = '/pages/friend-page/main/main';
  118. break;
  119. }
  120. uni.navigateTo({
  121. url: url,
  122. success: res => {},
  123. fail: () => {},
  124. complete: () => {}
  125. });
  126. },
  127. /**
  128. * 退出登录
  129. */
  130. onExit() {
  131. console.log("退出登录");
  132. // 清除token,退回首页
  133. this.delectToken({
  134. success: (res) => {
  135. uni.reLaunch({
  136. url: '../../login-page/login/login'
  137. })
  138. }
  139. });
  140. }
  141. }
  142. }
  143. </script>
  144. <style src="@/util/util-css/main-nvue.css"></style>
  145. <style>
  146. .wrapper {
  147. flex-direction: column;
  148. flex: 1;
  149. text-align: center;
  150. padding: 60rpx 0rpx 0rpx 0rpx;
  151. background-color: #FFFFFF;
  152. }
  153. .drawerBg {
  154. position: absolute;
  155. top: 0;
  156. right: 0;
  157. /* bottom: 0; */
  158. left: 0;
  159. justify-content: center;
  160. align-items: center;
  161. }
  162. .blank-space {
  163. height: 150rpx;
  164. }
  165. .avatar-img {
  166. width: 146rpx;
  167. height: 146rpx;
  168. /* border: 8rpx solid rgba(255, 255, 255, 1); */
  169. border-radius: 50%;
  170. }
  171. .bg-days {
  172. width: 126rpx;
  173. height: 48rpx;
  174. }
  175. .bg-days-text {
  176. height: 48rpx;
  177. width: 110rpx;
  178. line-height: 48rpx;
  179. }
  180. .text-more {
  181. width: 200px;
  182. line-height: 13px;
  183. height: 13px;
  184. }
  185. /* 自定义导航栏的图片大小 */
  186. .png-more {
  187. width: 20px;
  188. height: 20px;
  189. }
  190. .nav-text {
  191. color: #8f8f94;
  192. /* #ifndef APP-PLUS-NVUE */
  193. margin-bottom: 40px;
  194. /* #endif */
  195. /* #ifdef APP-PLUS-NVUE */
  196. margin-bottom: 40rpx;
  197. /* #endif */
  198. }
  199. .list-wrapper {
  200. /* margin-top: 120rpx; */
  201. height: 540rpx;
  202. /* #ifdef APP-PLUS-NVUE */
  203. /* height: 500rpx; */
  204. /* #endif */
  205. /* #ifndef APP-PLUS-NVUE */
  206. /* height: 500px; */
  207. /* #endif */
  208. }
  209. .text-wrapper {
  210. justify-content: center;
  211. /* border-bottom-style: solid;
  212. border-bottom-width: 1rpx;
  213. border-bottom-color: rgba(0, 0, 0, .2); */
  214. margin-bottom: 54rpx;
  215. margin-left: 140rpx;
  216. margin-right: 98rpx;
  217. /* padding-bottom: 15rpx; */
  218. }
  219. .close-drawer {
  220. display: flex;
  221. justify-content: center;
  222. /* align-content: center; */
  223. align-items: center;
  224. background-color: #f8f8f8;
  225. width: 300rpx;
  226. padding: 15rpx;
  227. border-radius: 40rpx;
  228. border-style: solid;
  229. border-width: 1rpx;
  230. border-color: rgba(229, 229, 229, 1);
  231. }
  232. .icon {
  233. position: absolute;
  234. right: 0;
  235. color: #D1D1D1;
  236. font-family: unibtn;
  237. font-size: 30rpx;
  238. font-weight: 400;
  239. }
  240. </style>