App.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <script>
  2. /**
  3. * vuex管理登陆状态,具体可以参考官方登陆模板示例
  4. */
  5. import {
  6. mapMutations,
  7. mapState
  8. } from 'vuex';
  9. export default {
  10. globalData:{
  11. toPage(e) {
  12. var query = e.currentTarget.dataset;
  13. var url = query['url'];
  14. delete query.url;
  15. console.log(url);
  16. console.log(query);
  17. var str = '';
  18. for (var k in query) {
  19. str = str + '&' + k + '=' + query[k];
  20. }
  21. console.log(str);
  22. url = url + '?' + str;
  23. console.log(url);
  24. uni.navigateTo({
  25. url
  26. });
  27. },
  28. },
  29. methods: {
  30. ...mapMutations(['login', 'logout', 'setUserInfo']),
  31. // #ifdef H5
  32. // 检查登录状态
  33. async checkLogin() {
  34. let user = uni.getStorageSync('userInfo');
  35. if (user) {
  36. this.login(user);
  37. } else {
  38. let result = await this.$api.request('/user/status');
  39. if (!result) {
  40. // 若没有登录则清空个人信息
  41. this.logout();
  42. }
  43. }
  44. },
  45. // #endif
  46. },
  47. onLaunch: function() {
  48. // 锁定屏幕竖向
  49. // #ifdef APP-PLUS
  50. plus.screen.lockOrientation('portrait-primary');
  51. // #endif
  52. },
  53. onShow: async function() {
  54. // 检查用户登录情况
  55. // #ifdef H5
  56. this.checkLogin();
  57. // #endif
  58. // #ifdef MP-WEIXIN
  59. const userInfo = await this.$wechatMiniLogin();
  60. this.login(userInfo)
  61. // #endif
  62. },
  63. onHide: function() {
  64. console.log('App Hide')
  65. },
  66. }
  67. </script>
  68. <style lang='scss'>
  69. /* project id 1729059 */
  70. @font-face {
  71. font-family: 'unishop';
  72. font-weight: normal;
  73. font-style: normal;
  74. src: url('https://at.alicdn.com/t/font_1729059_llr8d2acjac.ttf') format('truetype');
  75. }
  76. .yticon {
  77. font-family: "unishop" !important;
  78. font-size: 16px;
  79. font-style: normal;
  80. -webkit-font-smoothing: antialiased;
  81. -moz-osx-font-smoothing: grayscale;
  82. }
  83. .icon-shouhuodizhi:before{
  84. content: "\e6b5";
  85. }
  86. .icon-xuanzhong:before{
  87. content: "\e64c";
  88. }
  89. .icon-fenlei:before{
  90. content: "\e71b";
  91. }
  92. .icon-bianji:before{
  93. content: "\e77d";
  94. }
  95. .icon-jiahao:before{
  96. content: "\e616";
  97. }
  98. .icon-jianhao:before{
  99. content: "\e617";
  100. }
  101. .icon-wxpay:before{
  102. content: "\e607";
  103. }
  104. .icon-pay:before{
  105. content: "\e624";
  106. }
  107. .icon-alipay:before{
  108. content: "\e60b";
  109. }
  110. .icon-you:before{
  111. content: "\e65f";
  112. }
  113. .icon-huoche:before{
  114. content: "\e6f0";
  115. }
  116. .icon-shoucang:before{
  117. content: "\e60a";
  118. }
  119. .icon-gouwuche:before{
  120. content: "\e60e";
  121. }
  122. .icon-fangzi:before{
  123. content: "\e657";
  124. }
  125. .icon-daifukuan:before{
  126. content: "\e601";
  127. }
  128. .icon-daifahuo:before{
  129. content: "\e704";
  130. }
  131. .icon-daishouhuo:before{
  132. content: "\e62f";
  133. }
  134. .icon-pingjia:before{
  135. content: "\e61d";
  136. }
  137. .icon-shouhou:before{
  138. content:"\e610";
  139. }
  140. .icon-shoucang-setting:before{
  141. content:"\e612";
  142. }
  143. .icon-setting:before{
  144. content:"\e62b";
  145. }
  146. .icon-dizhi:before{
  147. content: "\e67c";
  148. }
  149. .icon-lajitong:before{
  150. content: "\e615";
  151. }
  152. view,
  153. scroll-view,
  154. swiper,
  155. swiper-item,
  156. cover-view,
  157. cover-image,
  158. icon,
  159. text,
  160. rich-text,
  161. progress,
  162. button,
  163. checkbox,
  164. form,
  165. input,
  166. label,
  167. radio,
  168. slider,
  169. switch,
  170. textarea,
  171. navigator,
  172. audio,
  173. camera,
  174. image,
  175. video {
  176. box-sizing: border-box;
  177. }
  178. /* 骨架屏替代方案 */
  179. .Skeleton {
  180. background: #f3f3f3;
  181. padding: 20upx 0;
  182. border-radius: 8upx;
  183. }
  184. /* 图片载入替代方案 */
  185. .image-wrapper {
  186. font-size: 0;
  187. background: #f3f3f3;
  188. border-radius: 4px;
  189. image {
  190. width: 100%;
  191. height: 100%;
  192. transition: .6s;
  193. opacity: 0;
  194. &.loaded {
  195. opacity: 1;
  196. }
  197. }
  198. }
  199. .clamp {
  200. overflow: hidden;
  201. text-overflow: ellipsis;
  202. white-space: nowrap;
  203. display: block;
  204. }
  205. .common-hover {
  206. background: #f5f5f5;
  207. }
  208. /*边框*/
  209. .b-b:after,
  210. .b-t:after {
  211. position: absolute;
  212. z-index: 3;
  213. left: 0;
  214. right: 0;
  215. height: 0;
  216. content: '';
  217. transform: scaleY(.5);
  218. border-bottom: 1px solid $border-color-base;
  219. }
  220. .b-b:after {
  221. bottom: 0;
  222. }
  223. .b-t:after {
  224. top: 0;
  225. }
  226. /* button样式改写 */
  227. uni-button,
  228. button {
  229. height: 80upx;
  230. line-height: 80upx;
  231. font-size: $font-lg + 2upx;
  232. font-weight: normal;
  233. &.no-border:before,
  234. &.no-border:after {
  235. border: 0;
  236. }
  237. }
  238. uni-button[type=default],
  239. button[type=default] {
  240. color: $font-color-dark;
  241. }
  242. /* input 样式 */
  243. .input-placeholder {
  244. color: #999999;
  245. }
  246. .placeholder {
  247. color: #999999;
  248. }
  249. </style>