index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="page">
  3. <div class="page__top" v-if="isAdmin">
  4. <div class="name">当前门店:</div>
  5. <div class="shop" v-if="!hideShop" @click="goShopSelect">
  6. <div class="shop__name">
  7. <!-- 最多6字 -->
  8. {{ curShop.name ? curShop.name : "加载中..." }}
  9. <i class="iconfont iconyoujiantou shop__arrow"></i>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="page__top" v-else>
  14. <div class="name">当前门店:</div>
  15. <div class="shop">
  16. <div class="shop__name">
  17. <!-- 最多6字 -->
  18. {{ curShop.name ? curShop.name : "加载中..." }}
  19. <!-- <i class="iconfont iconyoujiantou shop__arrow"></i> -->
  20. </div>
  21. </div>
  22. </div>
  23. <ul class="menu">
  24. <!-- <li class="item">
  25. <my-image
  26. class="img"
  27. src="/static/tabBar/icon_green_1.png"
  28. ></my-image>
  29. <span class="text">订单管理</span>
  30. </li> -->
  31. <li class="item" @click="jump('/pages/manage/add-good-form')">
  32. <my-image class="img" src="/static/icon/add.png"></my-image>
  33. <span class="text">新增商品</span>
  34. </li>
  35. <li class="item" @click="jump('/pages/manage/good-list')">
  36. <my-image class="img" src="/static/icon/edit.png"></my-image>
  37. <span class="text">编辑商品</span>
  38. </li>
  39. <li class="item" @click="jump('/pages/manage/classify')">
  40. <my-image
  41. class="img"
  42. src="/static/icon/classify.png"
  43. ></my-image>
  44. <span class="text">分类管理</span>
  45. </li>
  46. <li class="item" @click="jump('/pages/manage/statistics/nav')">
  47. <my-image
  48. class="img"
  49. src="/static/icon/statistics.png"
  50. ></my-image>
  51. <span class="text">数据统计</span>
  52. </li>
  53. </ul>
  54. <button class="btn" @click="layout">退出登录</button>
  55. <div class="ver">0.2.8</div>
  56. </div>
  57. </template>
  58. <script>
  59. import MyImage from "../../components/image/index";
  60. export default {
  61. name: "",
  62. components: { MyImage },
  63. // 数据
  64. data() {
  65. return {
  66. curShop: {},
  67. };
  68. },
  69. onLoad() {},
  70. async onShow() {
  71. console.log(this.user);
  72. if (this.isAdmin) {
  73. this.curShop = {
  74. name: this.user.storeName,
  75. id: this.user.storeId,
  76. };
  77. this.getShopList();
  78. } else {
  79. if (this.user.storeId) {
  80. this.curShop = {
  81. name: this.user.storeName,
  82. id: this.user.storeId,
  83. };
  84. } else {
  85. this.fn.showModal({
  86. content: "当前用户无门店设置,请前往后台设置所属店铺",
  87. });
  88. // this.getShopList();
  89. }
  90. }
  91. },
  92. // 函数
  93. methods: {
  94. getShopList() {
  95. uni.showLoading({
  96. title: "加载中...",
  97. });
  98. this.api.get("/Store/GetShopList").then((res) => {
  99. this.shopList = res.data;
  100. uni.hideLoading();
  101. uni.stopPullDownRefresh();
  102. if (this.curShop.id) {
  103. } else {
  104. this.curShop = res.data[0];
  105. if (!this.curShop.id) {
  106. let user = this.$store.state.user.user;
  107. user.storeId = this.curShop.id;
  108. user.storeName = this.curShop.name;
  109. this.$store.commit("user/update", {
  110. user,
  111. });
  112. }
  113. }
  114. });
  115. },
  116. goShopSelect() {
  117. this.router.push({
  118. path: "/pages/index/select",
  119. query: {
  120. entry: "manage",
  121. },
  122. });
  123. },
  124. layout() {
  125. this.$store.commit("user/logout", null);
  126. this.router.replace({
  127. path: "/pages/index/login",
  128. });
  129. },
  130. },
  131. // 数据计算
  132. computed: {
  133. user() {
  134. return this.$store.state.user.user;
  135. },
  136. isAdmin() {
  137. if (
  138. this.user.roleId === "50c41c5d-b54c-43ed-b587-10dcb60e72e5" ||
  139. this.user.roleId === "75b71b24-25de-40ac-a866-c8f5555b8b92"
  140. ) {
  141. return true;
  142. } else {
  143. return false;
  144. }
  145. },
  146. },
  147. // 数据监听
  148. watch: {},
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. .page {
  153. &__top {
  154. display: flex;
  155. align-items: center;
  156. justify-content: space-between;
  157. height: px(145);
  158. padding: 0 px(50);
  159. background-color: #fff;
  160. border-bottom: 1px solid #f1f1f1;
  161. }
  162. .name {
  163. font-size: px(36);
  164. color: #999;
  165. flex-shrink: 0;
  166. margin-right: px(20);
  167. }
  168. }
  169. .shop {
  170. display: flex;
  171. color: #666;
  172. font-size: px(36);
  173. flex-shrink: 0;
  174. margin-right: px(30);
  175. width: 100%;
  176. &__logo {
  177. margin-right: px(20);
  178. width: px(80);
  179. height: px(80);
  180. border-radius: 50%;
  181. box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
  182. overflow: hidden;
  183. /deep/ img {
  184. width: px(80);
  185. height: px(80);
  186. }
  187. }
  188. &__name {
  189. display: flex;
  190. white-space: nowrap;
  191. align-items: center;
  192. }
  193. &__arrow {
  194. margin-left: px(10);
  195. transform: rotate(90deg);
  196. }
  197. }
  198. .menu {
  199. display: flex;
  200. flex-wrap: wrap;
  201. border-top: 1px solid #f1f1f1;
  202. .item {
  203. width: 33.333333%;
  204. height: px(330);
  205. flex-shrink: 0;
  206. display: flex;
  207. flex-direction: column;
  208. justify-content: center;
  209. align-items: center;
  210. font-size: px(44);
  211. background-color: #fff;
  212. border-bottom: 1px solid #f1f1f1;
  213. /deep/ img {
  214. width: px(90);
  215. height: px(90);
  216. margin-bottom: px(30);
  217. }
  218. &:nth-child(3n-1),
  219. &:nth-child(3n) {
  220. border-left: 1px solid #f1f1f1;
  221. }
  222. }
  223. }
  224. .ver {
  225. margin-top: px(30);
  226. font-size: px(30);
  227. text-align: center;
  228. color: #aaa;
  229. }
  230. .btn {
  231. position: fixed;
  232. bottom: px(50);
  233. left: px(30);
  234. right: px(30);
  235. z-index: 10;
  236. color: #fff;
  237. background-color: #e92e25;
  238. font-size: px(44);
  239. }
  240. </style>