Index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="adminIndex-wrap">
  3. <div class="mess-wrap">
  4. <h5>您好!{{$store.state.userMess.userName}}管理员</h5>
  5. <div>
  6. <img src="../../assets/images/admin/userImg.png" />
  7. <div class="mess-content">
  8. <p>账户昵称:{{$store.state.userMess.userName}}</p>
  9. <p>登陆账号:{{$store.state.userMess.loginId}}</p>
  10. <p>登陆密码:{{$store.state.userMess.password}}</p>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="handle-wrap">
  15. <el-card class="box-card">
  16. <h6>商家账号人数</h6>
  17. <p>{{shopLength}}</p>
  18. <button @click="toShowAddShop">添加商家</button>
  19. </el-card>
  20. <el-card class="box-card handle-content">
  21. <h6>买家账号人数</h6>
  22. <p>{{buyerLength}}</p>
  23. <button @click="toShowAddBuyer">添加买家</button>
  24. </el-card>
  25. </div>
  26. <el-dialog :title="dialogTitle" :visible.sync="dialogTableVisible" :show-close="false">
  27. <div class="dialogheader">
  28. <el-form label-position="right" label-width="80px">
  29. <el-form-item label="店铺名称" v-show="dialogTitle=='添加商家'">
  30. <el-input v-model="showItem.userName"></el-input>
  31. </el-form-item>
  32. <el-form-item label="买家昵称" v-show="dialogTitle=='添加买家'">
  33. <el-input v-model="showItem.userName"></el-input>
  34. </el-form-item>
  35. <el-form-item label="登陆账号">
  36. <el-input v-model="showItem.name"></el-input>
  37. </el-form-item>
  38. <el-form-item label="登陆密码">
  39. <el-input v-model="showItem.password"></el-input>
  40. </el-form-item>
  41. <el-form-item label="店铺标签" v-show="dialogTitle=='添加商家'">
  42. <el-select v-model="showItem.label" placeholder="请选择">
  43. <el-option
  44. v-for="item in shopTagList"
  45. :key="item.id"
  46. :label="item.text"
  47. :value="item.value">
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="邮寄地址" v-show="dialogTitle=='添加买家'">
  52. <el-input v-model="showItem.address"></el-input>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button type="primary" @click="toAddShop" v-show="dialogTitle=='添加商家'">提交</el-button>
  56. <el-button type="primary" @click="toAddBuyer" v-show="dialogTitle=='添加买家'">提交</el-button>
  57. <el-button @click="toCancel">取消</el-button>
  58. </el-form-item>
  59. </el-form>
  60. </div>
  61. </el-dialog>
  62. </div>
  63. </template>
  64. <script>
  65. export default{
  66. data(){
  67. return{
  68. shopLength:"",
  69. buyerLength:"",
  70. shopTagList:[],
  71. dialogTableVisible:false,
  72. dialogTitle:"",
  73. showItem:{
  74. id:"",
  75. userName:"",
  76. name:"",
  77. password:"",
  78. label:"",
  79. address:"",
  80. }
  81. }
  82. },
  83. mounted(){
  84. this.getShopList();
  85. this.getBuyerList();
  86. this.getShopTagList();
  87. },
  88. methods:{
  89. getShopList(){
  90. this.axios.post(this.Api.getAccountList,{
  91. type:1
  92. }).then((res)=>{
  93. this.shopLength=res.data.length;
  94. }).catch((err)=>{
  95. console.log("getShopList:"+err);
  96. });
  97. },
  98. getBuyerList(){
  99. this.axios.post(this.Api.getAccountList,{
  100. type:2
  101. }).then((res)=>{
  102. this.buyerLength=res.data.length;
  103. }).catch((err)=>{
  104. console.log("getBuyerList:"+err);
  105. });
  106. },
  107. getShopTagList(){
  108. this.axios.post(this.Api.getTagtList,{}).then((res)=>{
  109. this.shopTagList=res.data;
  110. }).catch((err)=>{
  111. console.log("getShopTagList:"+err);
  112. });
  113. },
  114. toCancel(){
  115. this.dialogTableVisible=false;
  116. this.dialogTitle="";
  117. this.showItem={
  118. id:"",
  119. userName:"",
  120. name:"",
  121. password:"",
  122. label:""
  123. }
  124. },
  125. toShowAddShop(){
  126. this.dialogTableVisible=true;
  127. this.dialogTitle="添加商家";
  128. },
  129. toShowAddBuyer(){
  130. this.dialogTableVisible=true;
  131. this.dialogTitle="添加买家";
  132. },
  133. toAddShop(){
  134. if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.label==""){
  135. this.$message.error('请填写完整信息');
  136. console.log(this.showItem)
  137. return;
  138. }
  139. let param={
  140. type:1,
  141. handle:"1",
  142. mess:{
  143. name:this.showItem.name,
  144. password:this.showItem.password,
  145. userName:this.showItem.userName,
  146. label:this.showItem.label,
  147. }
  148. }
  149. this.axios.post(this.Api.adminHandle,param).then((res)=>{
  150. console.log(res);
  151. if(res.data.code==200){
  152. this.$message({
  153. message: '添加成功',
  154. type: 'success'
  155. });
  156. this.toCancel();
  157. this.getShopList();
  158. }
  159. }).catch((err)=>{
  160. console.log("toAdd:"+err);
  161. });
  162. },
  163. toAddBuyer(){
  164. if(this.showItem.name==""||this.showItem.password==""||this.showItem.userName==""||this.showItem.address==""){
  165. this.$message.error('请填写完整信息');
  166. return;
  167. }
  168. let param={
  169. type:2,
  170. handle:"1",
  171. mess:{
  172. name:this.showItem.name,
  173. password:this.showItem.password,
  174. userName:this.showItem.userName,
  175. address:this.showItem.address,
  176. }
  177. }
  178. this.axios.post(this.Api.adminHandle,param).then((res)=>{
  179. console.log(res);
  180. if(res.data.code==200){
  181. this.$message({
  182. message: '添加成功',
  183. type: 'success'
  184. });
  185. this.toCancel();
  186. this.getBuyerList();
  187. }
  188. }).catch((err)=>{
  189. console.log("toAdd:"+err);
  190. });
  191. }
  192. }
  193. }
  194. </script>
  195. <style scoped>
  196. .adminIndex-wrap{
  197. width: 100%;
  198. padding: 0 20px;
  199. }
  200. .adminIndex-wrap .mess-wrap{
  201. width: 100%;
  202. height: 150px;
  203. margin-top: 20px;
  204. background-color: #fff;
  205. border-left: 6px solid #3eb983;
  206. }
  207. .adminIndex-wrap h5{
  208. font-size: 18px;
  209. text-align: left;
  210. line-height: 35px;
  211. padding-left: 20px;
  212. }
  213. .adminIndex-wrap .mess-wrap img{
  214. width: 80px;
  215. height: 80px;
  216. display: block;
  217. float: left;
  218. margin: 15px 20px 15px;
  219. }
  220. .adminIndex-wrap .mess-content{
  221. width: calc(100% - 120px);
  222. height: 100%;
  223. float: left;
  224. margin-top: 5px;
  225. }
  226. .adminIndex-wrap .mess-content p{
  227. text-align: left;
  228. font-size: 16px;
  229. line-height: 35px;
  230. }
  231. .adminIndex-wrap .handle-wrap{
  232. width: 100%;
  233. height: 150px;
  234. display: flex;
  235. justify-content: space-around;
  236. flex-wrap: wrap;
  237. }
  238. .adminIndex-wrap .box-card{
  239. width: 450px;
  240. height: 174px;
  241. background-color: #fff;
  242. box-shadow: 0 2px 8px 0 rgba(0,0,0,0.3);
  243. border: 0;
  244. margin-top: 20px;
  245. }
  246. .adminIndex-wrap .box-card h6{
  247. font-size: 16px;
  248. line-height: 45px;
  249. }
  250. .adminIndex-wrap .box-card p{
  251. font-size: 34px;
  252. color: #008dc5;
  253. line-height: 60px;
  254. }
  255. .adminIndex-wrap .handle-content p{
  256. color: #54cdc8;
  257. }
  258. .adminIndex-wrap .box-card button{
  259. width: 100%;
  260. height: 50px;
  261. background-color: #008dc5;
  262. color: #fff;
  263. border: 0;
  264. font-size: 16px;
  265. margin-top: 20px;
  266. cursor: pointer;
  267. }
  268. .adminIndex-wrap .handle-content button{
  269. background-color: #54cdc8;
  270. }
  271. </style>
  272. <style>
  273. .adminIndex-wrap .el-card__body{
  274. padding: 0;
  275. }
  276. .adminIndex-wrap .el-dialog{
  277. width: 500px;
  278. /*height: 280px;*/
  279. border-radius: 6px;
  280. text-align: left;
  281. }
  282. .adminIndex-wrap .el-dialog__header{
  283. padding: 20px 30px 0 40px;
  284. }
  285. .adminIndex-wrap .el-dialog__body{
  286. padding: 20px 30px;
  287. }
  288. .adminIndex-wrap .dialogheader{
  289. width: 100%;
  290. /*height: 60px;*/
  291. }
  292. .adminIndex-wrap .dialogheader p{
  293. width: 360px;
  294. height: 30px;
  295. line-height: 30px;
  296. margin-top: 10px;
  297. border:1px solid #3eb983;
  298. border-radius: 6px;
  299. text-align: left;
  300. padding-left: 10px;
  301. margin-left: 60px;
  302. }
  303. .adminIndex-wrap .dialogheader p input{
  304. height: 24px;
  305. line-height: 24px;
  306. border:0;
  307. margin-left: 20px;
  308. }
  309. .adminIndex-wrap .dialogheader .button{
  310. background: #3eb983;
  311. color: #fff;
  312. text-align: center;
  313. margin-top: 40px;
  314. cursor: pointer;
  315. }
  316. .adminIndex-wrap .dialogheader .el-button{
  317. width: 173px;
  318. padding: 10px 0;
  319. }
  320. .adminIndex-wrap .dialogheader .el-form-item{
  321. margin-bottom: 15px;
  322. }
  323. .adminIndex-wrap .dialogheader .el-button+.el-button{
  324. margin-left: 0;
  325. }
  326. .adminIndex-wrap .dialogheader .el-button--primary{
  327. background-color: #3eb983;
  328. border-color: #3eb983;
  329. }
  330. .adminIndex-wrap .dialogheader .el-button--primary:hover{
  331. background-color: #3eb983;
  332. border-color: #3eb983;
  333. }
  334. .adminIndex-wrap .dialogheader .el-button--default{
  335. background-color: #bfcbd9;
  336. color: #fff;
  337. }
  338. .adminIndex-wrap .dialogheader .el-button--default:hover{
  339. background-color: #bfcbd9;
  340. border-color: #bfcbd9;
  341. color: #fff;
  342. }
  343. </style>