addClassify.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="container-classify">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <view class="main">
  5. <view class="input-text">
  6. <view class="label">分类名称:</view>
  7. <u-input v-model="classify_name" height="120" maxlength='10' placeholder="请输入10个字符以内的分类名称" />
  8. </view>
  9. </view>
  10. <view class="footer">
  11. <view class="btn" @click="submit">{{id ? '确认编辑' : '确认添加'}}</view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. config: {
  20. back: true,
  21. title: '新增分类',
  22. color: '#1A1A1A',
  23. backgroundColor: [1, "#fff"],
  24. statusBarFontColor: '#1A1A1A',
  25. leftSlot: true
  26. },
  27. id: '',
  28. classify_name: ''
  29. }
  30. },
  31. onLoad(options) {
  32. if (options && options.id && options.label) {
  33. this.id = options.id
  34. this.classify_name = options.label
  35. }
  36. },
  37. methods: {
  38. submit() {
  39. if (!this.classify_name) {
  40. return this.$mUtil.toast('请输入分类名称')
  41. }
  42. if (this.id) {
  43. this.$http.put('/offlinetype/goods/update', {
  44. id: this.id,
  45. name: this.classify_name
  46. }).then(res => {
  47. if (res.code == 200) {
  48. this.$mUtil.toast('编辑成功')
  49. setTimeout(() => {
  50. uni.navigateBack()
  51. }, 1000)
  52. }
  53. })
  54. } else {
  55. this.$http.post('/offlinetype/goods/save', {
  56. name: this.classify_name
  57. }).then(res => {
  58. if (res.code == 200) {
  59. this.$mUtil.toast('添加成功')
  60. setTimeout(() => {
  61. uni.navigateBack()
  62. }, 1000)
  63. }
  64. })
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .container-classify {
  72. .main {
  73. padding: 0 60rpx;
  74. }
  75. .input-text {
  76. display: flex;
  77. align-items: center;
  78. height: 120rpx;
  79. border-bottom: 1rpx solid #f1f1f1;
  80. font-size: 28rpx;
  81. font-family: PingFang SC, PingFang SC-Regular;
  82. font-weight: 400;
  83. text-align: left;
  84. color: #333333;
  85. .label {
  86. margin-right: 12rpx;
  87. }
  88. }
  89. .footer {
  90. width: 100%;
  91. padding: 30rpx 60rpx;
  92. position: fixed;
  93. bottom: 0;
  94. display: flex;
  95. align-items: center;
  96. justify-content: space-between;
  97. background-color: #fff;
  98. .btn {
  99. width: 100%;
  100. color: #fff;
  101. text-align: center;
  102. line-height: 85rpx;
  103. border: 1rpx solid #3775F6;
  104. border-radius: 44rpx;
  105. background-color: #FA6138;
  106. font-size: 28rpx;
  107. font-family: PingFang SC, PingFang SC-Regular;
  108. font-weight: 400;
  109. text-align: center;
  110. }
  111. .online-btn {
  112. color: #FA6138;
  113. border: 1rpx solid #3775F6;
  114. background-color: #e7eefc;
  115. }
  116. }
  117. }
  118. </style>