酒店桌布为微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
3.4 KiB

6 months ago
  1. <template>
  2. <view class="form">
  3. <view class="shopName">
  4. <view>物品分类</view>
  5. <view class="list">
  6. <view :class="{act : form.categoryId == item.id}" @click="form.categoryId = item.id" :key="index"
  7. v-for="(item, index) in category">
  8. {{ item.name }}
  9. </view>
  10. </view>
  11. </view>
  12. <view class="shopName">
  13. <view>物品照片</view>
  14. <view>
  15. <uv-upload :fileList="fileList" multiple :maxCount="1" width="180rpx" height="180rpx" multiple
  16. @afterRead="afterRead" @delete="deleteImage">
  17. <image src="../../static/help/uploading.png" mode="aspectFill"
  18. style="width: 180rpx;height: 180rpx;" />
  19. </uv-upload>
  20. </view>
  21. </view>
  22. <view class="shopName">
  23. <view>物品名称</view>
  24. <view>
  25. <input v-model="form.name" placeholder="请输入物品名称" clearable></input>
  26. </view>
  27. </view>
  28. <view class="shopName">
  29. <view>物品长度CM</view>
  30. <view>
  31. <input v-model="form.length" type="number" placeholder="请输入物品长度" clearable></input>
  32. </view>
  33. </view>
  34. <view class="shopName">
  35. <view>物品宽度CM</view>
  36. <view>
  37. <input v-model="form.wide" type="number" placeholder="请输入物品宽度" clearable></input>
  38. </view>
  39. </view>
  40. <view class="shopName">
  41. <view>物品数量</view>
  42. <view>
  43. <uv-number-box v-model="form.num" :min="1"></uv-number-box>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { mapState } from 'vuex'
  50. export default {
  51. data() {
  52. return {
  53. form: {
  54. categoryId: 0,
  55. name: '',
  56. num: 1,
  57. length: '',
  58. wide: '',
  59. },
  60. fileList: [],
  61. }
  62. },
  63. computed: {
  64. ...mapState(['category']),
  65. },
  66. mounted() {
  67. this.closeForm()
  68. },
  69. methods: {
  70. submit(fn) {
  71. this.form.pic = this.fileList.map((item) => item.url).join(",")
  72. let form = {
  73. ...this.form
  74. }
  75. if (this.$utils.verificationAll(form, {
  76. pic: '请上传物品照片',
  77. name: '请输入物品名称',
  78. length: '请输入物品长度',
  79. wide: '请输入物品宽度',
  80. })) {
  81. return
  82. }
  83. fn && fn(form)
  84. },
  85. closeForm() {
  86. this.form = {
  87. categoryId: 0,
  88. name: '',
  89. num: 1,
  90. length: '',
  91. wide: '',
  92. }
  93. this.fileList = []
  94. if (this.category.length) {
  95. this.form.categoryId = this.category[0].id
  96. }
  97. },
  98. deleteImage(e) {
  99. this.fileList.splice(e.index, 1)
  100. },
  101. afterRead(e) {
  102. let self = this
  103. e.file.forEach(file => {
  104. self.$Oss.ossUpload(file.url).then(url => {
  105. self.fileList.push({
  106. url
  107. })
  108. })
  109. })
  110. },
  111. }
  112. }
  113. </script>
  114. <style scoped lang="scss">
  115. .form {
  116. padding: 20rpx 0;
  117. .shopName {
  118. display: flex;
  119. align-items: center;
  120. background-color: #FFF;
  121. margin: 10rpx 0 0 0;
  122. padding: 10rpx 20rpx;
  123. >view:nth-of-type(1) {
  124. width: 30%;
  125. // font-weight: 700;
  126. }
  127. >view:nth-of-type(2) {
  128. width: 70%;
  129. // padding: 0 20rpx 0 0;
  130. border-radius: 10rpx;
  131. overflow: hidden;
  132. input {
  133. background-color: #f5f5f5;
  134. // color: #a4a4a4;
  135. font-size: 28rpx;
  136. padding: 8rpx 8rpx 8rpx 15rpx;
  137. }
  138. }
  139. }
  140. }
  141. .list {
  142. display: flex;
  143. flex-wrap: wrap;
  144. font-size: 22rpx;
  145. .act {
  146. color: $uni-color;
  147. border: 1px solid $uni-color;
  148. background-color: #F9E7DE;
  149. }
  150. view {
  151. border-radius: 15rpx;
  152. background-color: #F3F3F3;
  153. border: 1px solid #F3F3F3;
  154. margin: 10rpx;
  155. display: flex;
  156. justify-content: center;
  157. padding: 10rpx 20rpx;
  158. }
  159. }
  160. </style>