side-bar.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. }
  121. uni.navigateTo({
  122. url: url,
  123. success: res => {},
  124. fail: () => {},
  125. complete: () => {}
  126. });
  127. },
  128. /**
  129. * 退出登录
  130. */
  131. onExit() {
  132. console.log("退出登录");
  133. // 清除token,退回首页
  134. this.delectToken({
  135. success: (res) => {
  136. uni.reLaunch({
  137. url: '../../login-page/login/login'
  138. })
  139. }
  140. });
  141. },
  142. showModal() {
  143. // console.log("showModal:",this.show);
  144. this.bshow = true;
  145. this.show = true;
  146. },
  147. hideModal() {
  148. // console.log("hideModal");
  149. this.bshow = false;
  150. this.show = false;
  151. this.$store.state.bCanvasShow = true;
  152. this.$emit("hideSideBar");
  153. },
  154. change(e) {
  155. // console.log("side change:", e);
  156. if (e.close) {
  157. this.hideModal();
  158. this.bOpen = false;
  159. }else{
  160. this.bOpen = true;
  161. this.show = true;
  162. }
  163. },
  164. closeSide(){
  165. if(!this.bOpen)return;
  166. // console.log("close side.");
  167. this.show = false;
  168. },
  169. moveHandle(){}
  170. }
  171. }
  172. </script>
  173. <style>
  174. .blank-space {
  175. height: 150rpx;
  176. }
  177. .bg-image {
  178. background-size: cover;
  179. background-position: center;
  180. background-repeat: no-repeat;
  181. background-image: url(../../static/sidebar_white.png);
  182. opacity: 1;
  183. }
  184. .bg-days {
  185. background-size: cover;
  186. background-position: center;
  187. background-repeat: no-repeat;
  188. background-image: url(../../static/bg-days.png);
  189. opacity: 1;
  190. width: 126rpx;
  191. height: 48rpx;
  192. font-size: 11px;
  193. line-height: 48rpx;
  194. text-align: right;
  195. padding-right: 14rpx;
  196. }
  197. .avatar-img {
  198. width: 146rpx;
  199. height: 146rpx;
  200. /* border: 8rpx solid rgba(255, 255, 255, 1); */
  201. border-radius: 50%;
  202. }
  203. .text-more {
  204. /* width: 200px; */
  205. font-size: 12px;
  206. line-height: 20px;
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. display: -webkit-box; //必须结合的属性,将对象作为弹性伸缩盒子模型显示
  210. -webkit-line-clamp: 2; //控制文本的行数
  211. -webkit-box-orient: vertical; //必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式 
  212. /* border: 1rpx solid #aaa; */
  213. }
  214. .text-cut {
  215. font-size: 14px;
  216. line-height: 30px;
  217. width: 100px;
  218. height: 100px;
  219. /* font-weight: bold; */
  220. border: 1rpx solid #aaa;
  221. display: -webkit-box;
  222. /* 允许任意非CJK(Chinese/Japanese/Korean)文本间的单词断行 */
  223. word-break: break-all;
  224. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  225. -webkit-box-orient: vertical;
  226. /* 可显示的最多行数 */
  227. -webkit-line-clamp: 2;
  228. /* 超出的文本内容隐藏 */
  229. overflow: hidden;
  230. /* 超出显示省略号 */
  231. text-overflow: ellipsis;
  232. /* background: rgba(0, 0, 0, 0.3); */
  233. }
  234. .margin-view {
  235. margin: 10px 114rpx 10px 70rpx;
  236. }
  237. .side-mask{
  238. display: flex;
  239. position: fixed;
  240. top: 0;
  241. right: 0;
  242. bottom: 0;
  243. left: 0;
  244. z-index: 1100;
  245. outline: 0;
  246. text-align: center;
  247. overflow-x: hidden;
  248. overflow-y: auto;
  249. backface-visibility: hidden;
  250. background: rgba(0, 0, 0, 0.6);
  251. opacity:1;
  252. pointer-events: auto;
  253. }
  254. .side-handle {
  255. display: flex;
  256. position: fixed;
  257. top: 0;
  258. right: 0;
  259. bottom: 0;
  260. left: 0;
  261. z-index: 1110;
  262. outline: 0;
  263. text-align: center;
  264. backface-visibility: hidden;
  265. opacity:1;
  266. pointer-events: none;
  267. }
  268. .side-opacity{
  269. opacity:1;
  270. }
  271. .side-pointer{
  272. pointer-events: auto;
  273. }
  274. /* .side-handle::before {
  275. content: "\200B";
  276. display: inline-block;
  277. height: 100%;
  278. vertical-align: middle;
  279. } */
  280. .side-left {
  281. position: absolute;
  282. left: 0;
  283. top: 0;
  284. display: flex;
  285. /* border: 1rpx solid #007AFF; */
  286. width: 10px;
  287. height: 100%;
  288. z-index: 1110;
  289. }
  290. .ani {
  291. transition-property: transform;
  292. transition-duration: 0.3s;
  293. transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
  294. }
  295. /* 开始设置一个x偏移值 */
  296. #my-side-dialog{
  297. transform: translateX(-500px);
  298. -webkit-transform: translateX(-500px)
  299. }
  300. </style>