index.vue 6.9 KB

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