side-bar.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <!-- @touchmove.stop.prevent="moveHandle" -->
  3. <view class="content">
  4. <view class="side-left" :data-position="pos" :prop="pos" :change:prop="side.sizeReady" @touchstart="side.touchstart"
  5. @touchmove="side.touchmove" @touchend="side.touchend" @change="change">
  6. <!-- 侧边栏 bshow-->
  7. <view class="side-mask" v-if="bshow" @tap="closeSide"></view>
  8. <view class="side-handle">
  9. <view id="my-side-dialog" class="basis-xl bg-white selector-query-hock" :class="bOpen?'side-pointer':''" @tap.stop="">
  10. <scroll-view scroll-y="true" class="selector-query-hock" style="height: 100%;width: 100%;">
  11. <view class="cu-list menu text-left ">
  12. <view class="bg-image text-white" style="margin-bottom: 60rpx; padding-bottom: 60rpx;">
  13. <view class="blank-space"></view>
  14. <view class="flex-sub text-center">
  15. <view class="cu-avatar-group" style="position: relative; margin: 10rpx;">
  16. <view class="cu-avatar round " style="width: 146rpx;height: 146rpx;" :style="[{ backgroundImage:'url('+avatarUrl+')' }]"></view>
  17. </view>
  18. <!-- <view class="text-xsl">
  19. <image class="avatar-img bg-black" mode="aspectFit" :src="avatarUrl"></image>
  20. </view> -->
  21. <view class="flex justify-center align-center" @tap="onNavEditInfoPage">
  22. <view style="font-weight: bold; color: #000000; font-size: 22px;">{{userName}}</view>
  23. <image style="width: 34rpx;height: 34rpx; margin-left: 22rpx;" src="/static/sideEdit.png"></image>
  24. </view>
  25. </view>
  26. <view class="flex flex-direction justify-center align-center">
  27. <view class="bg-days margin">{{days}}天</view>
  28. <view class="text-more text-gray">
  29. {{signature!=='null'?signature:''}}
  30. </view>
  31. </view>
  32. </view>
  33. <view class="cu-item myarrow margin-view" v-for="(item,index) in sideList" :key="index" @tap="onNavListItem(item.page_type)">
  34. <view class="content flex align-center margin-top margin-bottom">
  35. <image :src="item.url" style="width: 34rpx;width: 34rpx; margin-bottom: 2rpx;margin-right:44rpx;" mode="aspectFit"></image>
  36. <text class="text-black text-16px text-bold">{{item.name}}</text>
  37. </view>
  38. </view>
  39. <view class="flex justify-center align-center " style="margin: 60px 0px;">
  40. <button class="cu-btn round text-16px line-mGrey" style="width: 250rpx; height: 80rpx;" @tap="onExit"> <span
  41. style="color:#000000;">退出登录</span> </button>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script src="./side-wxs.wxs" module="side" lang="wxs"></script>
  51. <script>
  52. import sideBarData from '@/components/side-bar/sideBar.js';
  53. import config from '@/common/config.js'
  54. import reqUtil from '@/util/util-js/requstUtil.js';
  55. import mp from './mp'
  56. import {
  57. mapState,
  58. mapMutations
  59. } from 'vuex'
  60. export default {
  61. mixins: [mp],
  62. computed: mapState(['bCanvasShow', 'token', 'userName', 'avatarUrl', 'days', 'signature', 'weight',
  63. 'height'
  64. ]),
  65. data() {
  66. return {
  67. sideList: sideBarData.getSideBarList,
  68. bshow: false,
  69. bOpen: false,
  70. left: 0,
  71. /**
  72. * 变量控制开关
  73. */
  74. show: {
  75. type: Boolean,
  76. default: false
  77. }
  78. }
  79. },
  80. mounted() {
  81. // console.log("******",this.bshow);
  82. },
  83. methods: {
  84. ...mapMutations(['loginUserInfo', 'onLuanchLogin', 'delectToken']),
  85. // 跳转我的页面
  86. onNavMyPage() {
  87. uni.navigateTo({
  88. url: '../../my-page/homepage/homepage',
  89. success: res => {},
  90. fail: () => {},
  91. complete: () => {}
  92. });
  93. },
  94. // 跳转编辑信息页面
  95. onNavEditInfoPage() {
  96. uni.navigateTo({
  97. url: '../../my-page/userInfo/userInfo',
  98. success: res => {},
  99. fail: () => {},
  100. complete: () => {}
  101. });
  102. },
  103. //侧边栏对应页面跳转
  104. onNavListItem(pageType) {
  105. // console.log(pageType);
  106. if (pageType == "my") {
  107. this.onNavMyPage();
  108. return;
  109. }
  110. // return;
  111. let url = '';
  112. switch (pageType) {
  113. case "recently":
  114. case "watchGame":
  115. url = '/pages/personal-page/list/list?type=' + pageType;
  116. break;
  117. case "ranking":
  118. url = '/pages/game-page/game-ranking/game-ranking';
  119. break;
  120. case "feedback":
  121. url = '/pages/login-page/feedback/feedback';
  122. break;
  123. }
  124. uni.navigateTo({
  125. url: url,
  126. success: res => {},
  127. fail: () => {},
  128. complete: () => {}
  129. });
  130. },
  131. /**
  132. * 退出登录
  133. */
  134. onExit() {
  135. console.log("退出登录");
  136. // 清除token,退回首页
  137. this.delectToken({
  138. success: (res) => {
  139. uni.reLaunch({
  140. url: '../../login-page/login/login'
  141. })
  142. }
  143. });
  144. },
  145. showModal() {
  146. // console.log("showModal:",this.show);
  147. this.bshow = true;
  148. this.show = true;
  149. },
  150. hideModal() {
  151. // console.log("hideModal");
  152. this.bshow = false;
  153. this.show = false;
  154. this.$store.state.bCanvasShow = true;
  155. this.$emit("hideSideBar");
  156. },
  157. change(e) {
  158. // console.log("side change:", e);
  159. if (e.close) {
  160. this.hideModal();
  161. this.bOpen = false;
  162. } else {
  163. this.bOpen = true;
  164. this.show = true;
  165. }
  166. },
  167. closeSide() {
  168. if (!this.bOpen) return;
  169. // console.log("close side.");
  170. this.show = false;
  171. },
  172. moveHandle() {}
  173. }
  174. }
  175. </script>
  176. <style>
  177. .blank-space {
  178. height: 150rpx;
  179. }
  180. .bg-image {
  181. background-size: cover;
  182. background-position: center;
  183. background-repeat: no-repeat;
  184. background-image: url(../../static/sidebar_white.png);
  185. opacity: 1;
  186. }
  187. .bg-days {
  188. background-size: cover;
  189. background-position: center;
  190. background-repeat: no-repeat;
  191. background-image: url(../../static/bg-days.png);
  192. opacity: 1;
  193. width: 126rpx;
  194. height: 48rpx;
  195. font-size: 11px;
  196. line-height: 48rpx;
  197. text-align: right;
  198. padding-right: 14rpx;
  199. }
  200. .avatar-img {
  201. width: 146rpx;
  202. height: 146rpx;
  203. /* border: 8rpx solid rgba(255, 255, 255, 1); */
  204. border-radius: 50%;
  205. }
  206. .text-more {
  207. /* width: 200px; */
  208. font-size: 12px;
  209. line-height: 20px;
  210. overflow: hidden;
  211. text-overflow: ellipsis;
  212. display: -webkit-box; //必须结合的属性,将对象作为弹性伸缩盒子模型显示
  213. -webkit-line-clamp: 2; //控制文本的行数
  214. -webkit-box-orient: vertical; //必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式 
  215. /* border: 1rpx solid #aaa; */
  216. }
  217. .text-cut {
  218. font-size: 14px;
  219. line-height: 30px;
  220. width: 100px;
  221. height: 100px;
  222. /* font-weight: bold; */
  223. border: 1rpx solid #aaa;
  224. display: -webkit-box;
  225. /* 允许任意非CJK(Chinese/Japanese/Korean)文本间的单词断行 */
  226. word-break: break-all;
  227. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  228. -webkit-box-orient: vertical;
  229. /* 可显示的最多行数 */
  230. -webkit-line-clamp: 2;
  231. /* 超出的文本内容隐藏 */
  232. overflow: hidden;
  233. /* 超出显示省略号 */
  234. text-overflow: ellipsis;
  235. /* background: rgba(0, 0, 0, 0.3); */
  236. }
  237. .margin-view {
  238. margin: 10px 114rpx 10px 70rpx;
  239. }
  240. .side-mask {
  241. display: flex;
  242. position: fixed;
  243. top: 0;
  244. right: 0;
  245. bottom: 0;
  246. left: 0;
  247. z-index: 1100;
  248. outline: 0;
  249. text-align: center;
  250. overflow-x: hidden;
  251. overflow-y: auto;
  252. backface-visibility: hidden;
  253. background: rgba(0, 0, 0, 0.6);
  254. opacity: 1;
  255. pointer-events: auto;
  256. }
  257. .side-handle {
  258. display: flex;
  259. position: fixed;
  260. top: 0;
  261. right: 0;
  262. bottom: 0;
  263. left: 0;
  264. z-index: 1110;
  265. outline: 0;
  266. text-align: center;
  267. backface-visibility: hidden;
  268. opacity: 1;
  269. pointer-events: none;
  270. }
  271. .side-opacity {
  272. opacity: 1;
  273. }
  274. .side-pointer {
  275. pointer-events: auto;
  276. }
  277. /* .side-handle::before {
  278. content: "\200B";
  279. display: inline-block;
  280. height: 100%;
  281. vertical-align: middle;
  282. } */
  283. .side-left {
  284. position: absolute;
  285. left: 0;
  286. top: 0;
  287. display: flex;
  288. /* border: 1rpx solid #007AFF; */
  289. width: 10px;
  290. height: 100%;
  291. z-index: 1110;
  292. }
  293. .ani {
  294. transition-property: transform;
  295. transition-duration: 0.3s;
  296. transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
  297. }
  298. /* 开始设置一个x偏移值 */
  299. #my-side-dialog {
  300. transform: translateX(-500px);
  301. -webkit-transform: translateX(-500px)
  302. }
  303. </style>