drawer.nvue 6.4 KB

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