drawer.nvue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div>
  3. <scroller :style="{ height: systemInfo.windowHeight + 'px' }">
  4. <view class="drawerBg">
  5. <image style="width: 750rpx;height: 672rpx;" src="../../../static/sidebar_white.png"></image>
  6. </view>
  7. <view class="blank-space"></view>
  8. <view class="flex justify-center align-center " @tap="onNavEditInfoPage">
  9. <view style="width: 146rpx;height: 146rpx; border-radius: 45px;">
  10. <image class="avatar-img bg-black" mode="aspectFit" :src="avatarUrl">
  11. </image>
  12. </view>
  13. <view class="flex flex-direction-row align-center margin-12px ">
  14. <text class="text-22px text-bold">{{userName}}
  15. </text>
  16. <image style="width: 34rpx;height: 34rpx; margin-left: 22rpx;" src="/static/sideEdit.png"></image>
  17. </view>
  18. </view>
  19. <view class="flex justify-center align-center position-relative" style="height: 256rpx;">
  20. <view class="position-absolute-center-top">
  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. </view>
  26. <text class="text-more text-13px text-grey text-cut text-lines1">{{signature!=='null'?signature:''}}</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. }
  61. },
  62. beforeCreate() {
  63. const domModule = weex.requireModule('dom')
  64. domModule.addRule('fontFace', {
  65. fontFamily: "unibtn",
  66. 'src': "url('../../../static/font/uni.ttf')"
  67. });
  68. },
  69. created() {
  70. // for (let i = 0; i < 5; i++) {
  71. // this.lists.push({
  72. // id: i,
  73. // name: 'Item' + i,
  74. // });
  75. // }
  76. },
  77. methods: {
  78. ...mapMutations(['loginUserInfo', 'onLuanchLogin', 'delectToken', 'showPopupById']),
  79. hideDrawer(callback) {
  80. uni.getCurrentSubNVue().hide('auto', 200);
  81. setTimeout(() => {
  82. if (callback)
  83. callback();
  84. }, 300)
  85. },
  86. clickitem(e, _pageType) {
  87. // uni.$emit('drawer-page', e);
  88. this.onNavListItem(_pageType);
  89. },
  90. // 跳转编辑信息页面
  91. onNavEditInfoPage() {
  92. this.hideDrawer(() => {
  93. uni.navigateTo({
  94. url: '../../my-page/userInfo/userInfo',
  95. success: res => {},
  96. fail: () => {},
  97. complete: () => {}
  98. });
  99. });
  100. },
  101. //侧边栏对应页面跳转
  102. onNavListItem(pageType) {
  103. this.hideDrawer(() => {
  104. if (pageType == "my") {
  105. this.onNavMyPage();
  106. return;
  107. }
  108. if (pageType == "signBoard") {
  109. this.showPopupById({
  110. type: 'signIn',
  111. item: null
  112. });
  113. return;
  114. }
  115. let url = '';
  116. switch (pageType) {
  117. case "recently":
  118. case "watchGame":
  119. url = '/pages/personal-page/list/list?type=' + pageType;
  120. break;
  121. case "ranking":
  122. url = '/pages/game-page/game-ranking/game-ranking';
  123. break;
  124. case "settings":
  125. url = '/pages/platform-page/settings/settings';
  126. break;
  127. case "friend":
  128. url = '/pages/friend-page/main/main';
  129. break;
  130. }
  131. uni.navigateTo({
  132. url: url,
  133. success: res => {},
  134. fail: () => {},
  135. complete: () => {}
  136. });
  137. });
  138. },
  139. /**
  140. * 退出登录
  141. */
  142. onExit() {
  143. uni.showToast({
  144. title: '正在退出登录...',
  145. icon: 'loading',
  146. mask: true,
  147. duration: 5000
  148. })
  149. this.hideDrawer(() => {
  150. // 清除token,退回首页
  151. this.delectToken({
  152. success: (res) => {
  153. uni.hideToast();
  154. uni.reLaunch({
  155. url: '../../login-page/login/login'
  156. })
  157. }
  158. });
  159. });
  160. }
  161. }
  162. }
  163. </script>
  164. <style>
  165. .wrapper {
  166. flex-direction: column;
  167. flex: 1;
  168. text-align: center;
  169. padding: 60rpx 0rpx 0rpx 0rpx;
  170. background-color: #FFFFFF;
  171. }
  172. .drawerBg {
  173. position: absolute;
  174. top: 0;
  175. right: 0;
  176. /* bottom: 0; */
  177. left: 0;
  178. justify-content: center;
  179. align-items: center;
  180. }
  181. .blank-space {
  182. height: 150rpx;
  183. }
  184. .avatar-img {
  185. width: 146rpx;
  186. height: 146rpx;
  187. /* border: 8rpx solid rgba(255, 255, 255, 1); */
  188. border-radius: 50%;
  189. }
  190. .bg-days {
  191. width: 126rpx;
  192. height: 48rpx;
  193. }
  194. .bg-days-text {
  195. height: 48rpx;
  196. width: 110rpx;
  197. line-height: 48rpx;
  198. }
  199. .text-more {
  200. width: 200px;
  201. line-height: 20px;
  202. height: 20px;
  203. }
  204. /* 自定义导航栏的图片大小 */
  205. .png-more {
  206. width: 20px;
  207. height: 20px;
  208. }
  209. .nav-text {
  210. color: #8f8f94;
  211. /* #ifndef APP-PLUS-NVUE */
  212. margin-bottom: 40px;
  213. /* #endif */
  214. /* #ifdef APP-PLUS-NVUE */
  215. margin-bottom: 40rpx;
  216. /* #endif */
  217. }
  218. .list-wrapper {
  219. /* margin-top: 120rpx; */
  220. height: 540rpx;
  221. /* #ifdef APP-PLUS-NVUE */
  222. /* height: 500rpx; */
  223. /* #endif */
  224. /* #ifndef APP-PLUS-NVUE */
  225. /* height: 500px; */
  226. /* #endif */
  227. }
  228. .text-wrapper {
  229. justify-content: center;
  230. /* border-bottom-style: solid;
  231. border-bottom-width: 1rpx;
  232. border-bottom-color: rgba(0, 0, 0, .2); */
  233. margin-bottom: 54rpx;
  234. margin-left: 140rpx;
  235. margin-right: 98rpx;
  236. /* padding-bottom: 15rpx; */
  237. }
  238. .close-drawer {
  239. display: flex;
  240. justify-content: center;
  241. /* align-content: center; */
  242. align-items: center;
  243. background-color: #f8f8f8;
  244. width: 300rpx;
  245. padding: 15rpx;
  246. border-radius: 40rpx;
  247. border-style: solid;
  248. border-width: 1rpx;
  249. border-color: rgba(229, 229, 229, 1);
  250. }
  251. .icon {
  252. position: absolute;
  253. right: 0;
  254. color: #D1D1D1;
  255. font-family: unibtn;
  256. font-size: 30rpx;
  257. font-weight: 400;
  258. }
  259. </style>