side-bar.vue 9.5 KB

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