home.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <el-container>
  3. <sidebar></sidebar>
  4. <el-container>
  5. <el-header>
  6. <span @click="showMerchant" v-if="$store.state.userInfo.memberType === 1" class="header-button">成为商户</span>
  7. <div class="account" @click="goAccount">
  8. <img src="../../static/image/head-account2.png" alt="">
  9. <div class="num">¥{{$store.state.userInfo.amount}}</div>
  10. </div>
  11. <div class="print" @click="goPrinter">
  12. <img src="../../static/image/head-print2.png" alt="">
  13. <div class="num con">打印设置</div>
  14. </div>
  15. <el-dropdown trigger="click">
  16. <span class="el-dropdown-link">
  17. <span style="cursor: pointer;">{{ userInfo.nickname }}</span>
  18. <i class="el-icon-arrow-down el-icon--right"></i>
  19. </span>
  20. <el-dropdown-menu slot="dropdown">
  21. <el-dropdown-item @click.native="loginOut">退出登录</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </el-header>
  25. <el-main style="background:#F1F2F5;">
  26. <router-view></router-view>
  27. </el-main>
  28. </el-container>
  29. <merchant-add ref="merchantAdd" :products="productList"></merchant-add>
  30. </el-container>
  31. </template>
  32. <script>
  33. import sidebar from "../common/sider.vue";
  34. import { mapState } from "vuex";
  35. import bus from "../common/bus.js";
  36. import merchantAdd from "../components/merchantAdd.vue";
  37. import { getProductList } from "../api/shop.js";
  38. export default {
  39. data() {
  40. return {
  41. audio: null,
  42. productList: [],
  43. };
  44. },
  45. computed: {
  46. ...mapState(["userInfo"]),
  47. },
  48. components: {
  49. sidebar,
  50. merchantAdd,
  51. },
  52. created() {
  53. bus.$emit("openGetSoundMsg");
  54. this.getProductList();
  55. let memberType = this.$store.state.userInfo.memberType;
  56. if (memberType === 1) {
  57. this.$confirm("您当前还不是商户,请先申请成为商户!", "提示", {
  58. confirmButtonText: "成为商户",
  59. cancelButtonText: "取消",
  60. type: "warning",
  61. center: true,
  62. })
  63. .then(() => {
  64. this.$refs.merchantAdd.init(0);
  65. })
  66. .catch(() => {});
  67. }
  68. },
  69. methods: {
  70. goAccount() {
  71. this.$router.push({
  72. name: "wallet",
  73. });
  74. },
  75. showMerchant() {
  76. this.$refs.merchantAdd.init(0);
  77. },
  78. getProductList() {
  79. getProductList().then((res) => {
  80. if (res.code === 200) {
  81. this.productList = res.data;
  82. } else {
  83. this.$message({
  84. type: "error",
  85. message: res.msg,
  86. });
  87. }
  88. });
  89. },
  90. goPrinter() {
  91. this.$router.push({
  92. name: "print",
  93. });
  94. },
  95. loginOut() {
  96. this.$confirm("此操作将退出当前登录用户, 是否继续?", "提示", {
  97. confirmButtonText: "确定",
  98. cancelButtonText: "取消",
  99. type: "warning",
  100. }).then(() => {
  101. localStorage.clear();
  102. this.$store.commit("setFirstLogin", true);
  103. bus.$emit("closeGetSoundMsg");
  104. this.$router.push({
  105. path: "/login",
  106. });
  107. });
  108. },
  109. },
  110. };
  111. </script>
  112. <style lang="scss" scoped="scoped">
  113. /deep/.el-header {
  114. display: flex;
  115. align-items: center;
  116. justify-content: flex-end;
  117. position: relative;
  118. width: 100%;
  119. height: 80px !important;
  120. }
  121. .el-main {
  122. position: absolute;
  123. left: 254px;
  124. right: 0;
  125. top: 80px;
  126. bottom: 0;
  127. background-color: #f1f2f5;
  128. padding: 10px;
  129. min-width: 550px;
  130. }
  131. .header-button {
  132. font-size: 16px;
  133. font-family: PingFang SC;
  134. font-weight: 400;
  135. color: #777777;
  136. cursor: pointer;
  137. margin-right: 40px;
  138. }
  139. .account,
  140. .print {
  141. display: flex;
  142. align-items: center;
  143. margin-right: 20px;
  144. cursor: pointer;
  145. img {
  146. width: 20px;
  147. height: 20px;
  148. margin-right: 5px;
  149. }
  150. .num {
  151. line-height: 25px;
  152. font-size: 16px;
  153. font-weight: 500;
  154. color: #fc7200;
  155. }
  156. .con {
  157. font-size: 15px;
  158. color: #333333;
  159. }
  160. }
  161. .home-content {
  162. display: flex;
  163. .side-box {
  164. // width: 200px;
  165. position: relative;
  166. }
  167. .content {
  168. flex: 1;
  169. flex-shrink: 1;
  170. }
  171. .title {
  172. color: #0074d9;
  173. }
  174. }
  175. </style>